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
December 2012
- 2 participants
- 109 discussions
31 Dec '12
Author: tchemit
Date: 2012-12-31 19:59:33 +0100 (Mon, 31 Dec 2012)
New Revision: 134
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/134
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (can save now some splitted batches :))
refs #1806: [Onglet Poisson] Pr?\195?\169filtrage du tableau (add ui, now need to do logic)
Added:
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/xmi/tutti-persistence.zargo
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/benthos/BenthosBatchTableModel.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/plankton/PlanktonBatchTableModel.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/SpeciesFrequencyTableModel.java
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/content/operation/fishing/environment/EnvironmentTableModel.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/HydrologyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ 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)
@@ -73,7 +73,7 @@
}
@Override
- protected AccidentalBatchRowModel createNewRow() {
+ public AccidentalBatchRowModel createNewRow() {
AccidentalBatchRowModel result = new AccidentalBatchRowModel();
// by default empty row is not valid
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -87,7 +87,7 @@
}
@Override
- protected BenthosBatchRowModel createNewRow() {
+ public BenthosBatchRowModel createNewRow() {
BenthosBatchRowModel result = new BenthosBatchRowModel();
// by default empty row is not valid
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -76,7 +76,7 @@
}
@Override
- protected MacroWasteBatchRowModel createNewRow() {
+ public MacroWasteBatchRowModel createNewRow() {
MacroWasteBatchRowModel result = new MacroWasteBatchRowModel();
// by default empty row is not valid
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -80,7 +80,7 @@
}
@Override
- protected PlanktonBatchRowModel createNewRow() {
+ public PlanktonBatchRowModel createNewRow() {
PlanktonBatchRowModel result = new PlanktonBatchRowModel();
// by default empty row is not valid
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
@@ -41,6 +42,36 @@
private static final long serialVersionUID = 1L;
+ public static class SampleColumnIdentifier<R> extends ColumnIdentifier<R> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static <R> SampleColumnIdentifier<R> newId(String propertyName,
+ String weightPropertyName,
+ String headerI18nKey,
+ String headerTipI18nKey) {
+ return new SampleColumnIdentifier<R>(propertyName,
+ weightPropertyName,
+ headerI18nKey,
+ headerTipI18nKey);
+ }
+
+ private final String weightPropertyName;
+
+ protected SampleColumnIdentifier(String propertyName,
+ String weightPropertyName,
+ String headerI18nKey,
+ String headerTipI18nKey
+ ) {
+ super(propertyName, headerI18nKey, headerTipI18nKey);
+ this.weightPropertyName = weightPropertyName;
+ }
+
+ public void setWeightValue(R entry, Object value) {
+ TuttiUIUtil.setProperty(entry, weightPropertyName, value);
+ }
+ }
+
public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SPECIES,
n_("tutti.table.species.batch.header.speciesByCode"),
@@ -51,28 +82,33 @@
n_("tutti.table.species.batch.header.speciesByGenusCode"),
n_("tutti.table.species.batch.header.speciesByGenusCode"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sortedUnsortedCategory"),
n_("tutti.table.species.batch.header.sortedUnsortedCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SIZE_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sizeCategory"),
n_("tutti.table.species.batch.header.sizeCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SEX_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sexCategory"),
n_("tutti.table.species.batch.header.sexCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_MATURITY_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.maturityCategory"),
n_("tutti.table.species.batch.header.maturityCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_AGE_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.ageCategory"),
n_("tutti.table.species.batch.header.ageCategory"));
@@ -133,7 +169,7 @@
}
@Override
- protected SpeciesBatchRowModel createNewRow() {
+ public SpeciesBatchRowModel createNewRow() {
SpeciesBatchRowModel result = new SpeciesBatchRowModel();
// by default empty row is not valid
@@ -147,8 +183,13 @@
int columnIndex,
ColumnIdentifier<SpeciesBatchRowModel> propertyName,
SpeciesBatchRowModel entry) {
- super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ if (sampleCols.contains(propertyName)) {
+ ((SampleColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue);
+ } else {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ }
+
if (propertyName == SPECIES_BY_CODE) {
// update also other columns
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -75,9 +75,56 @@
editable: false;
}
+#tablePopup {
+ label: "tutti.title.batchActions";
+}
+
+#splitBatchMenu {
+ text: "tutti.action.splitBatch";
+ actionIcon: batch-split;
+}
+
+#removeSubBatchMenu {
+ text: "tutti.action.removeSubBatch";
+ actionIcon: batch-delete;
+}
+
#table {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
selectionForeground: {Color.BLACK};
sortable: false;
}
+
+#createSpeciesBatchButton {
+ actionIcon: batch-split;
+ text: "tutti.action.createSpeciesBatch";
+}
+
+#filterTablePane {
+ border: {new TitledBorder(null, _("tutti.legend.filterSpeciesBatchMode"))};
+}
+
+#filterSpeciesBatchAllButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.all";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.all";
+ value: "all";
+ selected: {model.isTableViewModeAll()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchLeafButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.leaf";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.leaf";
+ value: "leaf";
+ selected: {model.isTableViewModeLeaf()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchRootButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.root";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.root";
+ value: "root";
+ selected: {model.isTableViewModeRoot()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -87,6 +87,13 @@
<AttachmentEditorUI id='attachmentEditor'/>
+ <JPopupMenu id='tablePopup'
+ onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>
+ <JMenuItem id='splitBatchMenu'
+ onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='removeSubBatchMenu'
+ onActionPerformed='handler.removeBatch()'/>
+ </JPopupMenu>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total / Poids total vrac -->
@@ -122,10 +129,31 @@
<JTextField id='speciesTotalUnsortedWeightField'/>
</cell>
</row>
+
+ <!-- Toolbar / Filter -->
+ <row>
+ <cell columns="4">
+ <JPanel id='tableToolbar' layout='{new BorderLayout()}'>
+ <JButton id='createSpeciesBatchButton' constraints='BorderLayout.WEST'
+ onActionPerformed='handler.createSpeciesBatch()'/>
+ <JPanel id='filterTablePane' constraints='BorderLayout.CENTER'>
+ <JRadioButton id='filterSpeciesBatchAllButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ALL)'/>
+ <JRadioButton id='filterSpeciesBatchLeafButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.LEAF)'/>
+ <JRadioButton id='filterSpeciesBatchRootButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
+ </JPanel>
+
+ </JPanel>
+ </cell>
+ </row>
+
</Table>
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)'/>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)'
+ onMouseClicked='handler.autoSelectRowInTable(event)'/>
</JScrollPane>
</JPanel>
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -42,22 +42,33 @@
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.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.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+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;
import java.util.List;
import java.util.Set;
+import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -218,7 +229,6 @@
persistenceService.deleteSpeciesBatch(catchBean.getId());
}
}
-
}
@Override
@@ -357,6 +367,7 @@
ui.getContextValue(EditCatchesUIModel.class);
SpeciesBatchUIModel model = new SpeciesBatchUIModel(catchesUIModel);
+ model.setTableViewMode(TableViewMode.ALL);
ui.setContextValue(model);
PersistenceService service =
@@ -529,6 +540,162 @@
//-- Public methods --//
//------------------------------------------------------------------------//
+ public void autoSelectRowInTable(MouseEvent e) {
+ if (SwingUtilities.isRightMouseButton(e) ||
+ e.isPopupTrigger()) {
+
+ // get the coordinates of the mouse click
+ Point p = e.getPoint();
+
+ JXTable source = (JXTable) e.getSource();
+
+ // get the row index at this point
+ int rowIndex = source.rowAtPoint(p);
+
+ if (log.isInfoEnabled()) {
+ log.info("At point [" + p + "] found Row " + rowIndex);
+ }
+ if (rowIndex != -1) {
+
+ // select new row
+ source.setRowSelectionInterval(rowIndex, rowIndex);
+ }
+
+ ui.getTablePopup().show(source, e.getX(), e.getY());
+ }
+ }
+
+ 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;
+ }
+ }
+
+ ui.getSplitBatchMenu().setEnabled(enableSplit);
+ ui.getRemoveSubBatchMenu().setEnabled(enableRemove);
+ }
+
+ public void removeBatch() {
+ //TODO
+ }
+
+ public void createSpeciesBatch() {
+
+ }
+ public void splitBatch() {
+
+ JXTable table = getTable();
+
+ // get selected row
+ int rowIndex = table.getSelectedRow();
+ SpeciesBatchRowModel selectedRow = getTableModel().getEntry(rowIndex);
+
+ if (log.isInfoEnabled()) {
+ log.info("Open split batch for row [" + rowIndex + "]");
+ }
+ SplitSampleCategoryUI sampleCategoryEditor = ui.getSampleCategoryEditor();
+ sampleCategoryEditor.getHandler().editBatch(selectedRow);
+
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ // open split batch dialog
+ TuttiUIUtil.openInDialog(sampleCategoryEditor,
+ frame,
+ _("tutti.title.splitBatch"), true, null);
+
+ // at close, synch back batches ?
+ SplitSampleCategoryUIModel splitModel = sampleCategoryEditor.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();
+ for (SplitSampleCategoryRowModel row : splitModel.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ SpeciesBatchRowModel batchNewRow = batchTableModel.createNewRow();
+ batchNewRow.setSpecies(selectedRow.getSpecies());
+ batchNewRow.setSpeciesToConfirm(selectedRow.getSpeciesToConfirm());
+ if (selectedCategory == SampleCategoryType.sortedUnsorted) {
+ batchNewRow.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSortedUnsortedCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSortedUnsortedCategory(selectedRow.getSortedUnsortedCategory());
+ batchNewRow.setSortedUnsortedCategoryWeight(selectedRow.getSortedUnsortedCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.size) {
+ batchNewRow.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSizeCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSizeCategory(selectedRow.getSizeCategory());
+ batchNewRow.setSizeCategoryWeight(selectedRow.getSizeCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.sex) {
+ batchNewRow.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSexCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSexCategory(selectedRow.getSexCategory());
+ batchNewRow.setSexCategoryWeight(selectedRow.getSexCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.maturity) {
+ batchNewRow.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setMaturityCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setMaturityCategory(selectedRow.getMaturityCategory());
+ batchNewRow.setMaturityCategoryWeight(selectedRow.getMaturityCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.age) {
+ batchNewRow.setAgeCategory((Float) row.getCategoryValue());
+ batchNewRow.setAgeCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setAgeCategory(selectedRow.getAgeCategory());
+ batchNewRow.setAgeCategoryWeight(selectedRow.getAgeCategoryWeight());
+ }
+ batchTableModel.addNewRow(++insertRow, batchNewRow);
+ boolean rowValid = isRowValid(batchNewRow);
+ batchNewRow.setValid(rowValid);
+ saveRow(batchNewRow);
+ }
+ }
+ }
+
+ // reset split ui
+ sampleCategoryEditor.getHandler().editBatch(null);
+
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
+ table.requestFocus();
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -124,5 +124,20 @@
Object oldValue = getTableViewMode();
this.tableViewMode = tableViewMode;
firePropertyChange(PROPERTY_TABLE_VIEW_MODE, oldValue, tableViewMode);
+ firePropertyChange("tableViewModeAll", null, isTableViewModeAll());
+ firePropertyChange("tableViewModeLeaf", null, isTableViewModeLeaf());
+ firePropertyChange("tableViewModeRoot", null, isTableViewModeRoot());
}
+
+ public boolean isTableViewModeAll() {
+ return TableViewMode.ALL.equals(tableViewMode);
+ }
+
+ public boolean isTableViewModeLeaf() {
+ return TableViewMode.LEAF.equals(tableViewMode);
+ }
+
+ public boolean isTableViewModeRoot() {
+ return TableViewMode.ROOT.equals(tableViewMode);
+ }
}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -78,7 +78,7 @@
}
@Override
- protected SpeciesFrequencyRowModel createNewRow() {
+ public SpeciesFrequencyRowModel createNewRow() {
Float defaultStep = null;
int rowCount = getRowCount();
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -24,6 +24,7 @@
* #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;
@@ -73,8 +74,8 @@
category.setCategoryType(categoryType);
}
- public Float getCategoryValue() {
- return category.getCategoryWeight();
+ public Serializable getCategoryValue() {
+ return category.getCategoryValue();
}
public void setCategoryValue(Serializable categoryValue) {
@@ -83,7 +84,18 @@
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();
}
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -41,11 +41,16 @@
private static final long serialVersionUID = 1L;
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> CATEGORY_VALUE = ColumnIdentifier.newId(
+ 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"),
@@ -53,17 +58,15 @@
private final SplitSampleCategoryUIModel uiModel;
-
public SplitSampleCategoryTableModel(TableColumnModel columnModel,
SplitSampleCategoryUIModel uiModel) {
super(columnModel);
this.uiModel = uiModel;
- setNoneEditableCols();
+ setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
}
@Override
- protected SplitSampleCategoryRowModel createNewRow() {
-
+ public SplitSampleCategoryRowModel createNewRow() {
SplitSampleCategoryRowModel result = new SplitSampleCategoryRowModel();
result.setCategoryType(uiModel.getSelectedCategory());
result.setValid(false);
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -32,7 +32,7 @@
border: {new TitledBorder(null, _("tutti.legend.sampleCategoryConfiguration"))};
}
-#categoryLabelLabel {
+#categoryLabel {
text: "tutti.label.sampleCategoryConfiguration.category";
labelFor: {categoryComboBox};
}
@@ -47,6 +47,36 @@
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";
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -69,6 +69,7 @@
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'>
@@ -91,6 +92,43 @@
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'>
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -25,10 +25,9 @@
*/
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.service.PersistenceService;
+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;
@@ -37,11 +36,11 @@
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 org.nuiton.util.decorator.Decorator;
import javax.swing.JDialog;
import java.beans.PropertyChangeEvent;
@@ -74,13 +73,6 @@
*/
private final SplitSampleCategoryUI ui;
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- protected final PersistenceService persistenceService;
-
public SplitSampleCategoryUIHandler(SpeciesBatchUI parentUi,
SplitSampleCategoryUI ui) {
super(parentUi.getHandler().getContext(),
@@ -88,7 +80,6 @@
SplitSampleCategoryRowModel.PROPERTY_WEIGHT);
this.parentUi = parentUi;
this.ui = ui;
- this.persistenceService = getContext().getService(PersistenceService.class);
}
//------------------------------------------------------------------------//
@@ -114,7 +105,16 @@
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
SplitSampleCategoryRowModel row) {
- //TODO
+ if (rowMonitor.wasModified()) {
+
+ if (row.isValid()) {
+ if (log.isInfoEnabled()) {
+ log.info("Change row that was modified and valid");
+ }
+ }
+
+ rowMonitor.clearModified();
+ }
}
@Override
@@ -128,8 +128,8 @@
if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
- // Need to recompute the total weight
- computeComputedWeight(row);
+ // Need to recompute the sample weight
+ computeSampleWeight(row);
}
}
@@ -167,7 +167,14 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- getModel().setSelectedCategory(null);
+ SplitSampleCategoryUIModel source =
+ (SplitSampleCategoryUIModel) evt.getSource();
+
+ // unselect previous selected category
+ source.setSelectedCategory(null);
+
+ // fill comboBox with new list
+ ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
}
});
@@ -176,11 +183,21 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- SampleCategoryEnum newValue = (SampleCategoryEnum) evt.getNewValue();
+ 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());
@@ -194,51 +211,72 @@
//-- Public methods --//
//------------------------------------------------------------------------//
- public void editBatch(SpeciesBatchRowModel row) {
+ 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());
- //TODO Use the samplingOrder
- SampleCategory<?> lastCategory = null;
+ Float batchWeight = null;
- if (row.getSortedUnsortedSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sortedUnsorted);
- lastCategory = row.getSortedUnsortedSampleCategory();
- }
+ if (batch != null) {
+ //TODO Use the samplingOrder
+ List<String> samplingOrder =
+ parentUi.getModel().getSamplingOrder();
- if (row.getSizeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.size);
- lastCategory = row.getSizeSampleCategory();
- }
+ SampleCategory<?> lastCategory = null;
- if (row.getSexSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sex);
- lastCategory = row.getSexSampleCategory();
- }
+ if (batch.getSortedUnsortedSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sortedUnsorted);
+ lastCategory = batch.getSortedUnsortedSampleCategory();
+ }
- if (row.getMaturitySampleCategory().isValid()) {
- categories.remove(SampleCategoryType.maturity);
- lastCategory = row.getMaturitySampleCategory();
- }
+ if (batch.getSizeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.size);
+ lastCategory = batch.getSizeSampleCategory();
+ }
- if (row.getAgeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.age);
- lastCategory = row.getAgeSampleCategory();
+ 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();
+ }
}
- Float batchWeight = lastCategory == null ? null :
- 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(row);
+ model.setBatch(batch);
}
public void close() {
@@ -247,52 +285,62 @@
log.info("Will close UI " + ui);
}
- SplitSampleCategoryUIModel model = getModel();
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
- // transfer rows to editor
- List<SplitSampleCategoryRowModel> safeRows = Lists.newArrayList();
- for (SplitSampleCategoryRowModel row : model.getRows()) {
- if (row.isValid()) {
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
- // can keep this row
- safeRows.add(row);
- }
- }
+ protected void computeSampleWeight(SplitSampleCategoryRowModel row) {
if (log.isInfoEnabled()) {
- log.info("Push back " + safeRows.size() +
- " rows to batch " + model.getBatch());
+ log.info("Will recompute sample weight from row: " + row);
}
- //TODO Create rows in batch table model
- editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ Float result = 0f;
+ List<SplitSampleCategoryRowModel> rows = getTableModel().getRows();
+ for (SplitSampleCategoryRowModel rowModel : rows) {
+ Float weight = rowModel.getWeight();
+ if (weight != null) {
+ result += weight;
+ }
+ }
+ getModel().setSampleWeight(result);
}
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
+ protected void validateModel() {
- protected void computeComputedWeight(SplitSampleCategoryRowModel row) {
+ SplitSampleCategoryUIModel model = getModel();
- if (log.isInfoEnabled()) {
- log.info("Will recompute computed weight for frequency: " + row);
+ 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(SampleCategoryEnum category) {
+ 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) {
- Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
- getDecorator(CaracteristicQualitativeValue.class, null);
-
switch (category) {
case sortedUnsorted:
@@ -308,18 +356,22 @@
data = persistenceService.getMaturityCaracteristic();
break;
case age:
+ editableCategoryValue = true;
addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.CATEGORY_VALUE,
+ SplitSampleCategoryTableModel.EDITABLE_CATEGORY_VALUE,
TuttiUI.DECIMAL1_PATTERN);
break;
}
if (data != null) {
- addComboDataColumnToModel(columnModel,
- SplitSampleCategoryTableModel.CATEGORY_VALUE,
- caracteristicDecorator,
- data.getQualitativeValue());
+ if (log.isInfoEnabled()) {
+ log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
+ }
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(CaracteristicQualitativeValue.class),
+ SplitSampleCategoryTableModel.READ_ONLY_CATEGORY_VALUE);
}
{ // Weight
@@ -335,21 +387,42 @@
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);
- //TODO Fix this!
-// installTableKeyListener(columnModel, table);
+ // 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);
- tableModel.addNewRow(newRow);
+ 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
Modified: 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 12:31:24 UTC (rev 133)
+++ 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)
@@ -24,6 +24,7 @@
* #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;
@@ -42,6 +43,8 @@
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";
@@ -85,7 +88,6 @@
*/
protected Float batchWeight;
-
/**
* Sample weight of split batches.
*
@@ -102,9 +104,15 @@
}
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;
}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -55,7 +55,7 @@
}
@Override
- protected EnvironmentRowModel createNewRow() {
+ public EnvironmentRowModel createNewRow() {
EnvironmentRowModel result = new EnvironmentRowModel();
return result;
}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -55,7 +55,7 @@
}
@Override
- protected GearShootingRowModel createNewRow() {
+ public GearShootingRowModel createNewRow() {
GearShootingRowModel result = new GearShootingRowModel();
return result;
}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -65,7 +65,7 @@
}
@Override
- protected HydrologyRowModel createNewRow() {
+ public HydrologyRowModel createNewRow() {
HydrologyRowModel result = new HydrologyRowModel();
return result;
}
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -81,7 +81,7 @@
}
@Override
- protected EditProtocolSpeciesRowModel createNewRow() {
+ public EditProtocolSpeciesRowModel createNewRow() {
EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel();
result.setMaturityEnabled(true);
result.setSizeEnabled(true);
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 12:31:24 UTC (rev 133)
+++ 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)
@@ -79,7 +79,7 @@
*/
protected Set<ColumnIdentifier<?>> noneEditableCols;
- protected abstract R createNewRow();
+ public abstract R createNewRow();
protected AbstractTuttiTableModel(TableColumnModel columnModel) {
int nbcols = columnModel.getColumnCount();
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 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-31 18:59:33 UTC (rev 134)
@@ -8,6 +8,7 @@
tutti.action.close=Fermer
tutti.action.configuration=Configuration
tutti.action.configuration.tip=Configurer Tutti
+tutti.action.createSpeciesBatch=Créer un lot pour une espèce
tutti.action.edit=Editer
tutti.action.exit=Quitter
tutti.action.exit.tip=Quitter l'application
@@ -23,12 +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.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.application.config=Configuration de l'application Tutti
tutti.application.name=Tutti
tutti.config.category.applications=Application
@@ -77,6 +80,9 @@
tutti.label.cruise.program=Série
tutti.label.cruise.surveyPart=Série partielle
tutti.label.cruise.year=Année
+tutti.label.filterSpeciesBatchMode.mode.all=Tout voir
+tutti.label.filterSpeciesBatchMode.mode.leaf=Voir les feuilles
+tutti.label.filterSpeciesBatchMode.mode.root=Voir les parents
tutti.label.fishingOperation.date=Date
tutti.label.fishingOperation.distanceChalutee=Distance chalutée
tutti.label.fishingOperation.duree=Durée
@@ -116,7 +122,11 @@
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
tutti.label.protocol=Protocol de saisie
+tutti.label.sampleCategoryConfiguration.batchWeight=Poids total à catégoriser
+tutti.label.sampleCategoryConfiguration.category=Catégorie
tutti.label.sampleCategoryConfiguration.sample=Echantillon ?
+tutti.label.sampleCategoryConfiguration.sampleWeight=Poids total catégorisé
+tutti.label.sampleCategoryConfiguration.species=Espèce
tutti.label.tab.accidentel=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
@@ -138,6 +148,7 @@
tutti.legend.catch.macroWaste=Macro déchets
tutti.legend.catch.species=Espèces
tutti.legend.catch.total=Capture
+tutti.legend.filterSpeciesBatchMode=Filtrer les lots
tutti.legend.frequencyConfiguration=Configuration
tutti.legend.sampleCategoryConfiguration=Configuration
tutti.menu.actions=Actions
@@ -223,6 +234,7 @@
tutti.table.species.sampleCategory.header.weight=Poids
tutti.timeeditor.H=H
tutti.title.about=À propos de Tutti
+tutti.title.batchActions=Actions possibles
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
@@ -239,6 +251,7 @@
tutti.title.selectedCruise=Campagne %s
tutti.title.selectedProgram=Série de campagne %s
tutti.title.selectedProtocol=Protocol %s
+tutti.title.splitBatch=Catégoriser un lot
tutti.to.be.done=< A FAIRE >
tutti.tooltip.attachment.none=Pas de pièce-jointes
tutti.tooltip.comment.none=Pas de commentaire
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: 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-split.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
1
0
r133 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation content/operation/catches/species/frequency util/table
by tchemit@users.forge.codelutin.com 31 Dec '12
by tchemit@users.forge.codelutin.com 31 Dec '12
31 Dec '12
Author: tchemit
Date: 2012-12-31 13:31:24 +0100 (Mon, 31 Dec 2012)
New Revision: 133
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/133
Log:
- improve navigation action in cells (now not force to create a new row if at end)
- improve listener api (can uninstall them too!)
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/catches/species/frequency/SpeciesFrequencyUIHandler.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/MoveToNextEditableCellAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
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-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -114,7 +114,7 @@
TableColumnModel columnModel,
AbstractTuttiTableModel<R> tableModel) {
- installTableKeyListener(columnModel, table);
+ installTableKeyListener(columnModel, table, true);
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/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-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -59,6 +59,11 @@
private static final Log log =
LogFactory.getLog(SpeciesFrequencyUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
private final SpeciesFrequencyUI ui;
public SpeciesFrequencyUIHandler(TuttiUIContext context,
@@ -146,7 +151,6 @@
lengthStepCaracterics,
model.getLengthStepCaracteristic());
-
//TODO Should it come from PROTOCOL or config ?
model.setStep(.5f);
@@ -220,7 +224,7 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- installTableKeyListener(columnModel, table);
+ installTableKeyListener(columnModel, table, true);
initTable(table);
}
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-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -25,6 +25,7 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
@@ -62,7 +63,6 @@
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Enumeration;
@@ -295,79 +295,13 @@
// always scroll to selected row
SwingUtil.scrollToTableSelection(getTable());
+ // always force to uninstall listener
+ uninstallTableSaveOnRowChangedSelectionListener();
+
// save when row chaged and was modified
- ListSelectionListener listener = new TableRowModificationListener<R>(
- getTableModel(), rowMonitor) {
- @Override
- protected void saveSelectedRow() {
-
- saveSelectedRowIfNeeded();
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
+ installTableSaveOnRowChangedSelectionListener();
}
- protected final void saveSelectedRowIfNeeded() {
-
- R row = rowMonitor.getBean();
-
- if (row != null) {
-
- saveSelectedRowIfRequired(rowMonitor, row);
- }
- }
-
- protected KeyListener installTableKeyListener(TableColumnModel columnModel,
- JTable table) {
-
- AbstractTuttiTableModel<R> model = getTableModel();
- final MoveToNextEditableCellAction nextCellAction =
- MoveToNextEditableCellAction.newAction(model, table);
- final MoveToPreviousEditableCellAction previousCellAction =
- MoveToPreviousEditableCellAction.newAction(model, table);
-
- final MoveToNextEditableRowAction nextRowAction =
- 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 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) {
- e.consume();
- nextCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
- e.consume();
- previousCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
- e.consume();
- previousRowAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
- e.consume();
- nextRowAction.actionPerformed(null);
- }
- }
- };
- table.addKeyListener(keyAdapter);
-
- Enumeration<TableColumn> columns = columnModel.getColumns();
- while (columns.hasMoreElements()) {
- TableColumn tableColumn = columns.nextElement();
- TableCellEditor cellEditor = tableColumn.getCellEditor();
- if (cellEditor instanceof NumberCellEditor) {
- NumberCellEditor editor = (NumberCellEditor) cellEditor;
- editor.getNumberEditor().getTextField().addKeyListener(keyAdapter);
- }
- }
- return keyAdapter;
- }
-
protected void addColumnToModel(TableColumnModel model,
TableCellEditor editor,
TableCellRenderer renderer,
@@ -433,11 +367,13 @@
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(newListCellRender(decorator));
+ List<B> dataToList = Lists.newArrayList(data);
+
// add a null value at first position
- if (!data.isEmpty() && data.get(0) != null) {
- data.add(0, null);
+ if (!dataToList.isEmpty() && dataToList.get(0) != null) {
+ dataToList.add(0, null);
}
- SwingUtil.fillComboBox(comboBox, data, null);
+ SwingUtil.fillComboBox(comboBox, dataToList, null);
ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
BeanUIUtil.decorate(comboBox, converter);
@@ -470,4 +406,147 @@
return result;
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods (listener methods) --//
+ //------------------------------------------------------------------------//
+
+ private ListSelectionListener tableSelectionListener;
+
+ private KeyAdapter keyAdapter;
+
+ protected void installTableSaveOnRowChangedSelectionListener() {
+
+ Preconditions.checkState(
+ tableSelectionListener == null,
+ "There is already a tableSelectionListener registred, " +
+ "remove it before invoking this method.");
+
+ // create new listener
+ // save when row chaged and was modified
+
+ tableSelectionListener = new TableRowModificationListener<R>(
+ getTableModel(), rowMonitor) {
+ @Override
+ protected void saveSelectedRow() {
+
+ saveSelectedRowIfNeeded();
+ }
+ };
+
+ if (log.isInfoEnabled()) {
+ log.info("Intall " + tableSelectionListener + " on tableModel " + getTableModel());
+ }
+
+ getTable().getSelectionModel().addListSelectionListener(tableSelectionListener);
+ }
+
+ protected void uninstallTableSaveOnRowChangedSelectionListener() {
+
+ if (tableSelectionListener != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Desintall " + tableSelectionListener);
+ }
+
+ // there was a previous selection listener, remove it
+ getTable().getSelectionModel().removeListSelectionListener(tableSelectionListener);
+ tableSelectionListener = null;
+ }
+ }
+
+ protected void installTableKeyListener(TableColumnModel columnModel,
+ JTable table, boolean canCreateRow) {
+
+ Preconditions.checkState(
+ keyAdapter == null,
+ "There is already a tableSelectionListener registred, " +
+ "remove it before invoking this method.");
+
+ AbstractTuttiTableModel<R> model = getTableModel();
+ final MoveToNextEditableCellAction nextCellAction =
+ MoveToNextEditableCellAction.newAction(model, table, canCreateRow);
+ final MoveToPreviousEditableCellAction previousCellAction =
+ MoveToPreviousEditableCellAction.newAction(model, table);
+
+ final MoveToNextEditableRowAction nextRowAction =
+ MoveToNextEditableRowAction.newAction(model, table, canCreateRow);
+ 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) {
+ e.consume();
+ nextCellAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ e.consume();
+ previousCellAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_UP) {
+ e.consume();
+ previousRowAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ e.consume();
+ nextRowAction.actionPerformed(null);
+ }
+ }
+ };
+
+ if (log.isInfoEnabled()) {
+ log.info("Intall " + keyAdapter);
+ }
+
+ table.addKeyListener(keyAdapter);
+
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ TableCellEditor cellEditor = tableColumn.getCellEditor();
+ if (cellEditor instanceof NumberCellEditor) {
+ NumberCellEditor editor = (NumberCellEditor) cellEditor;
+ editor.getNumberEditor().getTextField().addKeyListener(keyAdapter);
+ }
+ }
+ }
+
+ protected void uninstallTableKeyListener() {
+
+
+ if (keyAdapter != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Desintall " + keyAdapter);
+ }
+
+ getTable().removeKeyListener(keyAdapter);
+
+ TableColumnModel columnModel = getTable().getColumnModel();
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ TableCellEditor cellEditor = tableColumn.getCellEditor();
+ if (cellEditor instanceof NumberCellEditor) {
+ NumberCellEditor editor = (NumberCellEditor) cellEditor;
+ editor.getNumberEditor().getTextField().removeKeyListener(keyAdapter);
+ }
+ }
+ keyAdapter = null;
+ }
+ }
+
+ protected final void saveSelectedRowIfNeeded() {
+
+ R row = rowMonitor.getBean();
+
+ if (row != null) {
+
+ saveSelectedRowIfRequired(rowMonitor, row);
+ }
+ }
+
}
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-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -44,12 +44,20 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableCellAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table) {
- return new MoveToNextEditableCellAction<M>(model, table);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table, boolean canCreateRow) {
+ return new MoveToNextEditableCellAction<M>(model, table, canCreateRow);
}
- protected MoveToNextEditableCellAction(M model, JTable 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) {
super(model, table);
+ this.canCreateRow = canCreateRow;
}
@Override
@@ -81,8 +89,14 @@
if (currentRow == rowCount) {
- // create a new row in model
- addNewRow();
+ if (canCreateRow) {
+ // create a new row in model
+ addNewRow();
+ } else {
+
+ // can not create new row, so do nothing
+ break;
+ }
}
}
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-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -44,12 +44,20 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableRowAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table) {
- return new MoveToNextEditableRowAction<M>(model, table);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table, boolean canCreateRow) {
+ return new MoveToNextEditableRowAction<M>(model, table, canCreateRow);
}
- protected MoveToNextEditableRowAction(M model, JTable 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) {
super(model, table);
+ this.canCreateRow = canCreateRow;
}
@Override
@@ -64,17 +72,23 @@
}
currentRow++;
+ boolean canSelect = true;
if (currentRow >= getRowCount()) {
if (log.isDebugEnabled()) {
log.debug("No next row");
}
+ if (canCreateRow) {
+ // create a new row in model
+ addNewRow();
+ } else {
+ canSelect = false;
+ }
+ }
- // create a new row in model
- addNewRow();
+ if (canSelect) {
+ doSelectCell(currentRow, currentColumn);
}
- doSelectCell(currentRow, currentColumn);
-
} else {
if (log.isDebugEnabled()) {
log.debug("Cell not editable at " +
1
0
30 Dec '12
Author: tchemit
Date: 2012-12-30 20:39:00 +0100 (Sun, 30 Dec 2012)
New Revision: 132
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/132
Log:
- use jaxx last features
- clean css
- improve table api
- improve edit protocol design (at last do not save not valid data :()
- try and stop to improve design of pmfm in fishing stuff (need to improve this point!)
- start of config
- improve start and run of application (sammoa was not a good example to follow...)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
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/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
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/config/TuttiConfig.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.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/cruise/EditCruiseUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
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.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
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/FishingOperationsUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.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/BenthosBatchUI.css
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/MacroWasteBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css
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/PlanktonBatchUI.css
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/SpeciesBatchUI.css
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/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/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/fishing/environment/EnvironmentTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
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/GearShootingTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/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/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css
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/ColumnIdentifier.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 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,7 +28,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.IdAware;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -48,7 +47,6 @@
import javax.swing.JList;
import javax.swing.ListCellRenderer;
-import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
@@ -58,8 +56,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -168,7 +164,7 @@
Preconditions.checkNotNull(comboBox, "No comboBox!");
- Class<E> beanType = (Class<E>) comboBox.getHandler().getTargetClass();
+ Class<E> beanType = comboBox.getBeanType();
Preconditions.checkNotNull(beanType, "No beanType on the combobox!");
@@ -195,8 +191,8 @@
* pour un service de persistance donné.
*
* @param list le component graphique à initialiser
- * @param data
- * @param selectedData
+ * @param data la liste des données à mettre dans la liste de gauche
+ * @param selectedData la liste des données à mettre dans la liste de droite
*/
protected <E extends IdAware> void initBeanList(
BeanDoubleList<E> list,
@@ -260,36 +256,6 @@
picker.getEditor().setEditable(false);
}
- protected <B extends IdAware> void updateIndices(JList jlist,
- List<B> list) {
-
- List<String> ids = TuttiEntities.toIds(list);
-
- List<Integer> indices = new ArrayList<Integer>();
-
- if (list != null && !list.isEmpty()) {
-
- ListModel model = jlist.getModel();
-
- for (int i = 0, max = model.getSize(); i < max; i++) {
- B s = (B) model.getElementAt(i);
- if (ids.contains(s.getId())) {
- indices.add(i);
- }
- }
- }
- int[] result = new int[indices.size()];
- int i = 0;
- for (Integer indice : indices) {
- result[i++] = indice;
- }
- indices.clear();
- if (log.isDebugEnabled()) {
- log.debug("Selected indices : " + Arrays.toString(result));
- }
- jlist.setSelectedIndices(result);
- }
-
protected <O> Decorator<O> getDecorator(Class<O> type, String name) {
DecoratorService decoratorService =
context.getService(DecoratorService.class);
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -23,103 +23,103 @@
*/
#mainFrame {
- title: "tutti.application.name";
- defaultCloseOperation: {JFrame.DO_NOTHING_ON_CLOSE};
+ title: "tutti.application.name";
+ defaultCloseOperation: {JFrame.DO_NOTHING_ON_CLOSE};
}
#menuFile {
- text: "tutti.menu.file";
- toolTipText: "tutti.menu.file.tip";
- mnemonic: F;
+ text: "tutti.menu.file";
+ toolTipText: "tutti.menu.file.tip";
+ mnemonic: F;
}
#menuFileConfiguration {
- text: "tutti.action.configuration";
- toolTipText: "tutti.action.configuration.tip";
- actionIcon: "config";
- mnemonic: C;
+ text: "tutti.action.configuration";
+ toolTipText: "tutti.action.configuration.tip";
+ actionIcon: config;
+ mnemonic: C;
}
#menuFileExit {
- text: "tutti.action.exit";
- toolTipText: "tutti.action.exit.tip";
- actionIcon: "exit";
+ text: "tutti.action.exit";
+ toolTipText: "tutti.action.exit.tip";
+ actionIcon: exit;
}
#menuActions {
- text: "tutti.menu.actions";
- toolTipText: "tutti.menu.actions.tip";
- mnemonic: A;
+ text: "tutti.menu.actions";
+ toolTipText: "tutti.menu.actions.tip";
+ mnemonic: A;
}
#menuActionManageProtocol {
- text: "tutti.action.manageProtocol";
- toolTipText: "tutti.action.manageProtocol.tip";
- mnemonic: P;
- enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
- /*actionIcon: "protocol";*/
+ text: "tutti.action.manageProtocol";
+ toolTipText: "tutti.action.manageProtocol.tip";
+ mnemonic: P;
+ enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
+ /*actionIcon: "protocol";*/
}
#menuActionSelectCampaign {
- text: "tutti.action.selectCampaign";
- toolTipText: "tutti.action.selectCampaign.tip";
- mnemonic: S;
- enabled: {model.getScreen() != TuttiScreen.SELECT_CRUISE};
- /*actionIcon: "cruise";*/
+ text: "tutti.action.selectCampaign";
+ toolTipText: "tutti.action.selectCampaign.tip";
+ mnemonic: S;
+ enabled: {model.getScreen() != TuttiScreen.SELECT_CRUISE};
+ /*actionIcon: "cruise";*/
}
#menuActionFillCatches {
- text: "tutti.action.fillCatches";
- toolTipText: "tutti.action.fillCatches.tip";
- mnemonic: C;
- enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()};
- /*actionIcon: "catches";*/
+ text: "tutti.action.fillCatches";
+ toolTipText: "tutti.action.fillCatches.tip";
+ mnemonic: C;
+ enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()};
+ /*actionIcon: "catches";*/
}
#menuSynchronisations {
- text: "tutti.menu.synchronisations";
- toolTipText: "tutti.menu.synchronisations.tip";
- mnemonic: S;
+ text: "tutti.menu.synchronisations";
+ toolTipText: "tutti.menu.synchronisations.tip";
+ mnemonic: S;
}
#menuSynchronisationImport {
- text: "tutti.menu.synchronisationImport";
- toolTipText: "tutti.menu.synchronisationImport.tip";
- mnemonic: I;
- enabled: false;
+ text: "tutti.menu.synchronisationImport";
+ toolTipText: "tutti.menu.synchronisationImport.tip";
+ mnemonic: I;
+ enabled: false;
}
#menuSynchronisationExport {
- text: "tutti.menu.synchronisationExport";
- toolTipText: "tutti.menu.synchronisationExport.tip";
- mnemonic: E;
- enabled: false;
+ text: "tutti.menu.synchronisationExport";
+ toolTipText: "tutti.menu.synchronisationExport.tip";
+ mnemonic: E;
+ enabled: false;
}
#menuSynchronisationAllegro {
- text: "tutti.menu.synchronisationAllegro";
- toolTipText: "tutti.menu.synchronisationAllegro.tip";
- mnemonic: A;
- enabled: false;
+ text: "tutti.menu.synchronisationAllegro";
+ toolTipText: "tutti.menu.synchronisationAllegro.tip";
+ mnemonic: A;
+ enabled: false;
}
#menuHelp {
- text: "tutti.menu.help";
- toolTipText: "tutti.menu.help.tip";
- mnemonic: E;
+ text: "tutti.menu.help";
+ toolTipText: "tutti.menu.help.tip";
+ mnemonic: E;
}
#menuHelpSite {
- text: "tutti.action.site";
- toolTipText: "tutti.action.site.tip";
- actionIcon: "site";
- mnemonic: S;
+ text: "tutti.action.site";
+ toolTipText: "tutti.action.site.tip";
+ actionIcon: site;
+ mnemonic: S;
}
#menuHelpAbout {
- text: "tutti.action.about";
- toolTipText: "tutti.action.about.tip";
- actionIcon: "about";
- mnemonic: A;
+ text: "tutti.action.about";
+ toolTipText: "tutti.action.about.tip";
+ actionIcon: about;
+ mnemonic: A;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -72,13 +72,13 @@
<JMenu id='menuSynchronisations'>
- <JMenuItem id='menuSynchronisationImport'
- onActionPerformed="getHandler().showImportScreen()"/>
- <JMenuItem id='menuSynchronisationExport'
- onActionPerformed="getHandler().showExportScreen()"/>
- <JMenuItem id='menuSynchronisationAllegro'
- onActionPerformed="getHandler().showAllegroScreen()"/>
- </JMenu>
+ <JMenuItem id='menuSynchronisationImport'
+ onActionPerformed="getHandler().showImportScreen()"/>
+ <JMenuItem id='menuSynchronisationExport'
+ onActionPerformed="getHandler().showExportScreen()"/>
+ <JMenuItem id='menuSynchronisationAllegro'
+ onActionPerformed="getHandler().showAllegroScreen()"/>
+ </JMenu>
<JMenu id='menuHelp'>
<JMenuItem id='menuHelpSite'
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,19 +28,16 @@
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
-import fr.ifremer.tutti.ui.swing.config.TuttiConfigOption;
+import fr.ifremer.tutti.ui.swing.config.TuttiConfigUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.editor.config.ConfigUIHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ApplicationConfig;
@@ -54,7 +51,6 @@
import java.util.Calendar;
import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -78,6 +74,10 @@
context.addMessageNotifier(this);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void beforeInitUI() {
context.addPropertyChangeListener(new PropertyChangeListener() {
@@ -129,7 +129,7 @@
@Override
public void onCloseUI() {
- closeCurrentBody();
+// closeCurrentBody();
context.close();
}
@@ -139,94 +139,43 @@
return ui.getModel();
}
- public void showConfig() {
- TuttiConfig config = context.getConfig();
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
- ConfigUIHelper helper = new ConfigUIHelper(config.getApplicationConfig());
+ public void closeTutti() {
+ RunTutti.closeTutti(ui, true);
+ }
- helper.registerCallBack(
- "ui", n_("tutti.action.reload.ui"),
- SwingUtil.createActionIcon("reload-ui"),
- new Runnable() {
+ public void reloadTutti() {
- @Override
- public void run() {
- reloadTutti();
- }
- }
- ).registerCallBack(
- "home", n_("tutti.action.reload.home"),
- SwingUtil.createActionIcon("config"),
- new Runnable() {
+ // Close the application
+ RunTutti.closeTutti(ui, false);
- @Override
- public void run() {
- if (TuttiScreen.SELECT_CRUISE == context.getScreen()) {
- // Reselect home cruise
-// SelectCampaignUI homeUI = (SelectCampaignUI) currentBody;
-// homeUI.getHandler().selectCampaign();
- }
- }
- }
- ).registerCallBack(
- "actions", n_("tutti.action.reload.actions"),
- SwingUtil.createActionIcon("config"),
- new Runnable() {
+ // Re-open the context
+// try {
+// context.open();
+// } catch (Exception ex) {
+// ErrorDialogUI.showError(ex);
+// }
- @Override
- public void run() {
+ RunTutti.startTutti(context);
+ }
- //TODO Reload actions shortcuts
- }
- }
- );
+ public void reloadApplication() {
+ //TODO
+ }
- // APPLICATION
+ public void reloadShortcuts() {
+ //TODO
+ }
- helper.addCategory(n_("tutti.config.category.applications"),
- n_("tutti.config.category.applications.description"))
- .addOption(TuttiServiceConfigOption.DATA_DIRECTORY)
- .setOptionCallBack("ui");
-// .addOption(TuttiConfigOption.AUTO_COMMIT_DELAY) // milliseconds
-// .setOptionCallBack("ui");
+ public void showConfig() {
- // SHORTCUT
-
-// helper.addCategory(n_("tutti.config.category.shortcuts"),
-// n_("tutti.config.category.shortcuts.description"), "actions")
-// .addOption(TuttiConfigOption.KEY_START)
-// .addOption(TuttiConfigOption.KEY_STOP)
-// .addOption(TuttiConfigOption.KEY_BEGIN)
-// .addOption(TuttiConfigOption.KEY_END)
-// .addOption(TuttiConfigOption.KEY_NEXT)
-// .addOption(TuttiConfigOption.KEY_ADD)
-// .addOption(TuttiConfigOption.KEY_LEFT_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_CENTER_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_RIGHT_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_CIRCLE_BACK)
-// .addOption(TuttiConfigOption.KEY_VALID_FLIGHT)
-// .addOption(TuttiConfigOption.KEY_VALID_TRANSECT)
-// .addOption(TuttiConfigOption.KEY_VALID_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_VALID_ROUTE);
-
- // OTHER
-
- helper.addCategory(n_("tutti.config.category.other"),
- n_("tutti.config.category.other.description"))
- .addOption(TuttiServiceConfigOption.SITE_URL)
- .addOption(TuttiConfigOption.UI_CONFIG_FILE)
- .setOptionCallBack("ui");
-
-
- helper.buildUI(ui, "tutti.config.category.applications");
-
- helper.displayUI(ui, false);
+ TuttiConfigUI configUI = new TuttiConfigUI(ui);
+ configUI.createUI();
}
- public void closeTutti() {
- closeTutti(true);
- }
-
public void showManageProtocol() {
context.setScreen(TuttiScreen.EDIT_PROTOCOL);
}
@@ -314,6 +263,10 @@
ui.getStatus().setStatus(message);
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
protected void setScreen(TuttiScreen screen) {
try {
@@ -321,70 +274,80 @@
// busy ui
TuttiUIUtil.updateBusyState(ui, true);
- // remove any screen
-// ui.setScreen(null);
+ // close current body (if any)
+ if (currentBody != null) {
+ TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
+ body.getHandler().onCloseUI();
- closeCurrentBody();
+ context.getSwingSession().save();
- String programId = context.getProgramId();
- String cruiseId = context.getCruiseId();
- String protocolId = context.getProtocolId();
+ ui.getBody().remove(currentBody);
- JComponent screenUI;
- String screenTitle;
+ currentBody = null;
+ }
- switch (screen) {
- default:
- case SELECT_CRUISE:
+ if (screen != null) {
- screenUI = new SelectCruiseUI(context);
- screenTitle = _("tutti.title.home");
- break;
+ String programId = context.getProgramId();
+ String cruiseId = context.getCruiseId();
+ String protocolId = context.getProtocolId();
- case EDIT_PROGRAM:
+ JComponent screenUI;
+ String screenTitle;
- if (programId == null) {
- screenTitle = _("tutti.title.create.program");
- } else {
- screenTitle = _("tutti.title.edit.program");
- }
+ switch (screen) {
+ default:
+ case SELECT_CRUISE:
- screenUI = new EditProgramUI(context);
- break;
+ screenUI = new SelectCruiseUI(context);
+ screenTitle = _("tutti.title.home");
+ break;
- case EDIT_CRUISE:
+ case EDIT_PROGRAM:
- if (cruiseId == null) {
- screenTitle = _("tutti.title.create.cruise");
- } else {
- screenTitle = _("tutti.title.edit.cruise");
- }
+ if (programId == null) {
+ screenTitle = _("tutti.title.create.program");
+ } else {
+ screenTitle = _("tutti.title.edit.program");
+ }
- screenUI = new EditCruiseUI(context);
- break;
+ screenUI = new EditProgramUI(context);
+ break;
- case EDIT_PROTOCOL:
+ case EDIT_CRUISE:
- if (protocolId == null) {
- screenTitle = _("tutti.title.create.protocol");
- } else {
- screenTitle = _("tutti.title.edit.protocol");
- }
+ if (cruiseId == null) {
+ screenTitle = _("tutti.title.create.cruise");
+ } else {
+ screenTitle = _("tutti.title.edit.cruise");
+ }
- screenUI = new EditProtocolUI(context);
- break;
+ screenUI = new EditCruiseUI(context);
+ break;
- case EDIT_FISHING_OPERATION:
+ case EDIT_PROTOCOL:
- screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle());
- screenUI = new FishingOperationsUI(context);
- break;
- }
+ if (protocolId == null) {
+ screenTitle = _("tutti.title.create.protocol");
+ } else {
+ screenTitle = _("tutti.title.edit.protocol");
+ }
- changeScreen(screenUI, screenTitle);
+ screenUI = new EditProtocolUI(context);
+ break;
- // set new screen only if everything is ok
-// ui.setScreen(screen);
+ case EDIT_FISHING_OPERATION:
+
+ screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle());
+ screenUI = new FishingOperationsUI(context);
+ break;
+ }
+
+ this.currentBody = screenUI;
+ context.getSwingSession().add(currentBody);
+ ui.getBody().setTitle(screenTitle);
+ ui.getBody().add(currentBody);
+ }
} catch (Exception e) {
ErrorDialogUI.showError(e);
@@ -398,56 +361,20 @@
}
}
- protected void reloadTutti() {
+// protected void closeTutti(boolean exit) {
+//
+// context.getSwingSession().save();
+//
+// ui.setVisible(false);
+// ui.dispose();
+//
+// onCloseUI();
+//
+// if (exit) {
+// System.exit(0);
+// }
+// }
- // Close the application
- closeTutti(false);
-
- // Re-open the context
- try {
- context.open();
- } catch (Exception ex) {
- ErrorDialogUI.showError(ex);
- }
-
- MainUI mainUI = new MainUI(context);
- mainUI.setVisible(true);
- }
-
- protected void closeCurrentBody() {
- if (currentBody != null) {
- TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
- body.getHandler().onCloseUI();
-
- context.getSwingSession().save();
-
- ui.getBody().remove(currentBody);
-
- currentBody = null;
- }
- }
-
- protected void changeScreen(JComponent newBody, String title) {
- currentBody = newBody;
- context.getSwingSession().add(currentBody);
- ui.getBody().setTitle(title);
- ui.getBody().add(currentBody);
- }
-
- protected void closeTutti(boolean exit) {
-
- context.getSwingSession().save();
-
- ui.setVisible(false);
- ui.dispose();
-
- onCloseUI();
-
- if (exit) {
- System.exit(0);
- }
- }
-
protected void changeTitle() {
String title = getSelectedCruiseTitle();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -67,8 +67,6 @@
}
}));
- context.open();
-
// Initialize i18n
I18n.init(new DefaultI18nInitializer("tutti-ui-swing"), Locale.UK);
@@ -86,9 +84,29 @@
new BorderUIResource.LineBorderUIResource(Color.BLACK));
UIManager.put("BlockingLayerUI.blockingColor", new Color(50, 50, 50));
+ startTutti(context);
+ }
+
+ public static void startTutti(TuttiUIContext context) {
+
+ context.open();
+
MainUI mainUI = new MainUI(context);
mainUI.setVisible(true);
+ }
+ public static void closeTutti(MainUI ui, boolean exit) {
+
+ ui.getHandler().getContext().getSwingSession().save();
+
+ ui.getHandler().onCloseUI();
+
+ ui.setVisible(false);
+ ui.dispose();
+
+ if (exit) {
+ System.exit(0);
+ }
}
}
\ No newline at end of file
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -348,6 +348,8 @@
cruiseId = null;
protocolId = null;
+ setScreen(null);
+
IOUtils.closeQuietly(serviceContext);
// remove listeners
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,6 +35,7 @@
import org.nuiton.util.Version;
import javax.swing.KeyStroke;
+import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -133,7 +134,18 @@
return applicationConfig.getOption(TuttiConfigOption.PROTOCOL_ID.getKey());
}
+ public Color getColorRowInvalid() {
+ return applicationConfig.getOptionAsColor(TuttiConfigOption.COLOR_ROW_INVALID.getKey());
+ }
+ public Color getColorRowReadOnly() {
+ return applicationConfig.getOptionAsColor(TuttiConfigOption.COLOR_ROW_READ_ONLY.getKey());
+ }
+
+ public KeyStroke getShortcutClosePopup() {
+ return applicationConfig.getOptionAsKeyStroke(TuttiConfigOption.SHORTCUT_CLOSE_POPUP.getKey());
+ }
+
public KeyStroke getShortCut(String actionName) {
KeyStroke result = applicationConfig.getOptionAsKeyStroke(
"tutti.ui." + actionName);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,6 +26,8 @@
import org.nuiton.util.ApplicationConfig;
+import javax.swing.KeyStroke;
+import java.awt.Color;
import java.io.File;
import static org.nuiton.i18n.I18n.n_;
@@ -38,40 +40,66 @@
*/
public enum TuttiConfigOption implements ApplicationConfig.OptionDef {
- UI_CONFIG_FILE("tutti.ui.config",
- n_("tutti.config.ui.config"),
- "${tutti.data.directory}/tuttiUI.xml",
- File.class
+ UI_CONFIG_FILE(
+ "tutti.ui.config",
+ n_("tutti.config.ui.config"),
+ "${tutti.data.directory}/tuttiUI.xml",
+ File.class
),
- PROGRAM_ID("tutti.programId",
- n_("tutti.config.programId"),
- null,
- String.class
+
+ PROGRAM_ID(
+ "tutti.programId",
+ n_("tutti.config.programId"),
+ null,
+ String.class
),
- CRUISE_ID("tutti.cruiseId",
- n_("tutti.config.cruiseId"),
- null,
- String.class
+
+ CRUISE_ID(
+ "tutti.cruiseId",
+ n_("tutti.config.cruiseId"),
+ null,
+ String.class
),
- PROTOCOL_ID("tutti.protocolId",
- n_("tutti.config.protocolId"),
- null,
- String.class
+
+ PROTOCOL_ID(
+ "tutti.protocolId",
+ n_("tutti.config.protocolId"),
+ null,
+ String.class
),
- // UI CONFIG (should be moved to ui module)
- AUTO_POPUP_NUMBER_EDITOR("tutti.ui.autoPopupNumberEditor",
- n_("tutti.config.ui.autoPopupNumberEditor"),
- String.valueOf(false),
- Boolean.class
+ AUTO_POPUP_NUMBER_EDITOR(
+ "tutti.ui.autoPopupNumberEditor",
+ n_("tutti.config.ui.autoPopupNumberEditor"),
+ String.valueOf(false),
+ Boolean.class
),
- SHOW_NUMBER_EDITOR_BUTTON("tutti.ui.showNumberEditorButton",
- n_("tutti.config.ui.showNumberEditorButton"),
- String.valueOf(true),
- Boolean.class
- );
+ SHOW_NUMBER_EDITOR_BUTTON(
+ "tutti.ui.showNumberEditorButton",
+ n_("tutti.config.ui.showNumberEditorButton"),
+ String.valueOf(true),
+ Boolean.class
+ ),
+ COLOR_ROW_READ_ONLY(
+ "tutti.ui.color.rowReadOnly",
+ n_("tutti.config.ui.color.rowReadOnly"),
+ new Color(192, 192, 192).toString(),
+ Color.class
+ ),
+ COLOR_ROW_INVALID(
+ "tutti.ui.color.rowInvalid",
+ n_("tutti.config.ui.color.rowInvalid"),
+ new Color(255, 128, 128).toString(),
+ Color.class),
+
+ SHORTCUT_CLOSE_POPUP(
+ "tutti.ui.shortcut.closePopup",
+ n_("tutti.config.ui.shortcut.closePopup"),
+ "alt pressed F",
+ KeyStroke.class);
+
/** Configuration key. */
private final String key;
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -0,0 +1,135 @@
+package fr.ifremer.tutti.ui.swing.config;
+
+/*
+ * #%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.service.config.TuttiServiceConfigOption;
+import fr.ifremer.tutti.ui.swing.MainUI;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.config.ConfigUIHelper;
+import jaxx.runtime.swing.editor.config.model.MainCallBackFinalizer;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * To launch the config UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class TuttiConfigUI {
+
+ public static final String CALLBACK_APPLICATION = "application";
+
+ public static final String CALLBACK_UI = "ui";
+
+ public static final String CALLBACK_SHORTCUT = "shortcut";
+
+ protected final MainUI mainUI;
+
+ public TuttiConfigUI(MainUI mainUI) {
+ this.mainUI = mainUI;
+ }
+
+ public void createUI() {
+
+ TuttiConfig config = mainUI.getHandler().getContext().getConfig();
+
+ ConfigUIHelper helper = new ConfigUIHelper(config.getApplicationConfig());
+
+ helper.registerCallBack(
+ CALLBACK_UI, n_("tutti.action.reload.ui"),
+ SwingUtil.createActionIcon("reload-ui"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+ reloadUI();
+ }
+ }
+ ).registerCallBack(
+ CALLBACK_APPLICATION, n_("tutti.action.reload.application"),
+ SwingUtil.createActionIcon("reload-application"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+ reloadApplication();
+ }
+ }
+ ).registerCallBack(
+ CALLBACK_SHORTCUT, n_("tutti.action.reload.actions"),
+ SwingUtil.createActionIcon("reload-shortcut"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+
+ reloadShortcuts();
+ }
+ }
+ );
+
+ // APPLICATION
+
+ helper.addCategory(n_("tutti.config.category.applications"),
+ n_("tutti.config.category.applications.description"),
+ CALLBACK_APPLICATION)
+ .addOption(TuttiServiceConfigOption.DATA_DIRECTORY)
+ .addOption(TuttiServiceConfigOption.SITE_URL)
+ .addOption(TuttiConfigOption.UI_CONFIG_FILE);
+
+ // COLOR
+ helper.addCategory(n_("tutti.config.category.colors"),
+ n_("tutti.config.category.colors.description"),
+ CALLBACK_UI)
+ .addOption(TuttiConfigOption.COLOR_ROW_INVALID)
+ .addOption(TuttiConfigOption.COLOR_ROW_READ_ONLY);
+
+ // SHORTCUT
+
+ helper.addCategory(n_("tutti.config.category.shortcuts"),
+ n_("tutti.config.category.shortcuts.description"),
+ CALLBACK_SHORTCUT)
+ .addOption(TuttiConfigOption.SHORTCUT_CLOSE_POPUP);
+
+ helper.setFinalizer(new MainCallBackFinalizer(CALLBACK_APPLICATION));
+
+ helper.buildUI(mainUI, "tutti.config.category.applications");
+
+ helper.displayUI(mainUI, false);
+ }
+
+ protected void reloadApplication() {
+ mainUI.getHandler().reloadApplication();
+ }
+
+ protected void reloadUI() {
+ mainUI.getHandler().reloadTutti();
+ }
+
+ protected void reloadShortcuts() {
+ mainUI.getHandler().reloadShortcuts();
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -65,7 +65,7 @@
}
#yearField {
- property: "year";
+ property: year;
model: {model.getYear()};
useFloat: false;
numberPattern: {INT_4_DIGITS_PATTERN};
@@ -86,7 +86,7 @@
}
#countryComboBox {
- property: "country";
+ property: country;
selectedItem: {model.getCountry()};
}
@@ -96,7 +96,7 @@
}
#surveyComboBox {
- property: "program";
+ property: program;
selectedItem: {model.getProgram()};
}
@@ -126,33 +126,29 @@
}
#pocheField {
- property: "poche";
+ property: poche;
model: {model.getPoche()};
useFloat: false;
numberPattern: {INT_1_DIGITS_PATTERN};
}
#vesselList {
- beanType: {Vessel.class};
- property: "vessel";
+ property: vessel;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.vessel"))};
}
#gearList {
- beanType: {Gear.class};
- property: "gear";
+ property: gear;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.gear"))};
}
#headOfMissionList {
- beanType: {Person.class};
property: "headOfMission";
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfMission"))};
}
#headOfSortRoomList {
- beanType: {Person.class};
- property: "headOfSortRoom";
+ property: headOfSortRoom;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfSortRoom"))};
}
@@ -166,18 +162,18 @@
}
#saveButton {
- actionIcon: "save";
+ actionIcon: save;
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
}
#cancelButton {
- actionIcon: "cancel";
+ actionIcon: cancel;
text: "tutti.action.cancel";
}
#generateNameButton {
- actionIcon: "generate";
+ actionIcon: generate;
text: "tutti.action.generateCampaignName";
enabled: {model.isCanGenerateName()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -65,10 +65,10 @@
]]></script>
<EditCruiseUIHandler id='handler'
- initializer='getContextValue(EditCruiseUIHandler.class)'/>
+ initializer='getContextValue(EditCruiseUIHandler.class)'/>
<EditCruiseUIModel id='model'
- initializer='getContextValue(EditCruiseUIModel.class)'/>
+ initializer='getContextValue(EditCruiseUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
@@ -189,7 +189,7 @@
onFocusGained='commentField.requestFocus()'>
<JTextArea id='commentField'
onKeyReleased='handler.setText(event, "comment")'/>
- </JScrollPane>
+ </JScrollPane>
</cell>
</row>
@@ -206,7 +206,7 @@
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,8 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.referential.Country;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,19 +33,20 @@
}
#programCombobox {
- property: "program";
+ property: program;
+ beanType: {Program.class};
selectedItem: {model.getProgram()};
}
#editProgramButton {
enabled: {model.isProgramFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newProgramButton {
text: "tutti.action.new";
- actionIcon: "add";
+ actionIcon: add;
}
#cruiseLabel {
@@ -54,7 +55,7 @@
}
#cruiseCombobox {
- property: "cruise";
+ property: cruise;
enabled: {model.isProgramFound()};
selectedItem: {model.getCruise()};
}
@@ -62,11 +63,11 @@
#editCruiseButton {
enabled: {model.isProgramFound() && model.isCruiseFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newCruiseButton {
- actionIcon: "add";
+ actionIcon: add;
enabled: {model.isProgramFound()};
text: "tutti.action.new";
}
@@ -77,18 +78,18 @@
}
#protocolCombobox {
- property: "protocol";
+ property: protocol;
selectedItem: {model.getProtocol()};
}
#editProtocolButton {
enabled: {model.isProtocolFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newProtocolButton {
- actionIcon: "add";
+ actionIcon: add;
enabled: true;
text: "tutti.action.new";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -53,10 +53,10 @@
]]></script>
<SelectCruiseUIHandler id='handler'
- initializer='getContextValue(SelectCruiseUIHandler.class)'/>
+ initializer='getContextValue(SelectCruiseUIHandler.class)'/>
<SelectCruiseUIModel id='model'
- initializer='getContextValue(SelectCruiseUIModel.class)'/>
+ initializer='getContextValue(SelectCruiseUIModel.class)'/>
<Table fill='both' constraints='BorderLayout.CENTER'>
<row>
@@ -64,8 +64,8 @@
<JLabel id='programLabel'/>
</cell>
<cell weightx='1.0'>
- <BeanComboBox id='programCombobox' constructorParams='this'
- genericType='Program'/>
+ <BeanComboBox id='programCombobox' constructorParams='this'
+ genericType='Program'/>
</cell>
<cell>
<JPanel layout='{new GridLayout(1,0)}'>
@@ -81,8 +81,8 @@
<JLabel id='cruiseLabel'/>
</cell>
<cell>
- <BeanComboBox id='cruiseCombobox' constructorParams='this'
- genericType='Cruise'/>
+ <BeanComboBox id='cruiseCombobox' constructorParams='this'
+ genericType='Cruise'/>
</cell>
<cell>
<JPanel layout='{new GridLayout(1,0)}'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -142,6 +142,30 @@
model.getPrograms(),
model.getProgram());
+// ui.getProgramCombobox().setAutoComplete(false);
+// ui.getProgramCombobox().setEditable(true);
+//
+// JComboBox combobox = ui.getProgramCombobox().getCombobox();
+// ComboBoxSearchable comboBoxSearchable = new ComboBoxSearchable(combobox) {
+//
+// final Decorator<Program> decorator = getDecorator(Program.class, null);
+//
+// @Override
+// protected String convertElementToString(Object object) {
+// return decorator.toString(object);
+// }
+// };
+//
+// comboBoxSearchable.setRefreshPopupDuringSearching(true);
+// comboBoxSearchable.setShowPopupDuringSearching(true);
+// comboBoxSearchable.setFromStart(false);
+// comboBoxSearchable.setHideSearchPopupOnEvent(false);
+// comboBoxSearchable.setHeavyweightComponentEnabled(true);
+// comboBoxSearchable.setForeground(Color.GREEN);
+//
+// AutoCompletion i= new AutoCompletion(combobox, comboBoxSearchable);
+
+
initBeanComboBox(ui.getCruiseCombobox(),
model.getCruises(),
model.getCruise());
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,23 +33,16 @@
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.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.sort.TableSortController;
-import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
-import java.awt.Color;
import java.awt.Component;
import java.awt.event.FocusEvent;
import java.util.Collection;
@@ -66,25 +59,11 @@
private static final Log log =
LogFactory.getLog(AbstractTuttiBatchTableUIHandler.class);
- protected abstract void saveSelectedRowIfRequired();
-
- protected abstract void saveRow(R row);
-
- protected abstract FishingOperation getFishingOperation();
-
public abstract void selectFishingOperation(FishingOperation bean);
- /**
- * Persistence service.
- *
- * @since 0.2
- */
- protected final PersistenceService persistenceService;
-
protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi,
String... properties) {
super(parentUi.getHandler().getContext(), properties);
- this.persistenceService = context.getService(PersistenceService.class);
}
public final void saveSelectedRowIfRequired(FocusEvent event) {
@@ -103,8 +82,9 @@
if (parentContainer == null) {
// out of the table can save
- if (getFishingOperation() != null) {
- saveSelectedRowIfRequired();
+ if (getModel().getFishingOperation() != null) {
+
+ saveSelectedRowIfNeeded();
}
}
}
@@ -135,7 +115,6 @@
AbstractTuttiTableModel<R> tableModel) {
installTableKeyListener(columnModel, table);
- table.getTableHeader().setReorderingAllowed(false);
JTableFilter tableFilter = new JTableFilter(table);
TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply();
@@ -161,44 +140,8 @@
TableSortController<TableModel> sorter = new TableSortController<TableModel>(tableModel);
sorter.setSortable(false);
-
table.setRowSorter(sorter);
- Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
-
- table.addHighlighter(readOnlyHighlighter);
- Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
-
- boolean result = false;
- if (adapter.isEditable()) {
- int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- R row = getTableModel().getEntry(rowIndex);
- result = !row.isValid();
- }
- return result;
- }
- }), Color.RED);
- table.addHighlighter(validHighlighter);
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- // save when row chaged and was modified
- ListSelectionListener listener = new TableRowModificationListener<R>(
- tableModel, getRowMonitor()) {
- @Override
- protected void saveSelectedRow() {
- saveSelectedRowIfRequired();
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(table);
+ initTable(table);
}
-
}
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -67,7 +67,7 @@
}
#fishingOperationNumberField {
- property: "fishingOperationNumber";
+ property: fishingOperationNumber;
model: {model.getFishingOperationNumber()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -89,7 +89,7 @@
}
#strataComboBox {
- property: "strata";
+ property: strata;
selectedItem: {model.getStrata()};
}
@@ -99,7 +99,7 @@
}
#subStrataComboBox {
- property: "subStrata";
+ property: subStrata;
selectedItem: {model.getSubStrata()};
}
@@ -109,7 +109,7 @@
}
#locationComboBox {
- property: "location";
+ property: location;
selectedItem: {model.getLocation()};
}
@@ -151,7 +151,7 @@
}
#gearShootingStartTimeField {
- property: "gearShootingStartDate";
+ property: gearShootingStartDate;
date: {model.getGearShootingStartDate()};
}
@@ -169,7 +169,7 @@
}
#gearShootingEndTimeField {
- property: "gearShootingEndDate";
+ property: gearShootingEndDate;
date: {model.getGearShootingEndDate()};
}
@@ -180,7 +180,7 @@
}
#resetValidStateButton {
- actionIcon: "reset";
+ actionIcon: reset;
text: "tutti.action.reset.fishingOperationValidState";
}
@@ -211,7 +211,7 @@
}
#distanceChaluteeField {
- property: "distanceChalutee";
+ property: distanceChalutee;
model: {model.getDistanceChalutee()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -229,8 +229,7 @@
}
#saisisseurList {
- beanType: {Person.class};
- property: "saisisseur";
+ property: saisisseur;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.saisisseur"))};
}
@@ -253,19 +252,18 @@
}
#saveButton {
- actionIcon: "save";
+ actionIcon: save;
text: "tutti.action.save";
enabled: {model.isValid()};
}
#cancelButton {
- actionIcon: "cancel";
+ actionIcon: cancel;
text: "tutti.action.cancel";
- /*enabled: {model.isModify()};*/
}
#importCasinoButton {
- actionIcon: "casino-import";
+ actionIcon: casino-import;
text: "tutti.action.casino-import";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -30,11 +30,11 @@
#newFishingOperationButton {
text: "tutti.action.new";
- actionIcon: "add";
+ actionIcon: add;
}
#fishingOperationComboBox {
- property: "selectedFishingOperation";
+ property: selectedFishingOperation;
selectedItem: {model.getSelectedFishingOperation()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -70,7 +70,8 @@
<JTabbedPane id='tabPane' constraints='BorderLayout.CENTER'>
<tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'>
- <EditFishingOperationUI id='fishingOperationTabContent' constructorParams='this'/>
+ <EditFishingOperationUI id='fishingOperationTabContent'
+ constructorParams='this'/>
</tab>
<tab id='catchesTab' title='tutti.label.tab.catches'>
<EditCatchesUI id='catchesTabContent' constructorParams='this'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -31,15 +31,17 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import java.util.List;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
import static org.nuiton.i18n.I18n._;
-import org.nuiton.util.decorator.Decorator;
/**
* Handler of UI {@link FishingOperationsUI}.
@@ -198,7 +200,7 @@
}
public void saveFishingOperation(FishingOperation toSave) {
-
+
// persist the fishingOperation
boolean create = toSave.getId() == null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,11 +26,12 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
+import java.util.List;
+
/**
* Model fo UI {@link FishingOperationsUI}.
*
@@ -40,7 +41,7 @@
public class FishingOperationsUIModel extends AbstractSerializableBean {
private static final Log log = LogFactory.getLog(FishingOperationsUIModel.class);
-
+
private static final long serialVersionUID = 1L;
public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -39,7 +39,7 @@
}
#catchTotalWeightField {
- property: "catchTotalWeight";
+ property: catchTotalWeight;
model: {model.getCatchTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -51,7 +51,7 @@
}
#catchTotalSortedTremisWeightField {
- property: "catchTotalSortedTremisWeight";
+ property: catchTotalSortedTremisWeight;
model: {model.getCatchTotalSortedTremisWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -63,7 +63,7 @@
}
#catchTotalSortedCarousselWeightField {
- property: "catchTotalSortedCarousselWeight";
+ property: catchTotalSortedCarousselWeight;
model: {model.getCatchTotalSortedCarousselWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -75,7 +75,7 @@
}
#catchTotalRejectedWeightField {
- property: "catchTotalRejectedWeight";
+ property: catchTotalRejectedWeight;
model: {model.getCatchTotalRejectedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -101,7 +101,7 @@
}
#speciesTotalWeightField {
- property: "speciesTotalWeight";
+ property: speciesTotalWeight;
model: {model.getSpeciesTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -113,7 +113,7 @@
}
#speciesTotalSortedWeightField {
- property: "speciesTotalSortedWeight";
+ property: speciesTotalSortedWeight;
model: {model.getSpeciesTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -125,7 +125,7 @@
}
#speciesTotalSampleSortedWeightField {
- property: "speciesTotalSampleSortedWeight";
+ property: speciesTotalSampleSortedWeight;
model: {model.getSpeciesTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -151,7 +151,7 @@
}
#benthosTotalWeightField {
- property: "benthosTotalWeight";
+ property: benthosTotalWeight;
model: {model.getBenthosTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -163,7 +163,7 @@
}
#benthosTotalSortedWeightField {
- property: "benthosTotalSortedWeight";
+ property: benthosTotalSortedWeight;
model: {model.getBenthosTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -175,7 +175,7 @@
}
#benthosTotalSampleSortedWeightField {
- property: "benthosTotalSampleSortedWeight";
+ property: benthosTotalSampleSortedWeight;
model: {model.getBenthosTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -201,19 +201,17 @@
}
#macroWasteTotalWeightField {
- property: "macroWasteTotalWeight";
+ property: macroWasteTotalWeight;
model: {model.getMacroWasteTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
}
#importPupitriButton {
- actionIcon: "pupitri-import";
+ actionIcon: pupitri-import;
text: "tutti.action.pupitri-import";
}
#observationIndividuelTab {
enabled: {false};
}
-
-//#catchesCaracteristicsTabScrollPane { }
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -79,6 +79,10 @@
EditCatchesUIModel.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void beforeInitUI() {
@@ -110,6 +114,10 @@
return ui.getModel();
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
public void selectFishingOperation(FishingOperation bean,
String fishingOperationText) {
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,169 +74,92 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected AccidentalBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected AccidentalBatchTableModel getTableModel() {
- return (AccidentalBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ AccidentalBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<AccidentalBatchRowModel> rows;
+ if (empty) {
+ rows = null;
+ } else {
- @Override
- protected void onRowModified(AccidentalBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("Get accidental batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean wasValid = row.isValid();
-
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<AccidentalBatch> catches =
+ persistenceService.getAllAccidentalBatch(bean.getId());
+ for (AccidentalBatch aBatch : catches) {
+ AccidentalBatchRowModel entry =
+ new AccidentalBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(AccidentalBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(AccidentalBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected AccidentalBatchTableModel getTableModel() {
+ return (AccidentalBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<AccidentalBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (AccidentalBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor = getRowMonitor();
-
- AccidentalBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.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 " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- AccidentalBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteAccidentalBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(AccidentalBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(AccidentalBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor,
+ AccidentalBatchRowModel row) {
- AccidentalBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createAccidentalBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.saveAccidentalBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ AccidentalBatch catchBean = row.toBean();
- AccidentalBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<AccidentalBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get accidental batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deleteAccidentalBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<AccidentalBatch> catches =
- persistenceService.getAllAccidentalBatch(bean.getId());
- for (AccidentalBatch aBatch : catches) {
- AccidentalBatchRowModel entry =
- new AccidentalBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
-
}
- model.setRows(rows);
}
//------------------------------------------------------------------------//
@@ -244,6 +167,11 @@
//------------------------------------------------------------------------//
@Override
+ protected AccidentalBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -347,4 +275,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(AccidentalBatchRowModel row) {
+
+ AccidentalBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createAccidentalBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveAccidentalBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import javax.swing.table.TableColumnModel;
-import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#benthosTotalWeightField {
- property: "benthosTotalWeight";
+ property: benthosTotalWeight;
model: {model.getBenthosTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#benthosTotalSortedWeightField {
- property: "benthosTotalSortedWeight";
+ property: benthosTotalSortedWeight;
model: {model.getBenthosTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -59,7 +59,7 @@
}
#benthosTotalSampleSortedWeightField {
- property: "benthosTotalSampleSortedWeight";
+ property: benthosTotalSampleSortedWeight;
model: {model.getBenthosTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,180 +74,107 @@
BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
BenthosBatchRowModel.PROPERTY_COMMENT);
this.ui = ui;
-
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected BenthosBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected BenthosBatchTableModel getTableModel() {
- return (BenthosBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ BenthosBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<BenthosBatchRowModel> rows;
- @Override
- protected void onRowModified(BenthosBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
+ if (log.isInfoEnabled()) {
+ log.info("Get benthos batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<BenthosBatch> catches =
+ persistenceService.getAllBenthosBatch(bean.getId());
+ for (BenthosBatch aBatch : catches) {
+ BenthosBatchRowModel entry =
+ new BenthosBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected BenthosBatchTableModel getTableModel() {
+ return (BenthosBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<BenthosBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (BenthosBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor = getRowMonitor();
-
- BenthosBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.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 " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- BenthosBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteBenthosBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(BenthosBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(BenthosBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor,
+ BenthosBatchRowModel row) {
- BenthosBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createBenthosBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.saveBenthosBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ BenthosBatch catchBean = row.toBean();
- BenthosBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<BenthosBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get benthos batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deleteBenthosBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<BenthosBatch> catches =
- persistenceService.getAllBenthosBatch(bean.getId());
- for (BenthosBatch aBatch : catches) {
- BenthosBatchRowModel entry =
- new BenthosBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
}
-
- model.setRows(rows);
}
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected BenthosBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -259,8 +186,6 @@
BenthosBatchUIModel model = new BenthosBatchUIModel(catchesUIModel);
ui.setContextValue(model);
-
-// fishingOperationMonitor.setBean(model);
}
@Override
@@ -375,4 +300,23 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(BenthosBatchRowModel row) {
+
+ BenthosBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createBenthosBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveBenthosBatch(catchBean);
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -49,7 +49,7 @@
public static final String PROPERTY_WEIGHT = "weight";
- public static final String PROPERTY_NUMBER= "number";
+ public static final String PROPERTY_NUMBER = "number";
public static final String PROPERTY_COMMENT = "comment";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#macroWasteTotalWeightField {
- property: "macroWasteTotalWeight";
+ property: macroWasteTotalWeight;
model: {model.getMacroWasteTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,92 +74,80 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected MacroWasteBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected MacroWasteBatchTableModel getTableModel() {
- return (MacroWasteBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ MacroWasteBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<MacroWasteBatchRowModel> rows;
- @Override
- protected void onRowModified(MacroWasteBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
+ if (log.isInfoEnabled()) {
+ log.info("Get macroWaste batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<MacroWasteBatch> catches =
+ persistenceService.getAllMacroWasteBatch(bean.getId());
+ for (MacroWasteBatch aBatch : catches) {
+ MacroWasteBatchRowModel entry =
+ new MacroWasteBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(MacroWasteBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
+ @Override
+ protected MacroWasteBatchTableModel getTableModel() {
+ return (MacroWasteBatchTableModel) getTable().getModel();
}
@Override
- protected void onRowModifyStateChanged(MacroWasteBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void onModelRowsChanged(List<MacroWasteBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (MacroWasteBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected boolean isRowValid(MacroWasteBatchRowModel row) {
+ boolean result = row.getMacroWasteCategory() != null &&
+ row.getMacroWasteSizeCategory() != null &&
+ row.getWeight() != null;
+ return result;
}
@Override
- protected void saveSelectedRowIfRequired() {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor,
+ MacroWasteBatchRowModel row) {
- TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor = getRowMonitor();
+ if (row != null) {
- MacroWasteBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
+ 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 " + bean + " was modified, will save it");
+ log.info("Row " + row + " was modified, will save it");
}
- saveRow(bean);
+ saveRow(row);
// clear modified flag on the monitor
rowMonitor.clearModified();
@@ -168,7 +156,7 @@
// row is not valid can not save it
- MacroWasteBatch catchBean = bean.toBean();
+ MacroWasteBatch catchBean = row.toBean();
if (!TuttiEntities.isNew(catchBean)) {
@@ -179,72 +167,16 @@
}
}
- @Override
- protected boolean isRowValid(MacroWasteBatchRowModel row) {
- boolean result = row.getMacroWasteCategory() != null &&
- row.getMacroWasteSizeCategory() != null &&
- row.getWeight() != null;
- return result;
- }
-
- @Override
- protected void saveRow(MacroWasteBatchRowModel row) {
-
- MacroWasteBatch catchBean = row.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
-
- if (TuttiEntities.isNew(catchBean)) {
-
- catchBean = persistenceService.createMacroWasteBatch(catchBean);
- row.setId(catchBean.getId());
- } else {
- persistenceService.saveMacroWasteBatch(catchBean);
- }
- }
-
- @Override
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- MacroWasteBatchUIModel model = getModel();
-
- List<MacroWasteBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get macroWaste batch for fishingOperation: " +
- bean.getId());
- }
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<MacroWasteBatch> catches =
- persistenceService.getAllMacroWasteBatch(bean.getId());
- for (MacroWasteBatch aBatch : catches) {
- MacroWasteBatchRowModel entry =
- new MacroWasteBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
- }
-
- model.setRows(rows);
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected MacroWasteBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -352,4 +284,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(MacroWasteBatchRowModel row) {
+
+ MacroWasteBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createMacroWasteBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveMacroWasteBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#planktonTotalWeightField {
- property: "planktonTotalWeight";
+ property: planktonTotalWeight;
model: {model.getPlanktonTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#planktonTotalSampleWeightField {
- property: "planktonTotalSampleWeight";
+ property: planktonTotalSampleWeight;
model: {model.getPlanktonTotalSampleWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,169 +74,93 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected PlanktonBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected PlanktonBatchTableModel getTableModel() {
- return (PlanktonBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ PlanktonBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<PlanktonBatchRowModel> rows;
- @Override
- protected void onRowModified(PlanktonBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
- boolean valid = isRowValid(row);
+ if (log.isInfoEnabled()) {
+ log.info("Get plankton batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<PlanktonBatch> catches =
+ persistenceService.getAllPlanktonBatch(bean.getId());
+ for (PlanktonBatch aBatch : catches) {
+ PlanktonBatchRowModel entry =
+ new PlanktonBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(PlanktonBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(PlanktonBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected PlanktonBatchTableModel getTableModel() {
+ return (PlanktonBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<PlanktonBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (PlanktonBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor = getRowMonitor();
-
- PlanktonBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.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 " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- PlanktonBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deletePlanktonBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(PlanktonBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(PlanktonBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor,
+ PlanktonBatchRowModel row) {
- PlanktonBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createPlanktonBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.savePlanktonBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ PlanktonBatch catchBean = row.toBean();
- PlanktonBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<PlanktonBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
-
- if (log.isInfoEnabled()) {
- log.info("Get plankton batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deletePlanktonBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<PlanktonBatch> catches =
- persistenceService.getAllPlanktonBatch(bean.getId());
- for (PlanktonBatch aBatch : catches) {
- PlanktonBatchRowModel entry =
- new PlanktonBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
}
-
- model.setRows(rows);
}
//------------------------------------------------------------------------//
@@ -244,6 +168,11 @@
//------------------------------------------------------------------------//
@Override
+ protected PlanktonBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -358,4 +287,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(PlanktonBatchRowModel row) {
+
+ PlanktonBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createPlanktonBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.savePlanktonBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#speciesTotalWeightField {
- property: "speciesTotalWeight";
+ property: speciesTotalWeight;
model: {model.getSpeciesTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#speciesTotalSortedWeightField {
- property: "speciesTotalSortedWeight";
+ property: speciesTotalSortedWeight;
model: {model.getSpeciesTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -59,7 +59,7 @@
}
#speciesTotalSampleSortedWeightField {
- property: "speciesTotalSampleSortedWeight";
+ property: speciesTotalSampleSortedWeight;
model: {model.getSpeciesTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -113,14 +113,47 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected SpeciesBatchUIModel getModel() {
- return ui.getModel();
+ public void selectFishingOperation(FishingOperation bean) {
+
+ boolean empty = bean == null;
+
+ SpeciesBatchUIModel model = getModel();
+
+ List<SpeciesBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<SpeciesBatch> catches =
+ persistenceService.getAllSpeciesBatch(bean.getId());
+ for (SpeciesBatch aBatch : catches) {
+ List<SpeciesBatchFrequency> frequencies =
+ persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
+ SpeciesBatchRowModel entry =
+ new SpeciesBatchRowModel(aBatch, frequencies);
+ rows.add(entry);
+ }
+ }
+ }
+ model.setRows(rows);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
protected SpeciesBatchTableModel getTableModel() {
return (SpeciesBatchTableModel) getTable().getModel();
@@ -132,32 +165,79 @@
}
@Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
+ protected boolean isRowValid(SpeciesBatchRowModel row) {
+ boolean result = row.getSpecies() != null;
+ if (result) {
+ result = row.getWeight() != null;
+
+ if (!result) {
+
+ // No weight filled, so at least one sample category must be valid
+ result = row.getSortedUnsortedSampleCategory().isValid() ||
+ row.getSizeSampleCategory().isValid() ||
+ row.getSexSampleCategory().isValid() ||
+ row.getMaturitySampleCategory().isValid() ||
+ row.getAgeSampleCategory().isValid();
+ }
+ }
+ return result;
}
@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);
- // compute row valid
- for (SpeciesBatchRowModel row : rows) {
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
- }
// build the new sampling tree from the new rows to edit
// getModel().getSamplingTreeModel().populate(rows);
}
@Override
- protected void onRowModified(SpeciesBatchRowModel row,
+ protected void onRowModified(int rowIndex,
+ SpeciesBatchRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- if (log.isInfoEnabled()) {
- log.info("Property " + propertyName + " has changed on row.");
- }
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+
if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
// Need to recompute totalHorsVracWeight
@@ -254,163 +334,19 @@
// }
}
- @Override
- protected void onRowValidStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
-
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor();
-
- SpeciesBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.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 " + bean + " was modified, will save it");
- }
-
- showInformationMessage(
- "[ Captures - Espèces ] " +
- "Sauvegarde des modifications de " + bean +
- ".");
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- SpeciesBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteSpeciesBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
- protected boolean isRowValid(SpeciesBatchRowModel row) {
- boolean result = row.getSpecies() != null;
- if (result) {
- result = row.getWeight() != null;
-
- if (!result) {
-
- // No weight filled, so at least one sample category must be valid
- result = row.getSortedUnsortedSampleCategory().isValid() ||
- row.getSizeSampleCategory().isValid() ||
- row.getSexSampleCategory().isValid() ||
- row.getMaturitySampleCategory().isValid() ||
- row.getAgeSampleCategory().isValid();
- }
- }
- return result;
- }
-
- @Override
- protected void saveRow(SpeciesBatchRowModel row) {
-
- SpeciesBatch catchBean = row.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(fishingOperation);
-
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
-
- if (TuttiEntities.isNew(catchBean)) {
-
- catchBean = persistenceService.createSpeciesBatch(catchBean);
- row.setId(catchBean.getId());
- } else {
- persistenceService.saveSpeciesBatch(catchBean);
- }
-
- List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<SpeciesBatchFrequency> frequency =
- SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveSpeciesBatchFrequency(
- catchBean.getId(), frequency);
-
- // push it back to row model
- frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
- row.setFrequency(frequencyRows);
- }
-
- @Override
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- SpeciesBatchUIModel model = getModel();
-
- List<SpeciesBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get species batch for fishingOperation: " +
- bean.getId());
- }
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<SpeciesBatch> catches =
- persistenceService.getAllSpeciesBatch(bean.getId());
- for (SpeciesBatch aBatch : catches) {
- List<SpeciesBatchFrequency> frequencies =
- persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
- SpeciesBatchRowModel entry =
- new SpeciesBatchRowModel(aBatch, frequencies);
- rows.add(entry);
- }
- }
- }
- model.setRows(rows);
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
- public static final String SPECIES_FREQUENCY_LENGHTS = "SPECIES_FREQUENCY_LENGHTS";
+ public static final String SPECIES_FREQUENCY_LENGHTS =
+ "SPECIES_FREQUENCY_LENGHTS";
@Override
+ protected SpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -597,6 +533,42 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(SpeciesBatchRowModel row) {
+
+ SpeciesBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(fishingOperation);
+
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createSpeciesBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveSpeciesBatch(catchBean);
+ }
+
+ List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<SpeciesBatchFrequency> frequency =
+ SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveSpeciesBatchFrequency(
+ catchBean.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
+ row.setFrequency(frequencyRows);
+ }
+
// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
// SpeciesBatchTreeNode node) {
//
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -39,7 +39,7 @@
}
#stepField {
- property: "step";
+ property: step;
model: {model.getStep()};
useFloat: true;
numberPattern: {DECIMAL1_PATTERN};
@@ -52,7 +52,7 @@
}
#lenghtStepCaracteristicComboBox {
- property: "lengthStepCaracteristic";
+ property: lengthStepCaracteristic;
selectedItem: {model.getLengthStepCaracteristic()};
}
@@ -62,7 +62,7 @@
}
#minStepField {
- property: "minStep";
+ property: minStep;
model: {model.getMinStep()};
useFloat: true;
showReset: true;
@@ -76,7 +76,7 @@
}
#maxStepField {
- property: "maxStep";
+ property: maxStep;
model: {model.getMaxStep()};
useFloat: true;
showReset: true;
@@ -97,7 +97,7 @@
}
#generateButton {
- actionIcon: "generate";
+ actionIcon: generate;
text: "tutti.action.generate";
enabled: {model.isCanGenerate()};
}
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -31,18 +31,16 @@
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import javax.swing.JDialog;
-import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
@@ -78,11 +76,6 @@
//------------------------------------------------------------------------//
@Override
- protected SpeciesFrequencyUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
protected SpeciesFrequencyTableModel getTableModel() {
return (SpeciesFrequencyTableModel) getTable().getModel();
}
@@ -93,10 +86,24 @@
}
@Override
- protected void onRowModified(SpeciesFrequencyRowModel row,
+ protected boolean isRowValid(SpeciesFrequencyRowModel row) {
+ //TODO
+ return row.getLengthStep() != null && row.getWeight() != 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);
+
if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
// Need to recompute the computedWeight
@@ -104,29 +111,16 @@
}
}
- @Override
- protected void onRowValidStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected boolean isRowValid(SpeciesFrequencyRowModel row) {
- //TODO
- return true;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected SpeciesFrequencyUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel();
@@ -152,8 +146,40 @@
lengthStepCaracterics,
model.getLengthStepCaracteristic());
- JXTable table = getTable();
+ //TODO Should it come from PROTOCOL or config ?
+ model.setStep(.5f);
+
+ model.setMinStep(10f);
+ model.setMaxStep(20f);
+
+ //TODO Configure this ?
+ model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
+
+ ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ e.consume();
+ Float step = (Float) ui.getRafaleStepField().getModel();
+
+ applyRafaleStep(step);
+ }
+ }
+ });
+
+ // when lengthStepCaracteristic changed, let's updates all row with the new value
+ model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Caracteristic newValue = (Caracteristic) evt.getNewValue();
+ for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
+ rowModel.setLengthStepCaracteristic(newValue);
+ }
+ }
+ });
+
// create table column model
DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
@@ -189,54 +215,14 @@
SpeciesFrequencyTableModel tableModel =
new SpeciesFrequencyTableModel(columnModel, model);
+ JXTable table = getTable();
+
table.setModel(tableModel);
table.setColumnModel(columnModel);
installTableKeyListener(columnModel, table);
- table.getTableHeader().setReorderingAllowed(false);
-
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- //TODO Should it come from PROTOCOL or config ?
- model.setStep(.5f);
-
- model.setMinStep(10f);
- model.setMaxStep(20f);
-
- //TODO Configure this ?
- model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
-
- ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER) {
- e.consume();
- Float step = (Float) ui.getRafaleStepField().getModel();
-
- applyRafaleStep(step);
- }
- }
- });
-
- // when lengthStepCaracteristic changed, let's updates all row with the new value
- model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- Caracteristic newValue = (Caracteristic) evt.getNewValue();
- for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
- rowModel.setLengthStepCaracteristic(newValue);
- }
- }
- });
+ initTable(table);
}
@Override
@@ -326,7 +312,6 @@
frequency = row.getFrequency();
}
-
List<SpeciesFrequencyRowModel> editFrequency;
if (CollectionUtils.isEmpty(frequency)) {
Modified: 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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -38,7 +38,7 @@
}
#categoryComboBox {
- property: "selectedCategory";
+ property: selectedCategory;
selectedItem: {model.getSelectedCategory()};
}
@@ -48,7 +48,7 @@
}
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
enabled: {model.isValid()};
Modified: 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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -58,10 +58,10 @@
]]></script>
<SplitSampleCategoryUIHandler id='handler'
- initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
+ initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
<SplitSampleCategoryUIModel id='model'
- initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
+ initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
Modified: 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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -34,19 +34,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.TuttiUIUtil;
+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.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
import javax.swing.JDialog;
-import javax.swing.table.DefaultTableModel;
-import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
@@ -99,11 +96,6 @@
//------------------------------------------------------------------------//
@Override
- protected SplitSampleCategoryUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
protected SplitSampleCategoryTableModel getTableModel() {
return (SplitSampleCategoryTableModel) getTable().getModel();
}
@@ -114,10 +106,26 @@
}
@Override
- protected void onRowModified(SplitSampleCategoryRowModel row,
+ protected boolean isRowValid(SplitSampleCategoryRowModel row) {
+ //TODO
+ return row.getCategoryValue() != null && row.getWeight() != null;
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
+ SplitSampleCategoryRowModel row) {
+ //TODO
+ }
+
+ @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 total weight
@@ -125,29 +133,16 @@
}
}
- @Override
- protected void onRowValidStateChanged(SplitSampleCategoryRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void onRowModifyStateChanged(SplitSampleCategoryRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected boolean isRowValid(SplitSampleCategoryRowModel row) {
- //TODO
- return true;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected SplitSampleCategoryUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
SplitSampleCategoryUIModel model = new SplitSampleCategoryUIModel();
@@ -167,19 +162,6 @@
Lists.<SampleCategoryType>newArrayList(),
model.getSelectedCategory());
- JXTable table = getTable();
-
- table.getTableHeader().setReorderingAllowed(false);
-
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
-
// when category changed, remove selected category
model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
@Override
@@ -198,6 +180,10 @@
generateTableModel(newValue);
}
});
+
+ generateTableModel(null);
+
+ initTable(getTable());
}
@Override
@@ -295,21 +281,18 @@
}
}
-
protected void generateTableModel(SampleCategoryEnum category) {
- if (category == null) {
+ Caracteristic data = null;
- getTable().setModel(new DefaultTableModel());
- } else {
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ if (category != null) {
+
Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
getDecorator(CaracteristicQualitativeValue.class, null);
- Caracteristic data = null;
-
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
switch (category) {
case sortedUnsorted:
@@ -344,30 +327,29 @@
SplitSampleCategoryTableModel.WEIGHT,
TuttiUI.DECIMAL3_PATTERN);
}
+ }
- // create table model
- SplitSampleCategoryTableModel tableModel =
- new SplitSampleCategoryTableModel(columnModel, getModel());
+ // create table model
+ SplitSampleCategoryTableModel tableModel =
+ new SplitSampleCategoryTableModel(columnModel, getModel());
- JXTable table = getTable();
+ JXTable table = getTable();
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
- //TODO Fix this!
+ //TODO Fix this!
// installTableKeyListener(columnModel, table);
- if (data != null) {
+ if (data != null) {
- // add a row for each qualitive value
- for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
- SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
- newRow.setCategoryValue(qualitativeValue);
- tableModel.addNewRow(newRow);
- }
+ // add a row for each qualitive value
+ for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
+ newRow.setCategoryValue(qualitativeValue);
+ tableModel.addNewRow(newRow);
}
}
-
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#environmentTable {
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,14 +33,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
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.event.ListSelectionListener;
import java.util.Collection;
import java.util.List;
@@ -50,8 +48,14 @@
*/
public class EnvironmentTabUIHandler extends AbstractTuttiTableUIHandler<EnvironmentRowModel, EnvironmentTabUIModel> {
- private final static Log log = LogFactory.getLog(EnvironmentTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(EnvironmentTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final EnvironmentTabUI ui;
public EnvironmentTabUIHandler(EditFishingOperationUI parentUi,
@@ -61,10 +65,9 @@
this.ui = ui;
}
- @Override
- protected JXTable getTable() {
- return ui.getEnvironmentTable();
- }
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
@Override
protected EnvironmentTableModel getTableModel() {
@@ -72,28 +75,29 @@
}
@Override
- protected void onRowModified(EnvironmentRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ protected JXTable getTable() {
+ return ui.getEnvironmentTable();
}
@Override
- protected void onRowValidStateChanged(EnvironmentRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(EnvironmentRowModel row) {
+ //TODO
+ return row.getValue() != null;
}
@Override
- protected void onRowModifyStateChanged(EnvironmentRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EnvironmentRowModel> rowMonitor,
+ EnvironmentRowModel row) {
+// getModel().setCaracteristic(row.getKey(), row.getValue());
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(EnvironmentRowModel row) {
- //TODO
- return true;
+ protected EnvironmentTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -106,6 +110,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -133,35 +140,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<CaracteristicRow>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<EnvironmentRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<EnvironmentRowModel> monitor = getRowMonitor();
- EnvironmentRowModel row = monitor.getBean();
- if (row != null) {
- getModel().setCaracteristic(row.getKey(), row.getValue());
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected EnvironmentTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -171,7 +159,7 @@
EnvironmentRowModel row = getTableModel().createNewRow();
row.setKey(caracteristic);
getTableModel().addNewRow(row);
- getModel().setCaracteristic(caracteristic, null);
+// getModel().setCaracteristic(caracteristic, null);
keyCombo.removeItem(selectedItem);
selectFirstInCombo(keyCombo);
@@ -197,7 +185,7 @@
rows.add(newRow);
}
- tableModel.setRows(rows, false);
+ model.setRows(rows);
List<CaracteristicRow> caracteristicList = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
@@ -82,11 +81,4 @@
public void setAvailableCaracteristics(List<Caracteristic> caracteristics) {
availableCaracteristics = caracteristics;
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#gearShootingTable {
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,14 +33,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
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.event.ListSelectionListener;
import java.util.Collection;
import java.util.List;
@@ -50,19 +48,26 @@
*/
public class GearShootingTabUIHandler extends AbstractTuttiTableUIHandler<GearShootingRowModel, GearShootingTabUIModel> {
- private final static Log log = LogFactory.getLog(GearShootingTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(GearShootingTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final GearShootingTabUI ui;
- public GearShootingTabUIHandler(EditFishingOperationUI parentUi, GearShootingTabUI ui) {
- super(parentUi.getHandler().getContext(), GearShootingRowModel.PROPERTY_VALUE);
+ public GearShootingTabUIHandler(EditFishingOperationUI parentUi,
+ GearShootingTabUI ui) {
+ super(parentUi.getHandler().getContext(),
+ GearShootingRowModel.PROPERTY_VALUE);
this.ui = ui;
}
- @Override
- protected JXTable getTable() {
- return ui.getGearShootingTable();
- }
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
@Override
protected GearShootingTableModel getTableModel() {
@@ -70,28 +75,31 @@
}
@Override
- protected void onRowModified(GearShootingRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ protected JXTable getTable() {
+ return ui.getGearShootingTable();
}
@Override
- protected void onRowValidStateChanged(GearShootingRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(GearShootingRowModel row) {
+ //TODO
+ return row.getValue() != null;
}
@Override
- protected void onRowModifyStateChanged(GearShootingRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<GearShootingRowModel> rowMonitor,
+ GearShootingRowModel row) {
+
+ //TODO Check row was modified and is valid ?
+ getModel().setCaracteristic(row.getKey(), row.getValue());
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(GearShootingRowModel row) {
- //TODO
- return true;
+ protected GearShootingTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -104,6 +112,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -133,34 +144,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<CaracteristicRow>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<GearShootingRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<GearShootingRowModel> monitor = getRowMonitor();
- GearShootingRowModel row = monitor.getBean();
- if (row != null) {
- getModel().setCaracteristic(row.getKey(), row.getValue());
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected GearShootingTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -195,7 +188,7 @@
rows.add(newRow);
}
- tableModel.setRows(rows, false);
+ model.setRows(rows);
List<CaracteristicRow> caracteristicList = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -30,7 +30,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
@@ -84,10 +83,4 @@
public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) {
this.availableCaracteristics = availableCaracteristics;
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#hydrologyTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -21,11 +21,12 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'>
-
+<Table
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'>
+
<import>
fr.ifremer.tutti.persistence.entities.referential.Caracteristic
-
+
fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
jaxx.runtime.swing.editor.bean.BeanComboBox
@@ -35,13 +36,13 @@
javax.swing.ListSelectionModel
java.awt.Color
</import>
-
+
<HydrologyTabUIHandler id='handler'
initializer='getContextValue(HydrologyTabUIHandler.class)'/>
<HydrologyTabUIModel id='model'
initializer='getContextValue(HydrologyTabUIModel.class)'/>
-
+
<row fill='both'>
<cell fill='both' weightx='1'>
<BeanComboBox id='newRowKey' constructorParams='this'
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,15 +35,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
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.event.ListSelectionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
@@ -58,8 +55,14 @@
*/
public class HydrologyTabUIHandler extends AbstractTuttiTableUIHandler<HydrologyRowModel, HydrologyTabUIModel> {
- private final static Log log = LogFactory.getLog(HydrologyTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(HydrologyTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final HydrologyTabUI ui;
protected Map<Caracteristic, Map<Type, Caracteristic>> availableCaracteristics;
@@ -74,6 +77,10 @@
this.ui = ui;
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
protected JXTable getTable() {
return ui.getHydrologyTable();
@@ -85,28 +92,44 @@
}
@Override
- protected void onRowModified(HydrologyRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
- }
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<HydrologyRowModel> rowMonitor,
+ HydrologyRowModel row) {
- @Override
- protected void onRowValidStateChanged(HydrologyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ Map<Type, Caracteristic> caracteristics =
+ availableCaracteristics.get(row.getKey());
+ CaracteristicMap map = new CaracteristicMap();
+ for (Type type : caracteristics.keySet()) {
+ Serializable value = null;
+ switch (type) {
+ case START:
+ value = row.getGearShootingStartValue();
+ break;
+ case END:
+ value = row.getGearShootingEndValue();
+ break;
+ case AVERAGE:
+ value = row.getAverageValue();
+ }
+ map.put(caracteristics.get(type), value);
+ }
+ getModel().addCaracteristics(map);
}
@Override
- protected void onRowModifyStateChanged(HydrologyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(HydrologyRowModel row) {
+ //TODO
+ return row.getGearShootingStartValue() != null ||
+ row.getGearShootingEndValue() != null ||
+ row.getAverageValue() != null;
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(HydrologyRowModel row) {
- //TODO
- return true;
+ protected HydrologyTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -140,6 +163,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<Caracteristic>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -184,52 +210,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<Caracteristic>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<HydrologyRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<HydrologyRowModel> monitor = getRowMonitor();
- HydrologyRowModel row = monitor.getBean();
- if (row != null) {
- Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(row.getKey());
- CaracteristicMap map = new CaracteristicMap();
- for (Type type : caracteristics.keySet()) {
- Serializable value = null;
- switch (type) {
- case START:
- value = row.getGearShootingStartValue();
- break;
- case END:
- value = row.getGearShootingEndValue();
- break;
- case AVERAGE:
- value = row.getAverageValue();
- }
- map.put(caracteristics.get(type), value);
- }
- getModel().addCaracteristics(map);
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
-
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected HydrologyTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -285,7 +275,8 @@
}
}
- tableModel.setRows(rows, false);
+ getModel().setRows(rows);
+
ui.getNewRowKey().setData(caracteristicList);
selectFirstInCombo(ui.getNewRowKey());
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -86,10 +86,4 @@
this.availableCaracteristics = availableCaracteristics;
firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics);
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(Caracteristic selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -41,7 +41,7 @@
#nameLabel {
text: "tutti.label.program.name";
- labelFor: {nameField};
+ labelFor: {nameField};
}
#nameField {
@@ -49,8 +49,8 @@
}
#commentPane {
- columnHeaderView: {new JLabel(_("tutti.label.comment"))};
- minimumSize: {new Dimension(10,50)};
+ columnHeaderView: {new JLabel(_("tutti.label.comment"))};
+ minimumSize: {new Dimension(10,50)};
}
#commentField {
@@ -63,19 +63,19 @@
}
#zoneComboBox {
- property: "zone";
+ property: zone;
selectedItem: {model.getZone()};
}
#saveButton {
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
- actionIcon: "save";
+ actionIcon: save;
}
#cancelButton {
text: "tutti.action.cancel";
- actionIcon: "cancel";
+ actionIcon: cancel;
}
#messagePanel {
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -100,7 +100,7 @@
onFocusGained='commentField.requestFocus()'>
<JTextArea id='commentField'
onKeyReleased='handler.setText(event, "comment")'/>
- </JScrollPane>
+ </JScrollPane>
</cell>
</row>
@@ -118,7 +118,7 @@
<!-- validation messages -->
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,8 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
BeanDoubleList {
@@ -44,7 +43,7 @@
#nameLabel {
text: "tutti.label.program.name";
- labelFor: {nameField};
+ labelFor: {nameField};
}
#nameField {
@@ -52,8 +51,8 @@
}
#commentPane {
- columnHeaderView: {new JLabel(_("tutti.label.comment"))};
- minimumSize: {new Dimension(10,50)};
+ columnHeaderView: {new JLabel(_("tutti.label.comment"))};
+ minimumSize: {new Dimension(10,50)};
}
#commentField {
@@ -63,12 +62,12 @@
#saveButton {
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
- actionIcon: "save";
+ actionIcon: save;
}
#cancelButton {
text: "tutti.action.cancel";
- actionIcon: "cancel";
+ actionIcon: cancel;
}
#messagePanel {
@@ -88,13 +87,12 @@
#speciesComboBox {
showReset: false;
- property: selectedSpecies;
enabled: {!speciesComboBox.isEmpty()};
}
#addRow {
- actionIcon: "add";
- enabled: {!speciesComboBox.isEmpty() && speciesComboBox.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {speciesComboBox.getSelectedItem() != null};
}
#speciesTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -36,11 +36,11 @@
java.awt.Dimension
java.awt.Color
-
+
javax.swing.ListSelectionModel
-
+
org.jdesktop.swingx.JXTable
-
+
static org.nuiton.i18n.I18n._
static jaxx.runtime.SwingUtil.getStringValue
@@ -60,10 +60,10 @@
]]></script>
<EditProtocolUIHandler id='handler'
- initializer='getContextValue(EditProtocolUIHandler.class)'/>
+ initializer='getContextValue(EditProtocolUIHandler.class)'/>
<EditProtocolUIModel id='model'
- initializer='getContextValue(EditProtocolUIModel.class)'/>
+ initializer='getContextValue(EditProtocolUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
@@ -103,7 +103,7 @@
</row>
</Table>
</tab>
-
+
<tab title='tutti.label.tab.protocol.species'>
<Table fill='both'>
<row fill='both'>
@@ -124,7 +124,7 @@
</row>
</Table>
</tab>
-
+
<tab title='tutti.label.tab.protocol.pmfm'>
<Table fill='both' weightx='1'>
<row fill='both' weighty='1'>
@@ -134,7 +134,8 @@
</row>
<row fill='both' weighty='1'>
<cell fill='both'>
- <BeanDoubleList id='environmentList' genericType='Caracteristic'/>
+ <BeanDoubleList id='environmentList'
+ genericType='Caracteristic'/>
</cell>
</row>
<row fill='both' weighty='1'>
@@ -150,11 +151,11 @@
<JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
<JButton id='saveButton' onActionPerformed='handler.save()'/>
</JPanel>
-
+
</JPanel>
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,9 +26,7 @@
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
-import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
@@ -36,18 +34,16 @@
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
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;
@@ -55,7 +51,6 @@
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableColumn;
@@ -84,13 +79,6 @@
*/
private final EditProtocolUI ui;
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- private final PersistenceService persistenceService;
-
protected Map<String, Species> allSpecies;
protected Map<String, Caracteristic> allLengthStepPmfm;
@@ -108,7 +96,6 @@
public EditProtocolUIHandler(TuttiUIContext context, EditProtocolUI ui) {
super(context);
this.ui = ui;
- persistenceService = context.getService(PersistenceService.class);
columToSampleCategory = HashBiMap.create(SampleCategoryEnum.values().length);
columToSampleCategory.put(EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED, SampleCategoryEnum.sortedUnsorted);
columToSampleCategory.put(EditProtocolSpeciesTableModel.SIZE_ENABLED, SampleCategoryEnum.size);
@@ -117,9 +104,13 @@
columToSampleCategory.put(EditProtocolSpeciesTableModel.AGE_ENABLED, SampleCategoryEnum.age);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected EditProtocolUIModel getModel() {
- return ui.getModel();
+ protected EditProtocolSpeciesTableModel getTableModel() {
+ return (EditProtocolSpeciesTableModel) getTable().getModel();
}
@Override
@@ -128,46 +119,43 @@
}
@Override
- protected EditProtocolSpeciesTableModel getTableModel() {
- return (EditProtocolSpeciesTableModel) getTable().getModel();
+ protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
+ boolean result = row.getLengthStepPmfm() != null;
+ return result;
}
@Override
- protected void onRowModified(EditProtocolSpeciesRowModel row,
+ 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) {
- if (log.isInfoEnabled()) {
- log.info("onRowModified property: " + propertyName +
- ", newvalue: " + newValue);
- }
- boolean rowIsValid = isRowValid(row);
- row.setValid(rowIsValid);
- getModel().setModify(true);
- }
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
- @Override
- protected void onRowValidStateChanged(EditProtocolSpeciesRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- if (log.isInfoEnabled()) {
- log.info("onRowValidStateChanged, newValidstate: " + newValue);
- }
- }
+ if (row.isValid()) {
- @Override
- protected void onRowModifyStateChanged(EditProtocolSpeciesRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- if (log.isInfoEnabled()) {
- log.info("onRowModifyStateChanged, newModifiedState: " + 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!
+ getModel().setModify(true);
}
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
- boolean result = row.getLengthStepPmfm() != null;
- return result;
+ protected EditProtocolUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -175,45 +163,22 @@
EditProtocolUIModel model = new EditProtocolUIModel();
- String protocolId = context.getProtocolId();
- if (protocolId == null) {
+ // can't load directly model fro 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
- // create new protocol
-
- if (log.isDebugEnabled()) {
- log.debug("Will create a new protocol");
- }
- } else {
-
- // load existing program
- TuttiProtocol protocol =
- persistenceService.getProtocol(protocolId);
-
- model.fromBean(protocol);
- if (log.isDebugEnabled()) {
- log.debug("Will edit protocol: " + protocolId);
- }
- }
-
listModelIsModify(model);
ui.setContextValue(model);
- List<Species> species = persistenceService.getAllSpecies();
- allSpecies = Maps.newHashMap();
- for (Species s : species) {
- allSpecies.put(s.getId(), s);
- }
+ allSpecies = TuttiEntities.splitById(
+ persistenceService.getAllSpecies());
- List<Caracteristic> lengthStepCaracteristics =
- persistenceService.getAllSpeciesLengthStepCaracteristic();
- allLengthStepPmfm = Maps.newHashMap();
- for (Caracteristic c : lengthStepCaracteristics) {
- allLengthStepPmfm.put(c.getId(), c);
- }
+ allLengthStepPmfm = TuttiEntities.splitById(
+ persistenceService.getAllSpeciesLengthStepCaracteristic());
- List<Caracteristic> hydrologyPmfm = persistenceService.getAllFishingOperationHydrologicCaracteristic();
- hydroCaracteristics = HashMultimap.create();
- for (Caracteristic caracteristic : hydrologyPmfm) {
+ for (Caracteristic caracteristic :
+ persistenceService.getAllFishingOperationHydrologicCaracteristic()) {
String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
hydroCaracteristics.put(name, caracteristic.getId());
}
@@ -231,8 +196,6 @@
listenValidatorValid(ui.getValidator(), model);
- List<Species> speciesList = Lists.newArrayList(allSpecies.values());
-
// create table model
JXTable table = getTable();
@@ -278,77 +241,74 @@
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
- // fill table model
+ initTable(table);
- List<SpeciesProtocol> speciesProtocol = model.getSpecies();
- if (speciesProtocol == null) {
- speciesProtocol = Lists.newArrayList();
+ // Authorize to change column orders
+ table.getTableHeader().setReorderingAllowed(true);
+
+ List<Species> speciesList = Lists.newArrayList(allSpecies.values());
+
+ // load protocol if existing
+
+ String protocolId = context.getProtocolId();
+ if (protocolId == null) {
+
+ // create new protocol
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will create a new protocol");
+ }
+ } else {
+
+ // load existing protocol
+ TuttiProtocol protocol = persistenceService.getProtocol(protocolId);
+
+ model.fromBean(protocol);
+
+ // build speciesProtocol rows
+ List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
+
+ List<SpeciesProtocol> speciesProtocols = protocol.getSpecies();
+ if (CollectionUtils.isNotEmpty(speciesProtocols)) {
+ for (SpeciesProtocol speciesProtocol : speciesProtocols) {
+ Species species = allSpecies.get(speciesProtocol.getSpeciesId());
+ speciesList.remove(species);
+ EditProtocolSpeciesRowModel row = tableModel.createNewRow();
+ row.setSpecies(species);
+ row.setLengthStepPmfm(allLengthStepPmfm.get(speciesProtocol.getLengthStepPmfmId()));
+ row.fromBean(speciesProtocol);
+ rows.add(row);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Will edit protocol: " + protocolId + " with " +
+ rows.size() + " species declared.");
+ }
+
+ // set to model ( will propagate to tableModel)
+ model.setRows(rows);
}
- List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
- for (SpeciesProtocol protocol : speciesProtocol) {
- Species species = allSpecies.get(protocol.getSpeciesId());
- speciesList.remove(species);
- EditProtocolSpeciesRowModel row = tableModel.createNewRow();
- row.setSpecies(species);
- row.setLengthStepPmfm(allLengthStepPmfm.get(protocol.getLengthStepPmfmId()));
- row.fromBean(protocol);
- rows.add(row);
- }
- tableModel.setRows(rows, false);
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
// init species combo box
initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
selectFirstInCombo(ui.getSpeciesComboBox());
-// // Species
-// final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
-// speciesCombo.setRenderer(newListCellRender(Species.class));
-// speciesCombo.setModel(new DefaultComboBoxModel());
-// for (Species species : allSpecies.values()) {
-// speciesCombo.addItem(species);
-// }
-// speciesCombo.getModel().addListDataListener(new ListDataListener() {
-//
-// public void intervalAdded(ListDataEvent e) {
-// speciesCombo.setEnabled(true);
-// ui.getAddRow().setEnabled(true);
-// }
-//
-// public void intervalRemoved(ListDataEvent e) {
-// if (speciesCombo.getItemCount() == 0) {
-// speciesCombo.setEnabled(false);
-// ui.getAddRow().setEnabled(false);
-// }
-// }
-//
-// public void contentsChanged(ListDataEvent e) {
-// speciesCombo.setEnabled(true);
-// ui.getAddRow().setEnabled(true);
-// }
-// });
- ListSelectionListener listener = new TableRowModificationListener<EditProtocolSpeciesRowModel>(
- tableModel, getRowMonitor()) {
+ // init gear pmfm double list
+ List<Caracteristic> gearPmfm =
+ persistenceService.getAllFishingOperationGearCaracteristic();
+ initDoubleList(ui.getGearList(), gearPmfm, model.getGearPmfmId());
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<EditProtocolSpeciesRowModel> monitor = getRowMonitor();
- EditProtocolSpeciesRowModel row = monitor.getBean();
- if (row != null && monitor.wasModified()) {
- getModel().setModify(true);
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
+ // init environement pmfm double list
+ List<Caracteristic> environmentPmfm =
+ persistenceService.getAllFishingOperationEnvironmentCaracteristic();
+ initDoubleList(ui.getEnvironmentList(),
+ environmentPmfm,
+ model.getEnvironmentPmfmId());
- // PMFM
- List<Caracteristic> gearPmfm = persistenceService.getAllFishingOperationGearCaracteristic();
- initDoubleList(ui.getGearList(), gearPmfm, model.getGearPmfmId());
- List<Caracteristic> environmentPmfm = persistenceService.getAllFishingOperationEnvironmentCaracteristic();
- initDoubleList(ui.getEnvironmentList(), environmentPmfm, model.getEnvironmentPmfmId());
- //hydro
+ // init hydro pmfm double list
List<Caracteristic> selection = Lists.newArrayList();
Collection<String> availableCaracteristicNames = hydroCaracteristics.keySet();
List<Caracteristic> availableCaracteristics = Lists.newArrayList();
@@ -369,31 +329,20 @@
}
}
}
-
initBeanList(ui.getHydrologyList(), availableCaracteristics, selection);
// if new protocol can already cancel his creation
model.setModify(model.isCreate());
}
- protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
- List<Caracteristic> availableCaracteristics,
- List<String> selectedCaracteristics) {
- List<Caracteristic> selection = Lists.newArrayList();
- if (selectedCaracteristics != null) {
- for (Caracteristic caracteristic : availableCaracteristics) {
- if (selectedCaracteristics.contains(caracteristic.getId())) {
- selection.add(caracteristic);
- }
- }
- }
- initBeanList(widget, availableCaracteristics, selection);
- }
-
@Override
public void onCloseUI() {
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
public void cancel() {
context.setScreen(TuttiScreen.SELECT_CRUISE);
@@ -407,11 +356,12 @@
// get the species protocols from the table
List<SpeciesProtocol> protocols = Lists.newArrayList();
- List<EditProtocolSpeciesRowModel> rows =
- ((AbstractTuttiTableModel<EditProtocolSpeciesRowModel>) ui.getSpeciesTable().getModel()).getRows();
- for (EditProtocolSpeciesRowModel row : rows) {
- SpeciesProtocol protocol = row.toBean();
- protocols.add(protocol);
+
+ for (EditProtocolSpeciesRowModel row : getTableModel().getRows()) {
+ if (row.isValid()) {
+ SpeciesProtocol protocol = row.toBean();
+ protocols.add(protocol);
+ }
}
bean.setSpecies(protocols);
@@ -459,4 +409,22 @@
selectFirstInCombo(ui.getSpeciesComboBox());
// getModel().setModify(true);
}
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
+ List<Caracteristic> availableCaracteristics,
+ List<String> selectedCaracteristics) {
+ List<Caracteristic> selection = Lists.newArrayList();
+ if (selectedCaracteristics != null) {
+ for (Caracteristic caracteristic : availableCaracteristics) {
+ if (selectedCaracteristics.contains(caracteristic.getId())) {
+ selection.add(caracteristic);
+ }
+ }
+ }
+ initBeanList(widget, availableCaracteristics, selection);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -162,16 +161,16 @@
setHydrologyPmfmId(ids);
}
- public List<SpeciesProtocol> getSpecies() {
- return species;
- }
+// public List<SpeciesProtocol> getSpecies() {
+// return species;
+// }
+//
+// public void setSpecies(List<SpeciesProtocol> species) {
+// Object oldValue = getSpecies();
+// this.species = species;
+// firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+// }
- public void setSpecies(List<SpeciesProtocol> species) {
- Object oldValue = getSpecies();
- this.species = species;
- firePropertyChange(PROPERTY_SPECIES, oldValue, species);
- }
-
public List<SampleCategoryEnum> getSampleCategoryOrder() {
return sampleCategoryOrder;
}
@@ -181,11 +180,4 @@
this.sampleCategoryOrder = sampleCategoryOrder;
firePropertyChange(PROPERTY_SAMPLE_CATEGORY_ORDER, oldValue, sampleCategoryOrder);
}
-
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedSpecies(Species selectedSpecies) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,8 +28,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
/**
- *
* @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
*/
public class HydrologicCaracteristicUtil {
@@ -38,14 +38,14 @@
END,
AVERAGE
}
-
+
public static String getGlobalName(String name) {
if (name.charAt(name.length() - 2) == '_') {
name = name.substring(0, name.length() - 2);
}
return name;
}
-
+
public static Caracteristic createGlobalCaracteristic(String name, Caracteristic toClone) {
Caracteristic caracteristic = new Caracteristic();
caracteristic.setName(name);
@@ -61,7 +61,7 @@
}
return caracteristic;
}
-
+
public static Type getTypeOfCaracteristic(Caracteristic caracteristic) {
String name = caracteristic.getName();
Type result = null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -37,11 +37,11 @@
}
#addButton {
- actionIcon: "add";
+ actionIcon: add;
}
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -22,13 +22,13 @@
#L%
-->
<Table id='mainPanel'>
-
+
<import>
fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel
fr.ifremer.tutti.persistence.entities.data.Attachment
jaxx.runtime.swing.editor.FileEditor
</import>
-
+
<!-- bean property linked state -->
<String id='property' javaBean='""'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -36,11 +36,9 @@
import javax.swing.JButton;
import javax.swing.JDialog;
-import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Cursor;
-import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -186,7 +184,7 @@
}
protected void resetFields() {
- ui.getFile().setSelectedFile((File)null);
+ ui.getFile().setSelectedFile((File) null);
ui.getFileName().setText("");
ui.getFileComment().setText("");
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,14 +29,6 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import java.awt.Color;
-import java.awt.Component;
-import java.util.List;
-import javax.swing.AbstractCellEditor;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.TableCellEditor;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
@@ -46,32 +38,43 @@
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.AbstractCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.List;
+
/**
* Editor for the values of the caracteristics of the fishing operations.
* The editor depends on the caracteristic value type.
- *
+ *
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
public class CaracteristicValueEditor extends AbstractCellEditor implements TableCellEditor {
+ private static final long serialVersionUID = 1L;
+
protected int caracteristicColumn;
-
+
protected TableCellEditor editor;
-
+
protected Decorator<CaracteristicQualitativeValue> decorator;
-
+
public CaracteristicValueEditor(TuttiUIContext context) {
this(0, context);
}
-
+
public CaracteristicValueEditor(int caracteristicColumn, TuttiUIContext context) {
super();
this.caracteristicColumn = caracteristicColumn;
DecoratorService decoratorService = context.getService(DecoratorService.class);
decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
}
-
+
@Override
public Object getCellEditorValue() {
return editor.getCellEditorValue();
@@ -80,37 +83,36 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
editor = table.getDefaultEditor(Object.class);
-
+
Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
- if (caracteristic != null) {
+ if (caracteristic != null) {
if (caracteristic.isBooleanType()) {
editor = table.getDefaultEditor(Boolean.class);
-
+
} else if (caracteristic.isNumberType()) {
NumberCellEditor<Float> editor =
- JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+ JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
editor.getNumberEditor().setSelectAllTextOnError(true);
editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
this.editor = editor;
-
+
} else if (caracteristic.isQualitativeType()) {
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(new DecoratorListCellRenderer(decorator));
-
+
List<CaracteristicQualitativeValue> data = caracteristic.getQualitativeValue();
// add a null value at first position
if (!data.isEmpty() && data.get(0) != null) {
data.add(0, null);
}
SwingUtil.fillComboBox(comboBox, data, null);
-
ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
BeanUIUtil.decorate(comboBox, converter);
editor = new ComboBoxCellEditor(comboBox);
}
}
-
+
Component result = editor.getTableCellEditorComponent(table, value, isSelected, row, column);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,48 +29,44 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import java.awt.Component;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
-import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+
/**
* Renderer for the values of the caracteristics of the fishing operations.
* The renderer depends on the caracteristic value type.
- *
+ *
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
public class CaracteristicValueRenderer implements TableCellRenderer {
protected int caracteristicColumn;
-
+
protected Decorator<CaracteristicQualitativeValue> decorator;
-
+
public CaracteristicValueRenderer(TuttiUIContext context) {
this(0, context);
}
-
+
public CaracteristicValueRenderer(int caracteristicColumn, TuttiUIContext context) {
super();
this.caracteristicColumn = caracteristicColumn;
DecoratorService decoratorService = context.getService(DecoratorService.class);
decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
}
-
+
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
TableCellRenderer renderer = table.getDefaultRenderer(Object.class);
Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
- if (caracteristic != null) {
+ if (caracteristic != null) {
if (caracteristic.isBooleanType()) {
renderer = table.getDefaultRenderer(Boolean.class);
-
+
} else if (caracteristic.isQualitativeType()) {
renderer = new DecoratorTableCellRenderer(decorator);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -32,7 +32,6 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import java.awt.event.FocusEvent;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import org.apache.commons.lang3.StringUtils;
@@ -50,7 +49,6 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;
-import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -158,7 +156,7 @@
ComponentMover cm = new ComponentMover();
cm.setDragInsets(cr.getDragInsets());
cm.registerComponent(editor);
-
+
editor.addWindowListener(new WindowAdapter() {
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -22,7 +22,7 @@
* #L%
*/
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -23,23 +23,22 @@
*/
#hour {
- value:{model.getTimeModel() / 60};
- enabled:{isEnabled()};
- model:{new SpinnerNumberModel(0, 0, 23, 1)};
+ value: {model.getTimeModel() / 60};
+ enabled: {isEnabled()};
+ model: {new SpinnerNumberModel(0, 0, 23, 1)};
}
#labelH {
- text:"tutti.timeeditor.H";
- horizontalAlignment:center;
+ text: "tutti.timeeditor.H";
+ horizontalAlignment: center;
}
#minuteModel {
- calendarField:{java.util.Calendar.MINUTE};
- value:{handler.setMinuteModel(model.getDate())};
+ calendarField: {java.util.Calendar.MINUTE};
+ value: {handler.setMinuteModel(model.getDate())};
}
#minute {
- enabled:{isEnabled()};
- model:{minuteModel};
+ enabled: {isEnabled()};
+ model: {minuteModel};
}
-
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,32 +26,40 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.TableColumnExt;
import org.nuiton.util.decorator.Decorator;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.border.LineBorder;
+import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.Color;
+import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -76,39 +84,57 @@
LogFactory.getLog(AbstractTuttiTableUIHandler.class);
/**
- * Monitor the selected row (save it only if something has changed).
- *
+ * @return the table model handled byt the main table.
* @since 0.2
*/
- private final TuttiBeanMonitor<R> rowMonitor;
+ protected abstract AbstractTuttiTableModel<R> getTableModel();
+ /**
+ * @return the main table of the ui.
+ * @since 0.2
+ */
protected abstract JXTable getTable();
- protected abstract AbstractTuttiTableModel<R> getTableModel();
+ /**
+ * Validates the given row.
+ *
+ * @param row row to validate
+ * @return {@code true} if row is valid, {@code false} otherwise.
+ * @since 0.2
+ */
+ protected abstract boolean isRowValid(R row);
- protected abstract void onRowModified(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.
+ *
+ * @param rowMonitor the row monitor (see {@link #rowMonitor})
+ * @param row the row to save if necessary
+ * @since 0.3
+ */
+ protected abstract void saveSelectedRowIfRequired(TuttiBeanMonitor<R> rowMonitor, R row);
- protected abstract void onRowValidStateChanged(R row,
- Boolean oldValue,
- Boolean newValue);
+ /**
+ * Monitor the selected row (save it only if something has changed).
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<R> rowMonitor;
- protected abstract void onRowModifyStateChanged(R row,
- Boolean oldValue,
- Boolean newValue);
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ protected final PersistenceService persistenceService;
- protected abstract boolean isRowValid(R row);
-
- protected String[] getRowPropertiesToIgnore() {
- return ArrayUtils.EMPTY_STRING_ARRAY;
- }
-
protected AbstractTuttiTableUIHandler(TuttiUIContext context,
String... properties) {
super(context);
+ this.persistenceService = context.getService(PersistenceService.class);
+
rowMonitor = new TuttiBeanMonitor<R>(properties);
// listen when bean is changed
@@ -127,17 +153,19 @@
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
+ int rowIndex = getTableModel().getRowIndex(row);
+
if (AbstractTuttiBeanUIModel.PROPERTY_VALID.equals(propertyName)) {
- onRowValidStateChanged(row,
+ onRowValidStateChanged(rowIndex, row,
(Boolean) oldValue,
(Boolean) newValue);
} else if (AbstractTuttiBeanUIModel.PROPERTY_MODIFY.equals(propertyName)) {
- onRowModifyStateChanged(row,
+ onRowModifyStateChanged(rowIndex, row,
(Boolean) oldValue,
(Boolean) newValue);
} else if (!propertiesToSkip.contains(propertyName)) {
- onRowModified(row,
+ onRowModified(rowIndex, row,
propertyName,
oldValue,
newValue);
@@ -163,6 +191,132 @@
});
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods (row methods) --//
+ //------------------------------------------------------------------------//
+
+ protected String[] getRowPropertiesToIgnore() {
+ return ArrayUtils.EMPTY_STRING_ARRAY;
+ }
+
+ protected void onModelRowsChanged(List<R> rows) {
+ if (CollectionUtils.isNotEmpty(rows)) {
+ for (R row : rows) {
+ boolean rowIsValid = isRowValid(row);
+ row.setValid(rowIsValid);
+ }
+ }
+ 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,
+ Boolean newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] modify state changed from " +
+ oldValue + " to " + newValue);
+ }
+ }
+
+ protected void onRowValidStateChanged(int rowIndex,
+ R row,
+ Boolean oldValue,
+ Boolean newValue) {
+
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] valid state changed from " +
+ oldValue + " to " + newValue);
+ }
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods (init methods) --//
+ //------------------------------------------------------------------------//
+
+ protected void initTable(JXTable table) {
+
+ // by default do not authorize to change column orders
+ table.getTableHeader().setReorderingAllowed(false);
+
+ // paint in a special color read only cells
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
+ table.addHighlighter(readOnlyHighlighter);
+
+ // paint in a special color inValid rows
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ R row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), getConfig().getColorRowInvalid());
+ table.addHighlighter(validHighlighter);
+
+ // when model data change let's propagate it table model
+ getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ onModelRowsChanged((List<R>) evt.getNewValue());
+ }
+ });
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<R>(
+ getTableModel(), rowMonitor) {
+ @Override
+ protected void saveSelectedRow() {
+
+ saveSelectedRowIfNeeded();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+ }
+
+ protected final void saveSelectedRowIfNeeded() {
+
+ R row = rowMonitor.getBean();
+
+ if (row != null) {
+
+ saveSelectedRowIfRequired(rowMonitor, row);
+ }
+ }
+
protected KeyListener installTableKeyListener(TableColumnModel columnModel,
JTable table) {
@@ -262,7 +416,6 @@
addColumnToModel(model, editor, null, identifier);
}
-
protected void addBooleanColumnToModel(TableColumnModel model,
ColumnIdentifier<R> identifier,
JTable table) {
@@ -296,19 +449,6 @@
identifier);
}
- protected void listenRowsFromModel() {
- getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- onModelRowsChanged((List<R>) evt.getNewValue());
- }
- });
- }
-
- protected void onModelRowsChanged(List<R> rows) {
- getTableModel().setRows(rows);
- }
-
protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
return newTableCellRender(type, null);
@@ -330,8 +470,4 @@
return result;
}
- protected TuttiBeanMonitor<R> getRowMonitor() {
- return rowMonitor;
- }
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -51,8 +51,8 @@
}
protected ColumnIdentifier(String propertyName,
- String headerI18nKey,
- String headerTipI18nKey) {
+ String headerI18nKey,
+ String headerTipI18nKey) {
this.propertyName = propertyName;
this.headerI18nKey = headerI18nKey;
this.headerTipI18nKey = headerTipI18nKey;
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-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-30 19:39:00 UTC (rev 132)
@@ -20,6 +20,7 @@
tutti.action.new=Nouveau
tutti.action.pupitri-import=Import PUPITRI
tutti.action.reload.actions=Recharger les actions
+tutti.action.reload.application=Recharger l'application
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
tutti.action.reset.fishingOperationValidState=Réinitialiser
@@ -32,6 +33,8 @@
tutti.application.name=Tutti
tutti.config.category.applications=Application
tutti.config.category.applications.description=Application
+tutti.config.category.colors=Couleurs
+tutti.config.category.colors.description=Couleurs utilisées dans les interfaces graphiques
tutti.config.category.other=Autres
tutti.config.category.other.description=Autres options
tutti.config.category.shortcuts=Raccourcis
@@ -40,7 +43,10 @@
tutti.config.programId=Identifiant de la dernière série de campagne utilisée
tutti.config.protocolId=Identifiant du dernier protocole utilisé
tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pavé numérique lors de l'édition d'un nombre
+tutti.config.ui.color.rowInvalid=Ligne invalide
+tutti.config.ui.color.rowReadOnly=Cellule non éditable
tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques
+tutti.config.ui.shortcut.closePopup=Fermer une popup
tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2012-12-30 20:35:31 +0100 (Sun, 30 Dec 2012)
New Revision: 131
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/131
Log:
add comment dependency (will try to use it later)
Modified:
trunk/tutti-ui-swing/pom.xml
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2012-12-29 21:09:26 UTC (rev 130)
+++ trunk/tutti-ui-swing/pom.xml 2012-12-30 19:35:31 UTC (rev 131)
@@ -197,6 +197,12 @@
<scope>runtime</scope>
</dependency>
+ <!--dependency>
+ <groupId>com.jidesoft</groupId>
+ <artifactId>jide-oss</artifactId>
+ <version>3.5.0</version>
+ </dependency-->
+
<dependency>
<groupId>fr.ird</groupId>
<artifactId>msaccess-importer</artifactId>
1
0
r130 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 29 Dec '12
by tchemit@users.forge.codelutin.com 29 Dec '12
29 Dec '12
Author: tchemit
Date: 2012-12-29 22:09:26 +0100 (Sat, 29 Dec 2012)
New Revision: 130
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/130
Log:
refs #1804: [CAPTURE] - Mise en place de l'onglet Captures (improve layout)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2012-12-29 20:50:48 UTC (rev 129)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2012-12-29 21:09:26 UTC (rev 130)
@@ -101,7 +101,7 @@
<Table id="catchesForm" fill='both' weightx='1'
constraints='BorderLayout.NORTH'>
<row>
- <cell>
+ <cell columns='2'>
<Table id='catchTable' fill='both'>
<!-- Poids total capture -->
@@ -125,10 +125,10 @@
<NumberEditor id='catchTotalSortedTremisWeightField'
constructorParams='this'/>
</cell>
- <cell>
+ <cell anchor='west'>
<JLabel id='catchTotalSortedCarousselWeightLabel'/>
</cell>
- <cell>
+ <cell weightx='1.0'>
<NumberEditor id='catchTotalSortedCarousselWeightField'
constructorParams='this'/>
</cell>
@@ -157,7 +157,7 @@
<cell>
<Table id='speciesTable' fill='both'>
- <!-- Poids total capture / Poids total vrac -->
+ <!-- Poids total capture -->
<row>
<cell anchor='west'>
<JLabel id='speciesTotalWeightLabel'/>
@@ -166,6 +166,9 @@
<NumberEditor id='speciesTotalWeightField'
constructorParams='this'/>
</cell>
+ </row>
+ <!-- Poids total vrac -->
+ <row>
<cell anchor='west'>
<JLabel id='speciesTotalSortedWeightLabel'/>
</cell>
@@ -175,7 +178,7 @@
</cell>
</row>
- <!-- Poids total échantillonné vrac / Poids total hors vrac -->
+ <!-- Poids total échantillonné vrac -->
<row>
<cell>
<JLabel id='speciesTotalSampleSortedWeightLabel'/>
@@ -184,6 +187,9 @@
<NumberEditor id='speciesTotalSampleSortedWeightField'
constructorParams='this'/>
</cell>
+ </row>
+ <!-- Poids total hors vrac -->
+ <row>
<cell>
<JLabel id='speciesTotalUnsortedWeightLabel'/>
</cell>
@@ -193,12 +199,9 @@
</row>
</Table>
</cell>
- </row>
- <row>
<cell>
<Table id='benthosTable' fill='both'>
-
- <!-- Poids total capture / Poids total vrac -->
+ <!-- Poids total capture -->
<row>
<cell anchor='west'>
<JLabel id='benthosTotalWeightLabel'/>
@@ -207,6 +210,9 @@
<NumberEditor id='benthosTotalWeightField'
constructorParams='this'/>
</cell>
+ </row>
+ <!-- Poids total vrac -->
+ <row>
<cell anchor='west'>
<JLabel id='benthosTotalSortedWeightLabel'/>
</cell>
@@ -216,7 +222,7 @@
</cell>
</row>
- <!-- Poids total échantillonné vrac / Poids total hors vrac -->
+ <!-- Poids total échantillonné vrac -->
<row>
<cell>
<JLabel id='benthosTotalSampleSortedWeightLabel'/>
@@ -225,6 +231,9 @@
<NumberEditor id='benthosTotalSampleSortedWeightField'
constructorParams='this'/>
</cell>
+ </row>
+ <!-- Poids total hors vrac -->
+ <row>
<cell>
<JLabel id='benthosTotalUnsortedWeightLabel'/>
</cell>
@@ -236,7 +245,7 @@
</cell>
</row>
<row>
- <cell>
+ <cell columns='2'>
<Table id='macroWasteTable' fill='both'>
<!-- Poids total Macro dechet -->
@@ -257,7 +266,7 @@
<!-- Actions d'import -->
<row>
- <cell>
+ <cell columns='2'>
<JPanel layout='{new GridLayout(1,0)}'>
<JButton id='importPupitriButton'
onActionPerformed='handler.importPupitri()'/>
1
0
29 Dec '12
Author: tchemit
Date: 2012-12-29 21:50:48 +0100 (Sat, 29 Dec 2012)
New Revision: 129
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/129
Log:
refs #1812: [Ecran Trait] Tableaux de pmfm (utilisation BeanComboBox) + am?\195?\169lioration code
clean code
improve table api (add isRowValid method on handler (should be implemented on each table)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.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/cruise/EditCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
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/EditFishingOperationUIHandler.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/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.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/split/SplitSampleCategoryUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx
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/GearShootingTabUIModel.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/HydrologyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
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/CaracteristicRow.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 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -38,6 +38,7 @@
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXDatePicker;
@@ -165,12 +166,16 @@
List<E> data,
E selectedData) {
+ Preconditions.checkNotNull(comboBox, "No comboBox!");
+
Class<E> beanType = (Class<E>) comboBox.getHandler().getTargetClass();
+ Preconditions.checkNotNull(beanType, "No beanType on the combobox!");
+
Decorator<E> decorator = getDecorator(beanType, null);
if (log.isInfoEnabled()) {
- log.info("entity list [" + beanType.getName() + "] : " +
+ log.info("entity comboBox list [" + beanType.getName() + "] : " +
(data == null ? 0 : data.size()));
}
@@ -296,7 +301,6 @@
if (DecoratorService.LabelAware.class.isAssignableFrom(type)) {
decorator = getDecorator(DecoratorService.LabelAware.class, null);
-
}
}
Preconditions.checkNotNull(decorator);
@@ -336,7 +340,6 @@
});
}
-
protected void listModelIsModify(AbstractTuttiBeanUIModel model) {
model.addPropertyChangeListener(new PropertyChangeListener() {
@@ -352,4 +355,13 @@
}
});
}
+
+ protected <B> void selectFirstInCombo(BeanComboBox<B> combo) {
+ List<B> data = combo.getData();
+ B selectedItem = null;
+ if (CollectionUtils.isNotEmpty(data)) {
+ selectedItem = data.get(0);
+ }
+ combo.setSelectedItem(selectedItem);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -110,7 +110,7 @@
List<Person> users = persistenceService.getAllPerson();
- EditCruiseUIModel model = ui.getModel();
+ EditCruiseUIModel model = getModel();
initBeanComboBox(ui.getSurveyComboBox(),
persistenceService.getAllProgram(),
@@ -161,7 +161,7 @@
public void save() {
- EditCruiseUIModel model = ui.getModel();
+ EditCruiseUIModel model = getModel();
Cruise bean = model.toBean();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -136,7 +136,7 @@
@Override
public void afterInitUI() {
- SelectCruiseUIModel model = ui.getModel();
+ SelectCruiseUIModel model = getModel();
initBeanComboBox(ui.getProgramCombobox(),
model.getPrograms(),
@@ -198,7 +198,7 @@
@Override
public void onCloseUI() {
- PropertyChangeListener[] listeners = ui.getModel().getPropertyChangeListeners();
+ PropertyChangeListener[] listeners = getModel().getPropertyChangeListeners();
for (PropertyChangeListener listener : listeners) {
getModel().removePropertyChangeListener(listener);
}
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -68,8 +68,6 @@
protected abstract void saveSelectedRowIfRequired();
- protected abstract boolean isRowValid(R row);
-
protected abstract void saveRow(R row);
protected abstract FishingOperation getFishingOperation();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -162,7 +162,7 @@
ui.getFishingOperationValidPanel().remove(
ui.getFishingOperationResetRadio());
- final EditFishingOperationUIModel model = ui.getModel();
+ final EditFishingOperationUIModel model = getModel();
initUI(ui);
@@ -174,17 +174,17 @@
//
// public void intervalAdded(ListDataEvent e) {
// log.info(">>>>>>>>>> intervalAdded " + saisisseurModel.getSelected());
-// ui.getModel().setSaisisseur(saisisseurModel.getSelected());
+// getModel().setSaisisseur(saisisseurModel.getSelected());
// }
//
// public void intervalRemoved(ListDataEvent e) {
// log.info(">>>>>>>>>> intervalRemoved " + saisisseurModel.getSelected());
-// ui.getModel().setSaisisseur(saisisseurModel.getSelected());
+// getModel().setSaisisseur(saisisseurModel.getSelected());
// }
//
// public void contentsChanged(ListDataEvent e) {
// log.info(">>>>>>>>>> contentsChanged " + saisisseurModel.getSelected());
-// ui.getModel().setSaisisseur(saisisseurModel.getSelected());
+// getModel().setSaisisseur(saisisseurModel.getSelected());
// }
// });
@@ -249,7 +249,7 @@
}
);
CaracteristicMap gearShootingCaracteristics = model.getGearShootingCaracteristics();
- ui.getModel().setGearShootingCaracteristics(gearShootingCaracteristics);
+ getModel().setGearShootingCaracteristics(gearShootingCaracteristics);
gearShootingModel.setGearShootingCaracteristics(gearShootingCaracteristics);
//init environment
@@ -266,7 +266,7 @@
}
);
CaracteristicMap environmentCaracteristics = model.getEnvironmentCaracteristics();
- ui.getModel().setEnvironmentCaracteristics(environmentCaracteristics);
+ getModel().setEnvironmentCaracteristics(environmentCaracteristics);
environmentModel.setEnvironmentCaracteristics(environmentCaracteristics);
//init hydrology
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -43,8 +43,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
import java.util.List;
import static org.nuiton.i18n.I18n.n_;
@@ -99,64 +97,7 @@
return getModel().getFishingOperation();
}
- @Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
- {
- // Species (by code) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
-
- addComboDataColumnToModel(columnModel,
- AccidentalBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
- }
-
- {
- // Species (by genusCode) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_GENUS);
-
- addComboDataColumnToModel(columnModel,
- AccidentalBatchTableModel.SPECIES_BY_GENUS_CODE,
- decorator, allSpecies);
-
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- AccidentalBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- LongTextCellComponent.newEditor(ui.getLongTextEditor()),
- LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
- AccidentalBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- AccidentalBatchTableModel.ATTACHMENTS);
- }
- return columnModel;
- }
-
@Override
protected void onRowModified(AccidentalBatchRowModel row,
String propertyName,
@@ -328,8 +269,59 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ AccidentalBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ AccidentalBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ AccidentalBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditor()),
+ LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
+ AccidentalBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
+ AttachmentCellComponent.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none")),
+ AccidentalBatchTableModel.ATTACHMENTS);
+ }
+
// create table model
AccidentalBatchTableModel tableModel =
new AccidentalBatchTableModel(columnModel);
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -43,8 +43,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
import java.util.List;
import static org.nuiton.i18n.I18n.n_;
@@ -103,94 +101,7 @@
return getModel().getFishingOperation();
}
-// @Override
-// protected String[] getRowPropertiesToIgnore() {
-// return new String[]{
-// BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
-// BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO
-// };
-// }
-
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
- {
- // Species (by code) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
-
- addComboDataColumnToModel(columnModel,
- BenthosBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
- }
-
- {
- // Species (by genusCode) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_GENUS);
-
- addComboDataColumnToModel(columnModel,
- BenthosBatchTableModel.SPECIES_BY_GENUS_CODE,
- decorator, allSpecies);
-
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- BenthosBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Number column
-
- addIntegerColumnToModel(columnModel,
- BenthosBatchTableModel.NUMBER,
- TuttiUI.INT_3_DIGITS_PATTERN);
- }
-
- { // Sample weight column
-
- addFloatColumnToModel(columnModel,
- BenthosBatchTableModel.SAMPLE_WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- LongTextCellComponent.newEditor(ui.getLongTextEditor()),
- LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
- BenthosBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- BenthosBatchTableModel.ATTACHMENTS);
- }
-
- { // Species to confirm column
-
- addBooleanColumnToModel(columnModel,
- BenthosBatchTableModel.SPECIES_TO_CONFIRM,
- getTable());
- }
- return columnModel;
- }
-
- @Override
protected void onRowModified(BenthosBatchRowModel row,
String propertyName,
Object oldValue,
@@ -364,8 +275,81 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ BenthosBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Number column
+
+ addIntegerColumnToModel(columnModel,
+ BenthosBatchTableModel.NUMBER,
+ TuttiUI.INT_3_DIGITS_PATTERN);
+ }
+
+ { // Sample weight column
+
+ addFloatColumnToModel(columnModel,
+ BenthosBatchTableModel.SAMPLE_WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditor()),
+ LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
+ BenthosBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
+ AttachmentCellComponent.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none")),
+ BenthosBatchTableModel.ATTACHMENTS);
+ }
+
+ { // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
// create table model
BenthosBatchTableModel tableModel =
new BenthosBatchTableModel(columnModel);
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -42,8 +42,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
import java.util.List;
import static org.nuiton.i18n.I18n.n_;
@@ -100,68 +98,6 @@
}
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- {
- // MacroWaste Category column
-
- Decorator<CaracteristicQualitativeValue> decorator = getDecorator(
- CaracteristicQualitativeValue.class, null);
-
- addComboDataColumnToModel(columnModel,
- MacroWasteBatchTableModel.MACRO_WASTE_CATEGORY,
- decorator, persistenceService.getMacroWasteCategoryCaracteristic().getQualitativeValue());
- }
-
- {
- // MacroWaste Size Category column
-
- Decorator<CaracteristicQualitativeValue> decorator = getDecorator(
- CaracteristicQualitativeValue.class, null);
-
- addComboDataColumnToModel(columnModel,
- MacroWasteBatchTableModel.MACRO_WASTE_SIZE_CATEGORY,
- decorator, persistenceService.getMacroWasteSizeCategoryCaracteristic().getQualitativeValue());
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- MacroWasteBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Number column
-
- addIntegerColumnToModel(columnModel,
- MacroWasteBatchTableModel.NUMBER,
- TuttiUI.INT_3_DIGITS_PATTERN);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- LongTextCellComponent.newEditor(ui.getLongTextEditor()),
- LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
- MacroWasteBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- MacroWasteBatchTableModel.ATTACHMENTS);
- }
- return columnModel;
- }
-
- @Override
protected void onRowModified(MacroWasteBatchRowModel row,
String propertyName,
Object oldValue,
@@ -334,8 +270,63 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ {
+ // MacroWaste Category column
+
+ Decorator<CaracteristicQualitativeValue> decorator = getDecorator(
+ CaracteristicQualitativeValue.class, null);
+
+ addComboDataColumnToModel(columnModel,
+ MacroWasteBatchTableModel.MACRO_WASTE_CATEGORY,
+ decorator, persistenceService.getMacroWasteCategoryCaracteristic().getQualitativeValue());
+ }
+
+ {
+ // MacroWaste Size Category column
+
+ Decorator<CaracteristicQualitativeValue> decorator = getDecorator(
+ CaracteristicQualitativeValue.class, null);
+
+ addComboDataColumnToModel(columnModel,
+ MacroWasteBatchTableModel.MACRO_WASTE_SIZE_CATEGORY,
+ decorator, persistenceService.getMacroWasteSizeCategoryCaracteristic().getQualitativeValue());
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ MacroWasteBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Number column
+
+ addIntegerColumnToModel(columnModel,
+ MacroWasteBatchTableModel.NUMBER,
+ TuttiUI.INT_3_DIGITS_PATTERN);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditor()),
+ LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
+ MacroWasteBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
+ AttachmentCellComponent.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none")),
+ MacroWasteBatchTableModel.ATTACHMENTS);
+ }
+
// create table model
MacroWasteBatchTableModel tableModel =
new MacroWasteBatchTableModel(columnModel);
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -43,8 +43,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
import java.util.List;
import static org.nuiton.i18n.I18n.n_;
@@ -99,84 +97,7 @@
return getModel().getFishingOperation();
}
-// @Override
-// protected String[] getRowPropertiesToIgnore() {
-// return new String[]{
-// PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
-// PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO
-// };
-// }
-
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
- { // Species (by code) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
-
- addComboDataColumnToModel(columnModel,
- PlanktonBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
- }
-
- { // Species (by genusCode) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_GENUS);
-
- addComboDataColumnToModel(columnModel,
- PlanktonBatchTableModel.SPECIES_BY_GENUS_CODE,
- decorator, allSpecies);
-
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- PlanktonBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Sample weight column
-
- addColumnToModel(columnModel,
- PlanktonBatchTableModel.SAMPLE_WEIGHT);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- LongTextCellComponent.newEditor(ui.getLongTextEditor()),
- LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
- PlanktonBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- PlanktonBatchTableModel.ATTACHMENTS);
- }
-
- { // Species to confirm column
-
- addBooleanColumnToModel(columnModel,
- PlanktonBatchTableModel.SPECIES_TO_CONFIRM,
- getTable());
- }
- return columnModel;
- }
-
- @Override
protected void onRowModified(PlanktonBatchRowModel row,
String propertyName,
Object oldValue,
@@ -348,8 +269,70 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ { // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ { // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ PlanktonBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Sample weight column
+
+ addColumnToModel(columnModel,
+ PlanktonBatchTableModel.SAMPLE_WEIGHT);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditor()),
+ LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
+ PlanktonBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
+ AttachmentCellComponent.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none")),
+ PlanktonBatchTableModel.ATTACHMENTS);
+ }
+
+ { // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
// create table model
PlanktonBatchTableModel tableModel =
new PlanktonBatchTableModel(columnModel);
Added: 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 (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -0,0 +1,49 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.service.DecoratorService;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * All sample category types.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public enum SampleCategoryType implements DecoratorService.LabelAware {
+ sortedUnsorted(
+ n_("tutti.sampleCategoryType.sortedUnsorted"),
+ SampleCategoryEnum.sortedUnsorted),
+ size(
+ n_("tutti.sampleCategoryType.size"),
+ SampleCategoryEnum.size),
+ sex(
+ n_("tutti.sampleCategoryType.sex"),
+ SampleCategoryEnum.sex),
+ maturity(
+ n_("tutti.sampleCategoryType.maturity"),
+ SampleCategoryEnum.maturity),
+ age(
+ n_("tutti.sampleCategoryType.age"),
+ SampleCategoryEnum.age);
+
+ private final String i18nKey;
+
+ private final SampleCategoryEnum type;
+
+ private SampleCategoryType(String i18nKey, SampleCategoryEnum type) {
+ this.i18nKey = i18nKey;
+ this.type = type;
+ }
+
+ @Override
+ public String getLabel() {
+ return _(i18nKey);
+ }
+
+ public SampleCategoryEnum getType() {
+ return type;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -98,53 +98,53 @@
public static final String PROPERTY_ATTACHMENTS = "attachments";
/**
- * Species observed.
+ * Is catch is vrac or horsVrac?.
*
* @since 0.2
*/
- protected Species species;
+ protected final SampleCategory<CaracteristicQualitativeValue> sortedUnsortedSampleCategory;
/**
- * Is the species need to be confirmed?.
+ * Weight category (can be null).
*
* @since 0.2
*/
- protected boolean speciesToConfirm;
+ protected final SampleCategory<CaracteristicQualitativeValue> sizeSampleCategory;
/**
- * Is catch is vrac or horsVrac?.
+ * Sex (can be null).
*
* @since 0.2
*/
- protected final SampleCategory<CaracteristicQualitativeValue> sortedUnsortedSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
+ protected final SampleCategory<CaracteristicQualitativeValue> sexSampleCategory;
/**
- * Weight category (can be null).
+ * Maturity (can be null).
*
* @since 0.2
*/
- protected final SampleCategory<CaracteristicQualitativeValue> sizeSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
+ protected final SampleCategory<CaracteristicQualitativeValue> maturitySampleCategory;
/**
- * Sex (can be null).
+ * Age (can be null).
*
* @since 0.2
*/
- protected final SampleCategory<CaracteristicQualitativeValue> sexSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
+ protected final SampleCategory<Float> ageSampleCategory;
/**
- * Maturity (can be null).
+ * Species observed.
*
* @since 0.2
*/
- protected final SampleCategory<CaracteristicQualitativeValue> maturitySampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
+ protected Species species;
/**
- * Age (can be null).
+ * Is the species need to be confirmed?.
*
* @since 0.2
*/
- protected final SampleCategory<Float> ageSampleCategory = new SampleCategory<Float>();
+ protected boolean speciesToConfirm;
/**
* Observed weight.
@@ -206,6 +206,11 @@
public SpeciesBatchRowModel() {
super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
frequency = Lists.newArrayList();
+ sortedUnsortedSampleCategory = SampleCategory.newSample(SampleCategoryType.sortedUnsorted);
+ sizeSampleCategory = SampleCategory.newSample(SampleCategoryType.size);
+ sexSampleCategory = SampleCategory.newSample(SampleCategoryType.sex);
+ maturitySampleCategory = SampleCategory.newSample(SampleCategoryType.maturity);
+ ageSampleCategory = SampleCategory.newSample(SampleCategoryType.age);
}
public SpeciesBatchRowModel(SpeciesBatch aBatch,
@@ -455,22 +460,4 @@
public SampleCategory<Float> getAgeSampleCategory() {
return ageSampleCategory;
}
-
- public boolean isRowValid() {
- boolean result = species != null;
- if (result) {
- result = weight != null;
-
- if (!result) {
-
- // No weight filled, so at least one sample category must be valid
- result = sortedUnsortedSampleCategory.isValid() ||
- sizeSampleCategory.isValid() ||
- sexSampleCategory.isValid() ||
- maturitySampleCategory.isValid() ||
- ageSampleCategory.isValid();
- }
- }
- return result;
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-29 20:50:48 UTC (rev 129)
@@ -29,6 +29,7 @@
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.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
@@ -80,9 +81,12 @@
<SpeciesFrequencyUI id='frequencyEditor' constructorParams='this'/>
+ <SplitSampleCategoryUI id='sampleCategoryEditor' constructorParams='this'/>
+
<LongTextEditorUI id='longTextEditor'/>
<AttachmentEditorUI id='attachmentEditor'/>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total / Poids total vrac -->
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -42,8 +42,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import javax.swing.JDialog;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
@@ -95,41 +93,6 @@
}
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
-
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
- { // LengthStep
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.LENGTH_STEP,
- TuttiUI.DECIMAL1_PATTERN);
- }
-
- { // Number
-
- addIntegerColumnToModel(columnModel,
- SpeciesFrequencyTableModel.NUMBER,
- TuttiUI.INT_6_DIGITS_PATTERN);
- }
-
- { // Weight
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // ComputedWeight
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.COMPUTED_WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
- return columnModel;
- }
-
- @Override
protected void onRowModified(SpeciesFrequencyRowModel row,
String propertyName,
Object oldValue,
@@ -153,6 +116,12 @@
Boolean newValue) {
}
+ @Override
+ protected boolean isRowValid(SpeciesFrequencyRowModel row) {
+ //TODO
+ return true;
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -186,8 +155,36 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+ { // LengthStep
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.LENGTH_STEP,
+ TuttiUI.DECIMAL1_PATTERN);
+ }
+
+ { // Number
+
+ addIntegerColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.NUMBER,
+ TuttiUI.INT_6_DIGITS_PATTERN);
+ }
+
+ { // Weight
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // ComputedWeight
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.COMPUTED_WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
// create table model
SpeciesFrequencyTableModel tableModel =
new SpeciesFrequencyTableModel(columnModel, model);
Modified: 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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -363,7 +363,7 @@
for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
newRow.setCategoryValue(qualitativeValue);
- tableModel.addNewRow(tableModel.getRowCount(), newRow);
+ tableModel.addNewRow(newRow);
}
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -27,24 +27,23 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import java.util.Map.Entry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.io.Serializable;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class EnvironmentRowModel extends AbstractTuttiBeanUIModel<CaracteristicRow, EnvironmentRowModel> {
-
- private static final Log log = LogFactory.getLog(EnvironmentRowModel.class);
-
+
+ private static final long serialVersionUID = 1L;
+
public static final String PROPERTY_KEY = "key";
+
public static final String PROPERTY_VALUE = "value";
-
+
protected static final Binder<CaracteristicRow, EnvironmentRowModel> fromBeanBinder =
BinderFactory.newBinder(CaracteristicRow.class,
EnvironmentRowModel.class);
@@ -52,20 +51,16 @@
protected static final Binder<EnvironmentRowModel, CaracteristicRow> toBeanBinder =
BinderFactory.newBinder(EnvironmentRowModel.class,
CaracteristicRow.class);
-
+
protected Caracteristic key;
-
- protected Object value;
+ protected Serializable value;
+
public EnvironmentRowModel() {
super(CaracteristicRow.class, fromBeanBinder, toBeanBinder);
}
-
- public EnvironmentRowModel(Caracteristic key) {
- this(key, null);
- }
-
- public EnvironmentRowModel(Caracteristic key, Object value) {
+
+ public EnvironmentRowModel(Caracteristic key, Serializable value) {
this();
this.key = key;
this.value = value;
@@ -81,14 +76,14 @@
firePropertyChange(PROPERTY_KEY, oldValue, key);
}
- public Object getValue() {
+ public Serializable getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(Serializable value) {
Object oldValue = getValue();
this.value = value;
firePropertyChange(PROPERTY_VALUE, oldValue, value);
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-29 20:50:48 UTC (rev 129)
@@ -21,6 +21,23 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
+BeanComboBox {
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+#newRowKey {
+ showReset: false;
+ property: selectedCaracteristic;
+ enabled: {!newRowKey.isEmpty()};
+}
+
+#addRow {
+ actionIcon: "add";
+ enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+}
+
#environmentTable {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx 2012-12-29 20:50:48 UTC (rev 129)
@@ -21,28 +21,34 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<EnvironmentTabUIModel, EnvironmentTabUIHandler>'>
-
+<Table
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<EnvironmentTabUIModel, EnvironmentTabUIHandler>'>
+
<import>
+ fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
+ fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+
org.jdesktop.swingx.JXTable
- fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
+
javax.swing.ListSelectionModel
java.awt.Color
</import>
-
+
<EnvironmentTabUIHandler id='handler'
- initializer='getContextValue(EnvironmentTabUIHandler.class)'/>
+ initializer='getContextValue(EnvironmentTabUIHandler.class)'/>
<EnvironmentTabUIModel id='model'
- initializer='getContextValue(EnvironmentTabUIModel.class)'/>
-
+ initializer='getContextValue(EnvironmentTabUIModel.class)'/>
+
<row fill='both'>
<cell fill='both' weightx='1'>
- <JComboBox id='newRowKey'/>
+ <BeanComboBox id='newRowKey' constructorParams='this'
+ genericType='CaracteristicRow'/>
</cell>
<cell fill='both'>
- <JButton id='addRow' actionIcon='add'
- onActionPerformed='handler.addRow()'/>
+ <JButton id='addRow' onActionPerformed='handler.addRow()'/>
</cell>
</row>
<row fill='both' weighty='1'>
@@ -65,5 +71,4 @@
}
]]></script>
-
</Table>
\ 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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -27,89 +27,73 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
-import java.util.Collection;
-import java.util.List;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
+import jaxx.runtime.swing.editor.bean.BeanComboBox;
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.event.ListSelectionListener;
+import java.util.Collection;
+import java.util.List;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class EnvironmentTabUIHandler extends AbstractTuttiTableUIHandler<EnvironmentRowModel, EnvironmentTabUIModel> {
private final static Log log = LogFactory.getLog(EnvironmentTabUIHandler.class);
-
- protected EnvironmentTabUI ui;
-
- public EnvironmentTabUIHandler(EditFishingOperationUI parentUi, EnvironmentTabUI ui) {
- super(parentUi.getHandler().getContext(), EnvironmentRowModel.PROPERTY_VALUE);
+
+ protected final EnvironmentTabUI ui;
+
+ public EnvironmentTabUIHandler(EditFishingOperationUI parentUi,
+ EnvironmentTabUI ui) {
+ super(parentUi.getHandler().getContext(),
+ EnvironmentRowModel.PROPERTY_VALUE);
this.ui = ui;
}
-
+
@Override
protected JXTable getTable() {
return ui.getEnvironmentTable();
}
@Override
- protected AbstractTuttiTableModel<EnvironmentRowModel> getTableModel() {
+ protected EnvironmentTableModel getTableModel() {
return (EnvironmentTableModel) getTable().getModel();
}
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
- {
-
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Caracteristic.class),
- EnvironmentTableModel.KEY);
- }
-
- {
-
- addColumnToModel(columnModel,
- new CaracteristicValueEditor(context),
- new CaracteristicValueRenderer(context),
- EnvironmentTableModel.VALUE);
- }
-
-
- return columnModel;
+ protected void onRowModified(EnvironmentRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
}
@Override
- protected void onRowModified(EnvironmentRowModel row, String propertyName, Object oldValue, Object newValue) {
+ protected void onRowValidStateChanged(EnvironmentRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowValidStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) {
+ protected void onRowModifyStateChanged(EnvironmentRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowModifyStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) {
+ protected boolean isRowValid(EnvironmentRowModel row) {
+ //TODO
+ return true;
}
@Override
@@ -121,61 +105,55 @@
@Override
public void afterInitUI() {
initUI(ui);
-
+
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+ {
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ EnvironmentTableModel.KEY);
+ }
+
+ {
+
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ EnvironmentTableModel.VALUE);
+ }
+
// create table model
EnvironmentTableModel tableModel =
new EnvironmentTableModel(columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- final JComboBox keyCombo = ui.getNewRowKey();
- keyCombo.setModel(new DefaultComboBoxModel());
-
- keyCombo.getModel().addListDataListener(new ListDataListener() {
- public void intervalAdded(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
- public void intervalRemoved(ListDataEvent e) {
- if (keyCombo.getItemCount() == 0) {
- keyCombo.setEnabled(false);
- ui.getAddRow().setEnabled(false);
- }
- }
-
- public void contentsChanged(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
- });
-
// modify the model when the user enters a value
ListSelectionListener listener = new TableRowModificationListener<EnvironmentRowModel>(
tableModel, getRowMonitor()) {
-
+
@Override
protected void saveSelectedRow() {
TuttiBeanMonitor<EnvironmentRowModel> monitor = getRowMonitor();
EnvironmentRowModel row = monitor.getBean();
if (row != null) {
- ui.getModel().setCaracteristic(row.getKey(), row.getValue());
+ getModel().setCaracteristic(row.getKey(), row.getValue());
}
}
};
table.getSelectionModel().addListSelectionListener(listener);
-
table.getTableHeader().setReorderingAllowed(false);
-
}
-
+
@Override
public void onCloseUI() {
}
@@ -184,52 +162,53 @@
protected EnvironmentTabUIModel getModel() {
return ui.getModel();
}
-
- /**
- * Adds a row with the parameter selected in the combo box
- */
+
+ /** Adds a row with the parameter selected in the combo box */
public void addRow() {
- JComboBox keyCombo = ui.getNewRowKey();
+ BeanComboBox<CaracteristicRow> keyCombo = ui.getNewRowKey();
CaracteristicRow selectedItem = (CaracteristicRow) keyCombo.getSelectedItem();
Caracteristic caracteristic = selectedItem.getCaracteristics()[0];
- EnvironmentRowModel row = new EnvironmentRowModel(caracteristic);
- getTableModel().addNewRow(getTable().getRowCount(), row);
- ui.getModel().setCaracteristic(caracteristic, null);
-
+ EnvironmentRowModel row = getTableModel().createNewRow();
+ row.setKey(caracteristic);
+ getTableModel().addNewRow(row);
+ getModel().setCaracteristic(caracteristic, null);
+
keyCombo.removeItem(selectedItem);
+ selectFirstInCombo(keyCombo);
}
-
- /**
- * Resets the table with the data from the database
- */
+
+ /** Resets the table with the data from the database */
public void reset() {
- CaracteristicMap environmentCaracteristics = ui.getModel().getEnvironmentCaracteristics();
+ EnvironmentTableModel tableModel = getTableModel();
+
+ EnvironmentTabUIModel model = getModel();
+
+ CaracteristicMap environmentCaracteristics = model.getEnvironmentCaracteristics();
if (environmentCaracteristics == null) {
environmentCaracteristics = new CaracteristicMap();
}
-
+
List<EnvironmentRowModel> rows = Lists.newArrayList();
Collection<Caracteristic> caracteristics = environmentCaracteristics.keySet();
for (Caracteristic key : environmentCaracteristics.keySet()) {
- rows.add(new EnvironmentRowModel(key, environmentCaracteristics.get(key)));
+ EnvironmentRowModel newRow = tableModel.createNewRow();
+ newRow.setKey(key);
+ newRow.setValue(environmentCaracteristics.get(key));
+ rows.add(newRow);
}
-
- AbstractTuttiTableModel<EnvironmentRowModel> tableModel = getTableModel();
+
tableModel.setRows(rows, false);
-
- JComboBox keyCombo = ui.getNewRowKey();
- DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel();
- keyComboModel.removeAllElements();
-
- List<Caracteristic> availableCaracteristics = ui.getModel().getAvailableCaracteristics();
- log.info(availableCaracteristics);
- for (Caracteristic caracteristic : availableCaracteristics) {
+
+ List<CaracteristicRow> caracteristicList = Lists.newArrayList();
+
+ for (Caracteristic caracteristic : model.getAvailableCaracteristics()) {
if (!caracteristics.contains(caracteristic)) {
CaracteristicRow row = new CaracteristicRow(caracteristic.getName(), caracteristic);
- keyComboModel.addElement(row);
+ caracteristicList.add(row);
}
}
- keyCombo.setEnabled(keyCombo.getItemCount() > 0);
+
+ ui.getNewRowKey().setData(caracteristicList);
+ selectFirstInCombo(ui.getNewRowKey());
}
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -24,30 +24,30 @@
* #L%
*/
-import java.util.List;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import com.google.common.collect.Maps;
-import java.util.Map;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
-import static org.nuiton.i18n.I18n._;
+import java.io.Serializable;
+import java.util.List;
/**
- *
* @author kmorin
* @since 0.3
*/
public class EnvironmentTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, EnvironmentRowModel, EnvironmentTabUIModel> {
-
+
+ private static final long serialVersionUID = 1L;
+
protected CaracteristicMap environmentCaracteristics = new CaracteristicMap();
-
+
protected List<Caracteristic> availableCaracteristics;
-
+
protected static final Binder<FishingOperation, EnvironmentTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, EnvironmentTabUIModel.class)
.toBinder();
@@ -68,20 +68,25 @@
}
this.environmentCaracteristics = environmentCaracteristics;
}
-
- public void setCaracteristic(Caracteristic caracteristic, Object value) {
+
+ public void setCaracteristic(Caracteristic caracteristic, Serializable value) {
Object oldValue = environmentCaracteristics.clone();
environmentCaracteristics.put(caracteristic, value);
firePropertyChange(EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_CARACTERISTICS, oldValue, environmentCaracteristics);
}
-
+
public List<Caracteristic> getAvailableCaracteristics() {
return availableCaracteristics;
}
-
+
public void setAvailableCaracteristics(List<Caracteristic> caracteristics) {
-// Object oldValue = availableCaracteristics;
availableCaracteristics = caracteristics;
-// firePropertyChange(EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_CARACTERISTICS, oldValue, availableCaracteristics);
}
+
+ //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
+
+ public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
+ }
+ //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
+
}
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -24,43 +24,39 @@
* #L%
*/
-import org.apache.commons.logging.Log;
-import com.google.common.base.Preconditions;
-import java.util.List;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
import javax.swing.table.TableColumnModel;
-import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n.n_;
/**
- *
* @author kmorin
- * since 0.3
+ * @since 0.3
*/
public class EnvironmentTableModel extends AbstractTuttiTableModel<EnvironmentRowModel> {
+ private static final long serialVersionUID = 1L;
+
public static final ColumnIdentifier<EnvironmentRowModel> KEY = ColumnIdentifier.newId(
EnvironmentRowModel.PROPERTY_KEY,
n_("tutti.table.fishing.environment.header.key"),
n_("tutti.table.fishing.environment.header.key"));
-
+
public static final ColumnIdentifier<EnvironmentRowModel> VALUE = ColumnIdentifier.newId(
EnvironmentRowModel.PROPERTY_VALUE,
n_("tutti.table.fishing.environment.header.value"),
n_("tutti.table.fishing.environment.header.value"));
-
+
public EnvironmentTableModel(TableColumnModel columnModel) {
super(columnModel);
-
setNoneEditableCols(KEY);
}
-
+
@Override
protected EnvironmentRowModel createNewRow() {
EnvironmentRowModel result = new EnvironmentRowModel();
return result;
}
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -27,23 +27,23 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.io.Serializable;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class GearShootingRowModel extends AbstractTuttiBeanUIModel<CaracteristicRow, GearShootingRowModel> {
-
- private static final Log log = LogFactory.getLog(GearShootingRowModel.class);
-
+
+ private static final long serialVersionUID = 1L;
+
public static final String PROPERTY_KEY = "key";
+
public static final String PROPERTY_VALUE = "value";
-
+
protected static final Binder<CaracteristicRow, GearShootingRowModel> fromBeanBinder =
BinderFactory.newBinder(CaracteristicRow.class,
GearShootingRowModel.class);
@@ -51,24 +51,14 @@
protected static final Binder<GearShootingRowModel, CaracteristicRow> toBeanBinder =
BinderFactory.newBinder(GearShootingRowModel.class,
CaracteristicRow.class);
-
+
protected Caracteristic key;
-
- protected Object value;
+ protected Serializable value;
+
public GearShootingRowModel() {
super(CaracteristicRow.class, fromBeanBinder, toBeanBinder);
}
-
- public GearShootingRowModel(Caracteristic key) {
- this(key, null);
- }
-
- public GearShootingRowModel(Caracteristic key, Object value) {
- this();
- this.key = key;
- this.value = value;
- }
public Caracteristic getKey() {
return key;
@@ -80,14 +70,14 @@
firePropertyChange(PROPERTY_KEY, oldValue, key);
}
- public Object getValue() {
+ public Serializable getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(Serializable value) {
Object oldValue = getValue();
this.value = value;
firePropertyChange(PROPERTY_VALUE, oldValue, value);
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-29 20:50:48 UTC (rev 129)
@@ -21,6 +21,23 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
+BeanComboBox {
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+#newRowKey {
+ showReset: false;
+ property: selectedCaracteristic;
+ enabled: {!newRowKey.isEmpty()};
+}
+
+#addRow {
+ actionIcon: "add";
+ enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+}
+
#gearShootingTable {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx 2012-12-29 20:50:48 UTC (rev 129)
@@ -21,24 +21,29 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<GearShootingTabUIModel, GearShootingTabUIHandler>'>
-
+<Table
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<GearShootingTabUIModel, GearShootingTabUIHandler>'>
+
<import>
+ fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
+ fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
org.jdesktop.swingx.JXTable
- fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
javax.swing.ListSelectionModel
java.awt.Color
</import>
-
+
<GearShootingTabUIHandler id='handler'
- initializer='getContextValue(GearShootingTabUIHandler.class)'/>
+ initializer='getContextValue(GearShootingTabUIHandler.class)'/>
<GearShootingTabUIModel id='model'
- initializer='getContextValue(GearShootingTabUIModel.class)'/>
-
+ initializer='getContextValue(GearShootingTabUIModel.class)'/>
+
<row fill='both'>
<cell fill='both' weightx='1'>
- <JComboBox id='newRowKey'/>
+ <BeanComboBox id='newRowKey' constructorParams='this'
+ genericType='CaracteristicRow'/>
</cell>
<cell fill='both'>
<JButton id='addRow' actionIcon='add'
@@ -65,5 +70,5 @@
}
]]></script>
-
+
</Table>
\ No newline at end of file
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -31,85 +31,67 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
-import java.util.Collection;
-import java.util.List;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
+import jaxx.runtime.swing.editor.bean.BeanComboBox;
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.event.ListSelectionListener;
+import java.util.Collection;
+import java.util.List;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class GearShootingTabUIHandler extends AbstractTuttiTableUIHandler<GearShootingRowModel, GearShootingTabUIModel> {
private final static Log log = LogFactory.getLog(GearShootingTabUIHandler.class);
-
- protected GearShootingTabUI ui;
-
+
+ protected final GearShootingTabUI ui;
+
public GearShootingTabUIHandler(EditFishingOperationUI parentUi, GearShootingTabUI ui) {
super(parentUi.getHandler().getContext(), GearShootingRowModel.PROPERTY_VALUE);
this.ui = ui;
}
-
+
@Override
protected JXTable getTable() {
return ui.getGearShootingTable();
}
@Override
- protected AbstractTuttiTableModel<GearShootingRowModel> getTableModel() {
+ protected GearShootingTableModel getTableModel() {
return (GearShootingTableModel) getTable().getModel();
}
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- {
-
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Caracteristic.class),
- GearShootingTableModel.KEY);
- }
-
- {
-
- addColumnToModel(columnModel,
- new CaracteristicValueEditor(context),
- new CaracteristicValueRenderer(context),
- GearShootingTableModel.VALUE);
- }
-
-
- return columnModel;
+ protected void onRowModified(GearShootingRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
}
@Override
- protected void onRowModified(GearShootingRowModel row, String propertyName, Object oldValue, Object newValue) {
+ protected void onRowValidStateChanged(GearShootingRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowValidStateChanged(GearShootingRowModel row, Boolean oldValue, Boolean newValue) {
+ protected void onRowModifyStateChanged(GearShootingRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowModifyStateChanged(GearShootingRowModel row, Boolean oldValue, Boolean newValue) {
+ protected boolean isRowValid(GearShootingRowModel row) {
+ //TODO
+ return true;
}
@Override
@@ -121,61 +103,56 @@
@Override
public void afterInitUI() {
initUI(ui);
-
+
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ {
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ GearShootingTableModel.KEY);
+ }
+
+ {
+
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ GearShootingTableModel.VALUE);
+ }
+
// create table model
GearShootingTableModel tableModel =
new GearShootingTableModel(columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- final JComboBox keyCombo = ui.getNewRowKey();
- keyCombo.setModel(new DefaultComboBoxModel());
-
- keyCombo.getModel().addListDataListener(new ListDataListener() {
- public void intervalAdded(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
- public void intervalRemoved(ListDataEvent e) {
- if (keyCombo.getItemCount() == 0) {
- keyCombo.setEnabled(false);
- ui.getAddRow().setEnabled(false);
- }
- }
-
- public void contentsChanged(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
- });
-
// modify the model when the user enters a value
ListSelectionListener listener = new TableRowModificationListener<GearShootingRowModel>(
tableModel, getRowMonitor()) {
-
+
@Override
protected void saveSelectedRow() {
TuttiBeanMonitor<GearShootingRowModel> monitor = getRowMonitor();
GearShootingRowModel row = monitor.getBean();
if (row != null) {
- ui.getModel().setCaracteristic(row.getKey(), row.getValue());
+ getModel().setCaracteristic(row.getKey(), row.getValue());
}
}
};
table.getSelectionModel().addListSelectionListener(listener);
-
table.getTableHeader().setReorderingAllowed(false);
-
}
-
+
@Override
public void onCloseUI() {
}
@@ -184,52 +161,53 @@
protected GearShootingTabUIModel getModel() {
return ui.getModel();
}
-
- /**
- * Adds a row with the parameter selected in the combo box
- */
+
+ /** Adds a row with the parameter selected in the combo box */
public void addRow() {
- JComboBox keyCombo = ui.getNewRowKey();
+ BeanComboBox<CaracteristicRow> keyCombo = ui.getNewRowKey();
CaracteristicRow selectedItem = (CaracteristicRow) keyCombo.getSelectedItem();
Caracteristic caracteristic = selectedItem.getCaracteristics()[0];
- GearShootingRowModel row = new GearShootingRowModel(caracteristic);
- getTableModel().addNewRow(getTable().getRowCount(), row);
- ui.getModel().setCaracteristic(caracteristic, null);
-
+ GearShootingRowModel row = getTableModel().createNewRow();
+ row.setKey(caracteristic);
+ getTableModel().addNewRow(row);
+ getModel().setCaracteristic(caracteristic, null);
+
keyCombo.removeItem(selectedItem);
+ selectFirstInCombo(keyCombo);
}
-
- /**
- * Resets the table with the data from the database
- */
+
+ /** Resets the table with the data from the database */
public void reset() {
- CaracteristicMap gearShootingCaracteristics = ui.getModel().getGearShootingCaracteristics();
+ GearShootingTableModel tableModel = getTableModel();
+ GearShootingTabUIModel model = getModel();
+
+ CaracteristicMap gearShootingCaracteristics = model.getGearShootingCaracteristics();
if (gearShootingCaracteristics == null) {
gearShootingCaracteristics = new CaracteristicMap();
}
-
+
List<GearShootingRowModel> rows = Lists.newArrayList();
Collection<Caracteristic> caracteristics = gearShootingCaracteristics.keySet();
for (Caracteristic key : gearShootingCaracteristics.keySet()) {
- rows.add(new GearShootingRowModel(key, gearShootingCaracteristics.get(key)));
+ GearShootingRowModel newRow = tableModel.createNewRow();
+ newRow.setKey(key);
+ newRow.setValue(gearShootingCaracteristics.get(key));
+ rows.add(newRow);
}
-
- AbstractTuttiTableModel<GearShootingRowModel> tableModel = getTableModel();
+
tableModel.setRows(rows, false);
-
- JComboBox keyCombo = ui.getNewRowKey();
- DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel();
- keyComboModel.removeAllElements();
-
- List<Caracteristic> availableCaracteristics = ui.getModel().getAvailableCaracteristics();
- log.info(availableCaracteristics);
- for (Caracteristic caracteristic : availableCaracteristics) {
+
+ List<CaracteristicRow> caracteristicList = Lists.newArrayList();
+
+ for (Caracteristic caracteristic : model.getAvailableCaracteristics()) {
if (!caracteristics.contains(caracteristic)) {
CaracteristicRow row = new CaracteristicRow(caracteristic.getName(), caracteristic);
- keyComboModel.addElement(row);
+ caracteristicList.add(row);
}
}
- keyCombo.setEnabled(keyCombo.getItemCount() > 0);
+
+ ui.getNewRowKey().setData(caracteristicList);
+ selectFirstInCombo(ui.getNewRowKey());
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -24,28 +24,32 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import java.util.List;
+import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
+import java.io.Serializable;
+import java.util.List;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class GearShootingTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, GearShootingRowModel, GearShootingTabUIModel> {
-
+
+ private static final long serialVersionUID = 1L;
+
protected CaracteristicMap gearShootingCaracteristics = new CaracteristicMap();
-
+
protected List<Caracteristic> availableCaracteristics;
-
+
protected static final Binder<FishingOperation, GearShootingTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, GearShootingTabUIModel.class)
.toBinder();
@@ -66,8 +70,8 @@
}
this.gearShootingCaracteristics = gearShootingCaracteristics;
}
-
- public void setCaracteristic(Caracteristic caracteristic, Object value) {
+
+ public void setCaracteristic(Caracteristic caracteristic, Serializable value) {
Object oldValue = Maps.newLinkedHashMap(gearShootingCaracteristics);
gearShootingCaracteristics.put(caracteristic, value);
firePropertyChange(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_CARACTERISTICS, oldValue, gearShootingCaracteristics);
@@ -80,5 +84,10 @@
public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) {
this.availableCaracteristics = availableCaracteristics;
}
-
+
+ //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
+
+ public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
+ }
+ //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -26,37 +26,38 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
import javax.swing.table.TableColumnModel;
import static org.nuiton.i18n.I18n.n_;
/**
- *
* @author kmorin
- * since 0.3
+ * @since 0.3
*/
public class GearShootingTableModel extends AbstractTuttiTableModel<GearShootingRowModel> {
+ private static final long serialVersionUID = 1L;
+
public static final ColumnIdentifier<GearShootingRowModel> KEY = ColumnIdentifier.newId(
GearShootingRowModel.PROPERTY_KEY,
n_("tutti.table.fishing.gearShooting.header.key"),
n_("tutti.table.fishing.gearShooting.header.key"));
-
+
public static final ColumnIdentifier<GearShootingRowModel> VALUE = ColumnIdentifier.newId(
GearShootingRowModel.PROPERTY_VALUE,
n_("tutti.table.fishing.gearShooting.header.value"),
n_("tutti.table.fishing.gearShooting.header.value"));
-
+
public GearShootingTableModel(TableColumnModel columnModel) {
super(columnModel);
-
setNoneEditableCols(KEY);
}
-
+
@Override
protected GearShootingRowModel createNewRow() {
GearShootingRowModel result = new GearShootingRowModel();
return result;
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -26,26 +26,27 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.io.Serializable;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class HydrologyRowModel extends AbstractTuttiBeanUIModel<Caracteristic, HydrologyRowModel> {
-
- private static final Log log = LogFactory.getLog(HydrologyRowModel.class);
-
+
+ private static final long serialVersionUID = 1L;
+
public static final String PROPERTY_KEY = "key";
+
public static final String PROPERTY_GEAR_SHOOTING_START_VALUE = "gearShootingStartValue";
+
public static final String PROPERTY_GEAR_SHOOTING_END_VALUE = "gearShootingEndValue";
+
public static final String PROPERTY_AVERAGE_VALUE = "averageValue";
-
+
protected static final Binder<Caracteristic, HydrologyRowModel> fromBeanBinder =
BinderFactory.newBinder(Caracteristic.class,
HydrologyRowModel.class);
@@ -53,25 +54,25 @@
protected static final Binder<HydrologyRowModel, Caracteristic> toBeanBinder =
BinderFactory.newBinder(HydrologyRowModel.class,
Caracteristic.class);
-
+
protected Caracteristic key;
-
- protected Object gearShootingStartValue;
-
- protected Object gearShootingEndValue;
-
- protected Object averageValue;
+ protected Serializable gearShootingStartValue;
+
+ protected Serializable gearShootingEndValue;
+
+ protected Serializable averageValue;
+
public HydrologyRowModel() {
super(Caracteristic.class, fromBeanBinder, toBeanBinder);
}
-
+
public HydrologyRowModel(Caracteristic key) {
this(key, null, null, null);
}
-
- public HydrologyRowModel(Caracteristic key, Object gearShootingStartValue,
- Object gearShootingEndValue, Object averageValue) {
+
+ public HydrologyRowModel(Caracteristic key, Serializable gearShootingStartValue,
+ Serializable gearShootingEndValue, Serializable averageValue) {
this();
this.key = key;
this.gearShootingStartValue = gearShootingStartValue;
@@ -89,34 +90,34 @@
firePropertyChange(PROPERTY_KEY, oldValue, key);
}
- public Object getGearShootingStartValue() {
+ public Serializable getGearShootingStartValue() {
return gearShootingStartValue;
}
- public void setGearShootingStartValue(Object gearShootingStartValue) {
+ public void setGearShootingStartValue(Serializable gearShootingStartValue) {
Object oldValue = getGearShootingStartValue();
this.gearShootingStartValue = gearShootingStartValue;
firePropertyChange(PROPERTY_GEAR_SHOOTING_START_VALUE, oldValue, gearShootingStartValue);
}
-
- public Object getGearShootingEndValue() {
+
+ public Serializable getGearShootingEndValue() {
return gearShootingEndValue;
}
- public void setGearShootingEndValue(Object gearShootingEndValue) {
+ public void setGearShootingEndValue(Serializable gearShootingEndValue) {
Object oldValue = getGearShootingEndValue();
this.gearShootingEndValue = gearShootingEndValue;
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_VALUE, oldValue, gearShootingEndValue);
}
-
- public Object getAverageValue() {
+
+ public Serializable getAverageValue() {
return averageValue;
}
- public void setAverageValue(Object averageValue) {
+ public void setAverageValue(Serializable averageValue) {
Object oldValue = getAverageValue();
this.averageValue = averageValue;
firePropertyChange(PROPERTY_AVERAGE_VALUE, oldValue, averageValue);
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-29 20:50:48 UTC (rev 129)
@@ -21,6 +21,23 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
+BeanComboBox {
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+#newRowKey {
+ showReset: false;
+ property: selectedCaracteristic;
+ enabled: {!newRowKey.isEmpty()};
+}
+
+#addRow {
+ actionIcon: "add";
+ enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+}
+
#hydrologyTable {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-29 20:50:48 UTC (rev 129)
@@ -24,8 +24,14 @@
<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'>
<import>
+ fr.ifremer.tutti.persistence.entities.referential.Caracteristic
+
+ fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+
org.jdesktop.swingx.JXTable
- fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
+
javax.swing.ListSelectionModel
java.awt.Color
</import>
@@ -38,11 +44,11 @@
<row fill='both'>
<cell fill='both' weightx='1'>
- <JComboBox id='newRowKey'/>
+ <BeanComboBox id='newRowKey' constructorParams='this'
+ genericType='Caracteristic'/>
</cell>
<cell fill='both'>
- <JButton id='addRow' actionIcon='add'
- onActionPerformed='handler.addRow()'/>
+ <JButton id='addRow' onActionPerformed='handler.addRow()'/>
</cell>
</row>
<row fill='both' weighty='1'>
@@ -63,7 +69,5 @@
protected void $afterCompleteSetup() {
handler.afterInitUI();
}
-
]]></script>
-
</Table>
\ No newline at end of file
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -34,118 +34,86 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.swing.editor.bean.BeanComboBox;
+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.event.ListSelectionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumnModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
/**
- *
* @author kmorin
* @since 0.3
*/
public class HydrologyTabUIHandler extends AbstractTuttiTableUIHandler<HydrologyRowModel, HydrologyTabUIModel> {
private final static Log log = LogFactory.getLog(HydrologyTabUIHandler.class);
-
- protected HydrologyTabUI ui;
-
+
+ protected final HydrologyTabUI ui;
+
protected Map<Caracteristic, Map<Type, Caracteristic>> availableCaracteristics;
-
- public HydrologyTabUIHandler(EditFishingOperationUI parentUi, HydrologyTabUI ui) {
- super(parentUi.getHandler().getContext(),
- HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE,
- HydrologyRowModel.PROPERTY_AVERAGE_VALUE,
- HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE
- );
+
+ public HydrologyTabUIHandler(EditFishingOperationUI parentUi,
+ HydrologyTabUI ui) {
+ super(parentUi.getHandler().getContext(),
+ HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE,
+ HydrologyRowModel.PROPERTY_AVERAGE_VALUE,
+ HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE
+ );
this.ui = ui;
}
-
+
@Override
protected JXTable getTable() {
return ui.getHydrologyTable();
}
@Override
- protected AbstractTuttiTableModel<HydrologyRowModel> getTableModel() {
+ protected HydrologyTableModel getTableModel() {
return (HydrologyTableModel) getTable().getModel();
}
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- {
-
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Caracteristic.class),
- HydrologyTableModel.KEY);
- }
-
- {
-
- addColumnToModel(columnModel,
- new CaracteristicValueEditor(context),
- new CaracteristicValueRenderer(context),
- HydrologyTableModel.GEAR_SHOOTING_START_VALUE);
- }
-
- {
-
- addColumnToModel(columnModel,
- new CaracteristicValueEditor(context),
- new CaracteristicValueRenderer(context),
- HydrologyTableModel.GEAR_SHOOTING_END_VALUE);
- }
-
- {
-
- addColumnToModel(columnModel,
- new CaracteristicValueEditor(context),
- new CaracteristicValueRenderer(context),
- HydrologyTableModel.AVERAGE_VALUE);
- }
-
-
- return columnModel;
+ protected void onRowModified(HydrologyRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
}
@Override
- protected void onRowModified(HydrologyRowModel row, String propertyName, Object oldValue, Object newValue) {
+ protected void onRowValidStateChanged(HydrologyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowValidStateChanged(HydrologyRowModel row, Boolean oldValue, Boolean newValue) {
+ protected void onRowModifyStateChanged(HydrologyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
}
@Override
- protected void onRowModifyStateChanged(HydrologyRowModel row, Boolean oldValue, Boolean newValue) {
+ protected boolean isRowValid(HydrologyRowModel row) {
+ //TODO
+ return true;
}
@Override
public void beforeInitUI() {
HydrologyTabUIModel model = new HydrologyTabUIModel();
ui.setContextValue(model);
-
+
model.addPropertyChangeListener(HydrologyTabUIModel.PROPERTY_AVAILABLE_CARACTERISTICS, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
@@ -171,46 +139,59 @@
@Override
public void afterInitUI() {
initUI(ui);
-
+
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ {
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ HydrologyTableModel.KEY);
+ }
+
+ {
+
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.GEAR_SHOOTING_START_VALUE);
+ }
+
+ {
+
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.GEAR_SHOOTING_END_VALUE);
+ }
+
+ {
+
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.AVERAGE_VALUE);
+ }
+
// create table model
HydrologyTableModel tableModel =
new HydrologyTableModel(columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- final JComboBox keyCombo = ui.getNewRowKey();
- keyCombo.setModel(new DefaultComboBoxModel());
- keyCombo.setRenderer(newListCellRender(Caracteristic.class));
- keyCombo.getModel().addListDataListener(new ListDataListener() {
- public void intervalAdded(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<Caracteristic>newArrayList(), null);
- public void intervalRemoved(ListDataEvent e) {
- if (keyCombo.getItemCount() == 0) {
- keyCombo.setEnabled(false);
- ui.getAddRow().setEnabled(false);
- }
- }
-
- public void contentsChanged(ListDataEvent e) {
- keyCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
- });
-
// modify the model when the user enters a value
ListSelectionListener listener = new TableRowModificationListener<HydrologyRowModel>(
tableModel, getRowMonitor()) {
-
+
@Override
protected void saveSelectedRow() {
TuttiBeanMonitor<HydrologyRowModel> monitor = getRowMonitor();
@@ -219,7 +200,7 @@
Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(row.getKey());
CaracteristicMap map = new CaracteristicMap();
for (Type type : caracteristics.keySet()) {
- Object value = null;
+ Serializable value = null;
switch (type) {
case START:
value = row.getGearShootingStartValue();
@@ -232,16 +213,15 @@
}
map.put(caracteristics.get(type), value);
}
- ui.getModel().addCaracteristics(map);
+ getModel().addCaracteristics(map);
}
}
};
table.getSelectionModel().addListSelectionListener(listener);
-
table.getTableHeader().setReorderingAllowed(false);
-
+
}
-
+
@Override
public void onCloseUI() {
}
@@ -250,67 +230,64 @@
protected HydrologyTabUIModel getModel() {
return ui.getModel();
}
-
- /**
- * Adds a row with the parameter selected in the combo box
- */
+
+ /** Adds a row with the parameter selected in the combo box */
public void addRow() {
- JComboBox keyCombo = ui.getNewRowKey();
+ BeanComboBox<Caracteristic> keyCombo = ui.getNewRowKey();
Caracteristic key = (Caracteristic) keyCombo.getSelectedItem();
- HydrologyRowModel row = new HydrologyRowModel(key);
- getTableModel().addNewRow(getTable().getRowCount(), row);
-
+ HydrologyRowModel row = getTableModel().createNewRow();
+ row.setKey(key);
+ getTableModel().addNewRow(row);
+
Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(key);
CaracteristicMap map = new CaracteristicMap();
for (Caracteristic caracteristic : caracteristics.values()) {
map.put(caracteristic, null);
}
- ui.getModel().addCaracteristics(map);
-
+ getModel().addCaracteristics(map);
+
keyCombo.removeItem(key);
+ selectFirstInCombo(keyCombo);
}
-
- /**
- * Resets the table with the data from the database
- */
+
+ /** Resets the table with the data from the database */
public void reset() {
- CaracteristicMap hydrologyCaracteristics = ui.getModel().getHydrologyCaracteristics();
- JComboBox keyCombo = ui.getNewRowKey();
- DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel();
- keyComboModel.removeAllElements();
-
+
+ HydrologyTableModel tableModel = getTableModel();
+
+ CaracteristicMap hydrologyCaracteristics = getModel().getHydrologyCaracteristics();
+
List<HydrologyRowModel> rows = Lists.newArrayList();
+ List<Caracteristic> caracteristicList = Lists.newArrayList();
+
Collection<Caracteristic> selectedCaracteristics = hydrologyCaracteristics.keySet();
Set<Caracteristic> globalCaracteristics = availableCaracteristics.keySet();
-
+
for (Caracteristic availableCaracteristic : globalCaracteristics) {
Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(availableCaracteristic);
-
+
//should add the global caracteristic to the combo or to the table?
boolean selectedCaracteristic = false;
- Caracteristic sample = null;
for (Caracteristic caracteristic : caracteristics.values()) {
- selectedCaracteristic = selectedCaracteristic || selectedCaracteristics.contains(caracteristic);
- sample = caracteristic;
+ selectedCaracteristic |= selectedCaracteristics.contains(caracteristic);
}
-
+
if (selectedCaracteristic) {
- HydrologyRowModel row = new HydrologyRowModel(availableCaracteristic,
- hydrologyCaracteristics.get(caracteristics.get(Type.START)),
- hydrologyCaracteristics.get(caracteristics.get(Type.END)),
- hydrologyCaracteristics.get(caracteristics.get(Type.AVERAGE)));
+ HydrologyRowModel row = tableModel.createNewRow();
+ row.setKey(availableCaracteristic);
+ row.setGearShootingStartValue(hydrologyCaracteristics.get(caracteristics.get(Type.START)));
+ row.setGearShootingEndValue(hydrologyCaracteristics.get(caracteristics.get(Type.END)));
+ row.setAverageValue(hydrologyCaracteristics.get(caracteristics.get(Type.AVERAGE)));
rows.add(row);
-
+
} else {
- keyComboModel.addElement(availableCaracteristic);
+ caracteristicList.add(availableCaracteristic);
}
}
-
- keyCombo.setEnabled(keyCombo.getItemCount() > 0);
-
- AbstractTuttiTableModel<HydrologyRowModel> tableModel = getTableModel();
+
tableModel.setRows(rows, false);
-
+ ui.getNewRowKey().setData(caracteristicList);
+ selectFirstInCombo(ui.getNewRowKey());
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -30,24 +30,26 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import java.util.List;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
+import java.util.List;
+
/**
- *
* @author kmorin
* @since 0.3
*/
public class HydrologyTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, HydrologyRowModel, HydrologyTabUIModel> {
-
+
+ private static final long serialVersionUID = 1L;
+
public static final String PROPERTY_AVAILABLE_CARACTERISTICS = "availableCaracteristics";
-
+
protected CaracteristicMap hydrologyCaracteristics = new CaracteristicMap();
-
+
protected List<Caracteristic> availableCaracteristics;
-
+
protected static final Binder<FishingOperation, HydrologyTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, HydrologyTabUIModel.class)
.toBinder();
@@ -68,7 +70,7 @@
}
this.hydrologyCaracteristics = hydrologyCaracteristics;
}
-
+
public void addCaracteristics(CaracteristicMap caracteristics) {
Object oldValue = Maps.newLinkedHashMap(hydrologyCaracteristics);
hydrologyCaracteristics.putAll(caracteristics);
@@ -84,5 +86,10 @@
this.availableCaracteristics = availableCaracteristics;
firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics);
}
-
+
+ //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
+
+ public void setSelectedCaracteristic(Caracteristic selectedCaracteristic) {
+ }
+ //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -26,47 +26,48 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
import javax.swing.table.TableColumnModel;
import static org.nuiton.i18n.I18n.n_;
/**
- *
* @author kmorin
- * since 0.3
+ * @since 0.3
*/
public class HydrologyTableModel extends AbstractTuttiTableModel<HydrologyRowModel> {
+ private static final long serialVersionUID = 1L;
+
public static final ColumnIdentifier<HydrologyRowModel> KEY = ColumnIdentifier.newId(
HydrologyRowModel.PROPERTY_KEY,
n_("tutti.table.fishing.hydrology.header.key"),
n_("tutti.table.fishing.hydrology.header.key"));
-
+
public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_START_VALUE = ColumnIdentifier.newId(
HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE,
n_("tutti.table.fishing.hydrology.header.gearShootingStartValue"),
n_("tutti.table.fishing.hydrology.header.gearShootingStartValue"));
-
+
public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_END_VALUE = ColumnIdentifier.newId(
HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE,
n_("tutti.table.fishing.hydrology.header.gearShootingEndValue"),
n_("tutti.table.fishing.hydrology.header.gearShootingEndValue"));
-
+
public static final ColumnIdentifier<HydrologyRowModel> AVERAGE_VALUE = ColumnIdentifier.newId(
HydrologyRowModel.PROPERTY_AVERAGE_VALUE,
n_("tutti.table.fishing.hydrology.header.averageValue"),
n_("tutti.table.fishing.hydrology.header.averageValue"));
-
+
public HydrologyTableModel(TableColumnModel columnModel) {
super(columnModel);
-
setNoneEditableCols(KEY);
}
-
+
@Override
protected HydrologyRowModel createNewRow() {
HydrologyRowModel result = new HydrologyRowModel();
return result;
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -97,7 +97,7 @@
@Override
public void afterInitUI() {
- EditProgramUIModel model = ui.getModel();
+ EditProgramUIModel model = getModel();
initBeanComboBox(ui.getZoneComboBox(),
persistenceService.getAllZone(),
model.getZone());
@@ -127,7 +127,7 @@
public void save() {
- EditProgramUIModel model = ui.getModel();
+ EditProgramUIModel model = getModel();
Program bean = model.toBean();
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -48,7 +48,6 @@
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
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;
@@ -302,7 +301,7 @@
// init species combo box
initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
- selectFirstSpecies(speciesList);
+ selectFirstInCombo(ui.getSpeciesComboBox());
// // Species
// final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
// speciesCombo.setRenderer(newListCellRender(Species.class));
@@ -402,7 +401,7 @@
public void save() {
- EditProtocolUIModel model = ui.getModel();
+ EditProtocolUIModel model = getModel();
TuttiProtocol bean = model.toBean();
@@ -457,13 +456,7 @@
protocol.setSpecies(species);
getTableModel().addNewRow(protocol);
ui.getSpeciesComboBox().removeItem(species);
- selectFirstSpecies(ui.getSpeciesComboBox().getData());
+ selectFirstInCombo(ui.getSpeciesComboBox());
// getModel().setModify(true);
}
-
- protected void selectFirstSpecies(List<Species> data) {
- if (CollectionUtils.isNotEmpty(data)) {
- ui.getSpeciesComboBox().setSelectedItem(data.get(0));
- }
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -185,10 +185,6 @@
//>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
- public Species getSelectedSpecies() {
- return null;
- }
-
public void setSelectedSpecies(Species selectedSpecies) {
}
//<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -152,7 +152,7 @@
// public void chooseFile() {
// if (fileChooser.showOpenDialog(ui) == JFileChooser.APPROVE_OPTION) {
// File file = fileChooser.getSelectedFile();
-// ui.getModel().setFile(file);
+// getModel().setFile(file);
// ui.getFile().setText(file.getAbsolutePath());
// }
// }
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -1,6 +1,30 @@
package fr.ifremer.tutti.ui.swing.util.editor;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.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/editor/CaracteristicValueRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -1,6 +1,30 @@
package fr.ifremer.tutti.ui.swing.util.editor;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.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/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -99,7 +99,7 @@
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
@@ -120,6 +120,11 @@
public final void addNewRow() {
R newValue = createNewRow();
+ addNewRow(newValue);
+ }
+
+ public final void addNewRow(R newValue) {
+
addNewRow(getRowCount(), 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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -86,8 +86,6 @@
protected abstract AbstractTuttiTableModel<R> getTableModel();
- protected abstract TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer);
-
protected abstract void onRowModified(R row,
String propertyName,
Object oldValue,
@@ -101,6 +99,7 @@
Boolean oldValue,
Boolean newValue);
+ protected abstract boolean isRowValid(R row);
protected String[] getRowPropertiesToIgnore() {
return ArrayUtils.EMPTY_STRING_ARRAY;
@@ -114,7 +113,7 @@
// listen when bean is changed
rowMonitor.addPropertyChangeListener(TuttiBeanMonitor.PROPERTY_BEAN, new PropertyChangeListener() {
-
+
final Set<String> propertiesToSkip =
Sets.newHashSet(getRowPropertiesToIgnore());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java 2012-12-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java 2012-12-29 20:50:48 UTC (rev 129)
@@ -25,16 +25,18 @@
*/
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.DecoratorService;
/**
- *
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
-public class CaracteristicRow {
-
+public class CaracteristicRow implements DecoratorService.LabelAware {
+
+ private static final long serialVersionUID = 1L;
+
protected Caracteristic[] caracteristics;
-
+
protected String name;
public CaracteristicRow(String name, Caracteristic... caracteristics) {
@@ -46,7 +48,7 @@
return caracteristics;
}
- public void setCaracteristics(Caracteristic[] caracteristics) {
+ public void setCaracteristics(Caracteristic... caracteristics) {
this.caracteristics = caracteristics;
}
@@ -59,8 +61,7 @@
}
@Override
- public String toString() {
+ public String getLabel() {
return name;
}
-
}
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-29 15:32:03 UTC (rev 128)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-29 20:50:48 UTC (rev 129)
@@ -110,6 +110,7 @@
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
tutti.label.protocol=Protocol de saisie
+tutti.label.sampleCategoryConfiguration.sample=Echantillon ?
tutti.label.tab.accidentel=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
@@ -132,6 +133,7 @@
tutti.legend.catch.species=Espèces
tutti.legend.catch.total=Capture
tutti.legend.frequencyConfiguration=Configuration
+tutti.legend.sampleCategoryConfiguration=Configuration
tutti.menu.actions=Actions
tutti.menu.actions.tip=Actions
tutti.menu.file=Fichier
@@ -146,6 +148,11 @@
tutti.menu.synchronisationImport.tip=Effectuer des imports
tutti.menu.synchronisations=Synchronisation
tutti.menu.synchronisations.tip=Import/Export
+tutti.sampleCategoryType.age=Age
+tutti.sampleCategoryType.maturity=Maturité
+tutti.sampleCategoryType.sex=Sexe
+tutti.sampleCategoryType.size=Class Tri.
+tutti.sampleCategoryType.sortedUnsorted=V/HV
tutti.table.accidental.batch.header.comment=Commentaire
tutti.table.accidental.batch.header.file=Pièces-jointes
tutti.table.accidental.batch.header.speciesByCode=Espèce
@@ -180,10 +187,11 @@
tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
tutti.table.plankton.batch.header.toConfirm=A Confirmer
tutti.table.plankton.batch.header.weight=Poids
+tutti.table.protocol.species.header.age=Age
+tutti.table.protocol.species.header.lengthStep=Classe de Taille
tutti.table.protocol.species.header.maturity=Maturité
tutti.table.protocol.species.header.sex=Sexe
-tutti.table.protocol.species.header.sizeCategory=Catégorie Taille
-tutti.table.protocol.species.header.sizeFrequency=Fréquence Taile
+tutti.table.protocol.species.header.size=Catégorie Tri
tutti.table.protocol.species.header.sortedUnsorted=Vrac / Hors Vrac
tutti.table.protocol.species.header.speciesId=Espèce
tutti.table.species.batch.header.age=Age
@@ -205,6 +213,8 @@
tutti.table.species.frequency.header.lengthStep=Classe de taille
tutti.table.species.frequency.header.number=Nombre
tutti.table.species.frequency.header.weight=Poids observé
+tutti.table.species.sampleCategory.header.category=Catégorie
+tutti.table.species.sampleCategory.header.weight=Poids
tutti.timeeditor.H=H
tutti.title.about=À propos de Tutti
tutti.title.create.cruise=Créer une nouvelle campagne
1
0
r128 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities
by tchemit@users.forge.codelutin.com 29 Dec '12
by tchemit@users.forge.codelutin.com 29 Dec '12
29 Dec '12
Author: tchemit
Date: 2012-12-29 16:32:03 +0100 (Sat, 29 Dec 2012)
New Revision: 128
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/128
Log:
caracteristic value are always serializable
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/CaracteristicMap.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/CaracteristicMap.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/CaracteristicMap.java 2012-12-29 14:58:26 UTC (rev 127)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/CaracteristicMap.java 2012-12-29 15:32:03 UTC (rev 128)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import java.io.Serializable;
import java.util.HashMap;
/**
@@ -34,6 +35,6 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class CaracteristicMap extends HashMap<Caracteristic, Object> {
+public class CaracteristicMap extends HashMap<Caracteristic, Serializable> {
private static final long serialVersionUID = 1L;
}
1
0
r127 - in trunk: tutti-persistence/src/main/xmi tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
by tchemit@users.forge.codelutin.com 29 Dec '12
by tchemit@users.forge.codelutin.com 29 Dec '12
29 Dec '12
Author: tchemit
Date: 2012-12-29 15:58:26 +0100 (Sat, 29 Dec 2012)
New Revision: 127
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/127
Log:
refs #1810: [PROTOCOLE] Ecran de saisie (improve code, add missing age property, use beanComboBox, ...)
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/protocol/
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java 2012-12-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java 2012-12-29 14:58:26 UTC (rev 127)
@@ -1,35 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-import fr.ifremer.tutti.persistence.entities.protocol.SampleCategoryEnum;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-
-/**
- * Column identifier containing the SampleCategoryEnum associated to the column
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.3
- */
-public class EditProtocolSpeciesColumnIdentifier extends ColumnIdentifier<EditProtocolSpeciesRowModel> {
-
- /** SampleCategoryEnum associated to the column. It is used to retain order of the columns */
- protected SampleCategoryEnum sampleCategory;
-
- protected EditProtocolSpeciesColumnIdentifier(String propertyName, String headerI18nKey, String headerTipI18nKey, SampleCategoryEnum sampleCategory) {
- super(propertyName, headerI18nKey, headerTipI18nKey);
- this.sampleCategory = sampleCategory;
- }
-
- public static EditProtocolSpeciesColumnIdentifier newId(String propertyName, String headerI18nKey, String headerTipI18nKey, SampleCategoryEnum sampleCategory) {
- return new EditProtocolSpeciesColumnIdentifier(propertyName, headerI18nKey, headerTipI18nKey, sampleCategory);
- }
-
- public SampleCategoryEnum getSampleCategory() {
- return sampleCategory;
- }
-
- public void setSampleCategory(SampleCategoryEnum sampleCategory) {
- this.sampleCategory = sampleCategory;
- }
-
-}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2012-12-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2012-12-29 14:58:26 UTC (rev 127)
@@ -28,45 +28,45 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
/**
- *
* @author kmorin
* @since 0.3
*/
public class EditProtocolSpeciesRowModel extends AbstractTuttiBeanUIModel<SpeciesProtocol, EditProtocolSpeciesRowModel> {
-
- private static final Log log = LogFactory.getLog(EditProtocolSpeciesRowModel.class);
-
+
+ private static final long serialVersionUID = 1L;
+
public static final String PROPERTY_SPECIES = "species";
public static final String PROPERTY_SORTED_UNSORTED_ENABLED = "sortedUnsortedEnabled";
- public static final String PROPERTY_SIZE_CATEGORY_ENABLED = "sizeCategoryEnabled";
+ public static final String PROPERTY_SIZE_ENABLED = "sizeEnabled";
public static final String PROPERTY_SEX_ENABLED = "sexEnabled";
public static final String PROPERTY_MATURITY_ENABLED = "maturityEnabled";
- public static final String PROPERTY_SIZE_FRENQUENCY_PMFM = "sizeFrenquencyPmfm";
+ public static final String PROPERTY_AGE_ENABLED = "ageEnabled";
+ public static final String PROPERTY_LENGTH_STEP_PMFM = "lengthStepPmfm";
+
protected Species species;
-
+
protected boolean sortedUnsortedEnabled;
- protected boolean sizeCategoryEnabled;
+ protected boolean sizeEnabled;
protected boolean sexEnabled;
protected boolean maturityEnabled;
- protected Caracteristic sizeFrenquencyPmfm;
-
+ protected boolean ageEnabled;
+
+ protected Caracteristic lengthStepPmfm;
+
protected static final Binder<SpeciesProtocol, EditProtocolSpeciesRowModel> fromBeanBinder =
BinderFactory.newBinder(SpeciesProtocol.class,
EditProtocolSpeciesRowModel.class);
@@ -74,13 +74,11 @@
protected static final Binder<EditProtocolSpeciesRowModel, SpeciesProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolSpeciesRowModel.class,
SpeciesProtocol.class);
-
- public EditProtocolSpeciesRowModel(Species species, Caracteristic sizeFrenquencyPmfm) {
+
+ public EditProtocolSpeciesRowModel() {
super(SpeciesProtocol.class, fromBeanBinder, toBeanBinder);
- this.species = species;
- this.sizeFrenquencyPmfm = sizeFrenquencyPmfm;
}
-
+
public String getSpeciesId() {
return species.getId();
}
@@ -88,7 +86,7 @@
public Species getSpecies() {
return species;
}
-
+
public void setSpecies(Species species) {
Object oldValue = getSpecies();
this.species = species;
@@ -105,14 +103,14 @@
firePropertyChange(PROPERTY_SORTED_UNSORTED_ENABLED, oldValue, sortedUnsortedEnabled);
}
- public boolean isSizeCategoryEnabled() {
- return sizeCategoryEnabled;
+ public boolean isSizeEnabled() {
+ return sizeEnabled;
}
- public void setSizeCategoryEnabled(boolean sizeCategoryEnabled) {
- Object oldValue = isSizeCategoryEnabled();
- this.sizeCategoryEnabled = sizeCategoryEnabled;
- firePropertyChange(PROPERTY_SIZE_CATEGORY_ENABLED, oldValue, sizeCategoryEnabled);
+ public void setSizeEnabled(boolean sizeEnabled) {
+ Object oldValue = isSizeEnabled();
+ this.sizeEnabled = sizeEnabled;
+ firePropertyChange(PROPERTY_SIZE_ENABLED, oldValue, sizeEnabled);
}
public boolean isSexEnabled() {
@@ -135,18 +133,27 @@
firePropertyChange(PROPERTY_MATURITY_ENABLED, oldValue, maturityEnabled);
}
- public String getSizeFrenquencyPmfmId() {
- return sizeFrenquencyPmfm != null ? sizeFrenquencyPmfm.getId() : null;
+ public boolean isAgeEnabled() {
+ return ageEnabled;
}
- public Caracteristic getSizeFrenquencyPmfm() {
- return sizeFrenquencyPmfm;
+ public void setAgeEnabled(boolean ageEnabled) {
+ Object oldValue = isAgeEnabled();
+ this.ageEnabled = ageEnabled;
+ firePropertyChange(PROPERTY_AGE_ENABLED, oldValue, ageEnabled);
}
-
- public void setSizeFrenquencyPmfm(Caracteristic sizeFrenquencyPmfm) {
- Object oldValue = getSizeFrenquencyPmfm();
- this.sizeFrenquencyPmfm = sizeFrenquencyPmfm;
- firePropertyChange(PROPERTY_SIZE_FRENQUENCY_PMFM, oldValue, sizeFrenquencyPmfm);
+
+ public String getLengthStepPmfmId() {
+ return lengthStepPmfm != null ? lengthStepPmfm.getId() : null;
}
-
+
+ public Caracteristic getLengthStepPmfm() {
+ return lengthStepPmfm;
+ }
+
+ public void setLengthStepPmfm(Caracteristic lengthStepPmfm) {
+ Object oldValue = getLengthStepPmfm();
+ this.lengthStepPmfm = lengthStepPmfm;
+ firePropertyChange(PROPERTY_LENGTH_STEP_PMFM, oldValue, lengthStepPmfm);
+ }
}
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-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-29 14:58:26 UTC (rev 127)
@@ -24,56 +24,54 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.protocol.SampleCategoryEnum;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
import javax.swing.table.TableColumnModel;
import static org.nuiton.i18n.I18n.n_;
/**
- *
* @author kmorin
- * since 0.3
+ * @since 0.3
*/
public class EditProtocolSpeciesTableModel extends AbstractTuttiTableModel<EditProtocolSpeciesRowModel> {
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SPECIES_ID = EditProtocolSpeciesColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SPECIES_ID = ColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SPECIES,
n_("tutti.table.protocol.species.header.speciesId"),
- n_("tutti.table.protocol.species.header.speciesId"),
- SampleCategoryEnum.speciesId);
+ n_("tutti.table.protocol.species.header.speciesId"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SORTED_UNSORTED_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SORTED_UNSORTED_ENABLED = ColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SORTED_UNSORTED_ENABLED,
n_("tutti.table.protocol.species.header.sortedUnsorted"),
- n_("tutti.table.protocol.species.header.sortedUnsorted"),
- SampleCategoryEnum.sortedUnsorted);
+ n_("tutti.table.protocol.species.header.sortedUnsorted"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_CATEGORY_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_SIZE_CATEGORY_ENABLED,
- n_("tutti.table.protocol.species.header.sizeCategory"),
- n_("tutti.table.protocol.species.header.sizeCategory"),
- SampleCategoryEnum.size);
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SIZE_ENABLED,
+ n_("tutti.table.protocol.species.header.size"),
+ n_("tutti.table.protocol.species.header.size"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = ColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SEX_ENABLED,
n_("tutti.table.protocol.species.header.sex"),
- n_("tutti.table.protocol.species.header.sex"),
- SampleCategoryEnum.sex);
+ n_("tutti.table.protocol.species.header.sex"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = ColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_MATURITY_ENABLED,
n_("tutti.table.protocol.species.header.maturity"),
- n_("tutti.table.protocol.species.header.maturity"),
- SampleCategoryEnum.maturity);
+ n_("tutti.table.protocol.species.header.maturity"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_FRENQUENCY_PMFM_ID = EditProtocolSpeciesColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_SIZE_FRENQUENCY_PMFM,
- n_("tutti.table.protocol.species.header.sizeFrequency"),
- n_("tutti.table.protocol.species.header.sizeFrequency"),
- SampleCategoryEnum.age);
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> AGE_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_AGE_ENABLED,
+ n_("tutti.table.protocol.species.header.age"),
+ n_("tutti.table.protocol.species.header.age"));
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_FRENQUENCY_PMFM_ID = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_LENGTH_STEP_PMFM,
+ n_("tutti.table.protocol.species.header.lengthStep"),
+ n_("tutti.table.protocol.species.header.lengthStep"));
+
private static final long serialVersionUID = 1L;
public EditProtocolSpeciesTableModel(TableColumnModel columnModel) {
@@ -81,11 +79,17 @@
setNoneEditableCols(SPECIES_ID);
}
-
+
@Override
protected EditProtocolSpeciesRowModel createNewRow() {
- EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel(null, null);
+ EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel();
+ result.setMaturityEnabled(true);
+ result.setSizeEnabled(true);
+ result.setSexEnabled(true);
+ result.setAgeEnabled(true);
+ result.setSortedUnsortedEnabled(true);
+ result.setValid(false);
return result;
}
-
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-29 14:58:26 UTC (rev 127)
@@ -21,12 +21,16 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
BeanComboBox {
- showReset: true;
i18nPrefix: "tutti.property.";
bean: {model};
}
+BeanDoubleList {
+ bean: {model};
+}
+
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
resizeWeight: 0.3;
@@ -82,6 +86,17 @@
model: {errorTableModel};
}
+#speciesComboBox {
+ showReset: false;
+ property: selectedSpecies;
+ enabled: {!speciesComboBox.isEmpty()};
+}
+
+#addRow {
+ actionIcon: "add";
+ enabled: {!speciesComboBox.isEmpty() && speciesComboBox.getSelectedItem() != null};
+}
+
#speciesTable {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
@@ -90,19 +105,19 @@
}
#gearList {
- bean: {model};
property: gearPmfm;
+ beanType: {Caracteristic.class};
border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.gearShooting"))};
}
#environmentList {
- bean: {model};
property: environmentPmfm;
+ beanType: {Caracteristic.class};
border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.environment"))};
}
#hydrologyList {
- bean: {model};
property: hydrologyPmfm;
+ beanType: {Caracteristic.class};
border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.hydrology"))};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-29 14:58:26 UTC (rev 127)
@@ -26,7 +26,7 @@
<import>
fr.ifremer.tutti.persistence.entities.referential.Caracteristic
- fr.ifremer.tutti.persistence.entities.referential.Zone
+ fr.ifremer.tutti.persistence.entities.referential.Species
fr.ifremer.tutti.ui.swing.TuttiUIContext
jaxx.runtime.swing.editor.bean.BeanComboBox
@@ -108,11 +108,11 @@
<Table fill='both'>
<row fill='both'>
<cell fill='both' weightx='1'>
- <JComboBox id='newSpeciesRowCombo'/>
+ <BeanComboBox id='speciesComboBox' constructorParams='this'
+ genericType='Species'/>
</cell>
<cell fill='both'>
- <JButton id='addRow' actionIcon='add'
- onActionPerformed='handler.addRow()'/>
+ <JButton id='addRow' onActionPerformed='handler.addRow()'/>
</cell>
</row>
<row fill='both' weighty='1'>
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-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-29 14:58:26 UTC (rev 127)
@@ -24,52 +24,48 @@
* #L%
*/
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.protocol.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TableColumnModelEvent;
-import javax.swing.event.TableColumnModelListener;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.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 org.nuiton.util.decorator.JXPathDecorator;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableColumnModelEvent;
+import javax.swing.event.TableColumnModelListener;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
/**
* TODO
*
@@ -95,17 +91,31 @@
* @since 0.3
*/
private final PersistenceService persistenceService;
-
+
protected Map<String, Species> allSpecies;
-
+
protected Map<String, Caracteristic> allLengthStepPmfm;
-
+
protected Multimap<String, String> hydroCaracteristics;
+ /**
+ * Mapping between columns and sample category
+ * (used to define the {@link TuttiProtocol#sampleCategoryOrder}).
+ *
+ * @since 0.3
+ */
+ private final BiMap<ColumnIdentifier<EditProtocolSpeciesRowModel>, SampleCategoryEnum> columToSampleCategory;
+
public EditProtocolUIHandler(TuttiUIContext context, EditProtocolUI ui) {
super(context);
this.ui = ui;
persistenceService = context.getService(PersistenceService.class);
+ columToSampleCategory = HashBiMap.create(SampleCategoryEnum.values().length);
+ columToSampleCategory.put(EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED, SampleCategoryEnum.sortedUnsorted);
+ columToSampleCategory.put(EditProtocolSpeciesTableModel.SIZE_ENABLED, SampleCategoryEnum.size);
+ columToSampleCategory.put(EditProtocolSpeciesTableModel.SEX_ENABLED, SampleCategoryEnum.sex);
+ columToSampleCategory.put(EditProtocolSpeciesTableModel.MATURITY_ENABLED, SampleCategoryEnum.maturity);
+ columToSampleCategory.put(EditProtocolSpeciesTableModel.AGE_ENABLED, SampleCategoryEnum.age);
}
@Override
@@ -119,81 +129,48 @@
}
@Override
- protected AbstractTuttiTableModel<EditProtocolSpeciesRowModel> getTableModel() {
- return (AbstractTuttiTableModel) getTable().getModel();
+ protected EditProtocolSpeciesTableModel getTableModel() {
+ return (EditProtocolSpeciesTableModel) getTable().getModel();
}
@Override
- protected void onRowModified(EditProtocolSpeciesRowModel row, String propertyName, Object oldValue, Object newValue) {
- log.info("onRowModified");
- ui.getModel().setModify(true);
+ protected void onRowModified(EditProtocolSpeciesRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("onRowModified property: " + propertyName +
+ ", newvalue: " + newValue);
+ }
+ boolean rowIsValid = isRowValid(row);
+ row.setValid(rowIsValid);
+ getModel().setModify(true);
}
@Override
- protected void onRowValidStateChanged(EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
- log.info("onRowValidStateChanged");
+ protected void onRowValidStateChanged(EditProtocolSpeciesRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("onRowValidStateChanged, newValidstate: " + newValue);
+ }
}
@Override
- protected void onRowModifyStateChanged(EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
- log.info("onRowModifyStateChanged");
+ protected void onRowModifyStateChanged(EditProtocolSpeciesRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("onRowModifyStateChanged, newModifiedState: " + newValue);
+ }
}
-
+
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer renderer) {
- JXTable table = ui.getSpeciesTable();
- DecoratorService decoratorService = context.getService(DecoratorService.class);
- JXPathDecorator<Caracteristic> decorator =
- (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
- EditProtocolUIModel model = ui.getModel();
- List<SampleCategoryEnum> sampleOrders = model.getSampleCategoryOrder();
- for (SampleCategoryEnum sampleOrder : sampleOrders) {
- switch (sampleOrder) {
- case speciesId:
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Species.class),
- EditProtocolSpeciesTableModel.SPECIES_ID);
- break;
-
- case sortedUnsorted:
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED,
- table);
- break;
-
- case size:
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SIZE_CATEGORY_ENABLED,
- table);
- break;
+ protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
+ boolean result = row.getLengthStepPmfm() != null;
+ return result;
+ }
- case sex:
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SEX_ENABLED,
- table);
- break;
-
- case maturity:
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.MATURITY_ENABLED,
- table);
- break;
-
- case age:
- addComboDataColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SIZE_FRENQUENCY_PMFM_ID,
- decorator,
- Lists.newArrayList(allLengthStepPmfm.values()));
-
- }
- }
-
- return columnModel;
- }
-
@Override
public void beforeInitUI() {
@@ -203,7 +180,7 @@
if (protocolId == null) {
// create new protocol
-
+
if (log.isDebugEnabled()) {
log.debug("Will create a new protocol");
}
@@ -218,23 +195,23 @@
log.debug("Will edit protocol: " + protocolId);
}
}
-
+
listModelIsModify(model);
ui.setContextValue(model);
-
+
List<Species> species = persistenceService.getAllSpecies();
allSpecies = Maps.newHashMap();
for (Species s : species) {
allSpecies.put(s.getId(), s);
}
-
- List<Caracteristic> lengthStepCaracteristics =
+
+ List<Caracteristic> lengthStepCaracteristics =
persistenceService.getAllSpeciesLengthStepCaracteristic();
allLengthStepPmfm = Maps.newHashMap();
for (Caracteristic c : lengthStepCaracteristics) {
allLengthStepPmfm.put(c.getId(), c);
}
-
+
List<Caracteristic> hydrologyPmfm = persistenceService.getAllFishingOperationHydrologicCaracteristic();
hydroCaracteristics = HashMultimap.create();
for (Caracteristic caracteristic : hydrologyPmfm) {
@@ -248,43 +225,39 @@
initUI(ui);
- EditProtocolUIModel model = ui.getModel();
+ EditProtocolUIModel model = getModel();
SwingValidatorUtil.installUI(ui.getErrorTable(),
new SwingValidatorMessageTableRenderer());
listenValidatorValid(ui.getValidator(), model);
-
- // Species
- final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
- speciesCombo.setRenderer(newListCellRender(Species.class));
- speciesCombo.setModel(new DefaultComboBoxModel());
- for (Species species : allSpecies.values()) {
- speciesCombo.addItem(species);
- }
- speciesCombo.getModel().addListDataListener(new ListDataListener() {
- public void intervalAdded(ListDataEvent e) {
- speciesCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
+ List<Species> speciesList = Lists.newArrayList(allSpecies.values());
- public void intervalRemoved(ListDataEvent e) {
- if (speciesCombo.getItemCount() == 0) {
- speciesCombo.setEnabled(false);
- ui.getAddRow().setEnabled(false);
- }
- }
+ // create table model
- public void contentsChanged(ListDataEvent e) {
- speciesCombo.setEnabled(true);
- ui.getAddRow().setEnabled(true);
- }
- });
-
- JXTable table = ui.getSpeciesTable();
- final TableColumnModel columnModel = createTableColumnModel(
- table.getDefaultRenderer(Object.class));
+ JXTable table = getTable();
+
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Species.class),
+ EditProtocolSpeciesTableModel.SPECIES_ID);
+
+ addComboDataColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SIZE_FRENQUENCY_PMFM_ID,
+ getDecorator(Caracteristic.class, null),
+ Lists.newArrayList(allLengthStepPmfm.values()));
+
+ Map<SampleCategoryEnum, ColumnIdentifier<EditProtocolSpeciesRowModel>> sampleCategoryToColumn = columToSampleCategory.inverse();
+
+ for (SampleCategoryEnum sampleOrder : model.getSampleCategoryOrder()) {
+
+ ColumnIdentifier<EditProtocolSpeciesRowModel> columnIdentifier = sampleCategoryToColumn.get(sampleOrder);
+ addBooleanColumnToModel(columnModel, columnIdentifier, table);
+ }
+
columnModel.addColumnModelListener(new TableColumnModelListener() {
public void columnAdded(TableColumnModelEvent e) {
@@ -294,11 +267,7 @@
}
public void columnMoved(TableColumnModelEvent e) {
- if (e.getFromIndex() != e.getToIndex()) {
- List<SampleCategoryEnum> sampleOrders = getModel().getSampleCategoryOrder();
- SampleCategoryEnum sampleOrder = sampleOrders.remove(e.getFromIndex());
- sampleOrders.add(e.getToIndex(), sampleOrder);
- }
+ getModel().setModify(true);
}
public void columnMarginChanged(ChangeEvent e) {
@@ -307,10 +276,12 @@
public void columnSelectionChanged(ListSelectionEvent e) {
}
});
-
+
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
-
+
+ // fill table model
+
List<SpeciesProtocol> speciesProtocol = model.getSpecies();
if (speciesProtocol == null) {
speciesProtocol = Lists.newArrayList();
@@ -318,25 +289,56 @@
List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
for (SpeciesProtocol protocol : speciesProtocol) {
Species species = allSpecies.get(protocol.getSpeciesId());
- speciesCombo.removeItem(species);
- EditProtocolSpeciesRowModel row = new EditProtocolSpeciesRowModel(
- species,
- allLengthStepPmfm.get(protocol.getSizeFrenquencyPmfmId()));
+ speciesList.remove(species);
+ EditProtocolSpeciesRowModel row = tableModel.createNewRow();
+ row.setSpecies(species);
+ row.setLengthStepPmfm(allLengthStepPmfm.get(protocol.getLengthStepPmfmId()));
row.fromBean(protocol);
rows.add(row);
}
tableModel.setRows(rows, false);
table.setModel(tableModel);
table.setColumnModel(columnModel);
+
+ // init species combo box
+ initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
+ selectFirstSpecies(speciesList);
+// // Species
+// final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
+// speciesCombo.setRenderer(newListCellRender(Species.class));
+// speciesCombo.setModel(new DefaultComboBoxModel());
+// for (Species species : allSpecies.values()) {
+// speciesCombo.addItem(species);
+// }
+// speciesCombo.getModel().addListDataListener(new ListDataListener() {
+//
+// public void intervalAdded(ListDataEvent e) {
+// speciesCombo.setEnabled(true);
+// ui.getAddRow().setEnabled(true);
+// }
+//
+// public void intervalRemoved(ListDataEvent e) {
+// if (speciesCombo.getItemCount() == 0) {
+// speciesCombo.setEnabled(false);
+// ui.getAddRow().setEnabled(false);
+// }
+// }
+//
+// public void contentsChanged(ListDataEvent e) {
+// speciesCombo.setEnabled(true);
+// ui.getAddRow().setEnabled(true);
+// }
+// });
+
ListSelectionListener listener = new TableRowModificationListener<EditProtocolSpeciesRowModel>(
tableModel, getRowMonitor()) {
-
+
@Override
protected void saveSelectedRow() {
TuttiBeanMonitor<EditProtocolSpeciesRowModel> monitor = getRowMonitor();
EditProtocolSpeciesRowModel row = monitor.getBean();
if (row != null && monitor.wasModified()) {
- ui.getModel().setModify(true);
+ getModel().setModify(true);
}
}
};
@@ -366,21 +368,16 @@
break;
}
}
- }
+ }
}
- DecoratorService decoratorService =
- context.getService(DecoratorService.class);
- JXPathDecorator<Caracteristic> decorator =
- (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
- ui.getHydrologyList().init(decorator, availableCaracteristics, selection);
-
+
+ initBeanList(ui.getHydrologyList(), availableCaracteristics, selection);
+
// if new protocol can already cancel his creation
model.setModify(model.isCreate());
-
- table.getTableHeader().setReorderingAllowed(true);
}
-
- protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
+
+ protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
List<Caracteristic> availableCaracteristics,
List<String> selectedCaracteristics) {
List<Caracteristic> selection = Lists.newArrayList();
@@ -389,13 +386,9 @@
if (selectedCaracteristics.contains(caracteristic.getId())) {
selection.add(caracteristic);
}
- }
+ }
}
- DecoratorService decoratorService =
- context.getService(DecoratorService.class);
- JXPathDecorator<Caracteristic> decorator =
- (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
- widget.init(decorator, availableCaracteristics, selection);
+ initBeanList(widget, availableCaracteristics, selection);
}
@Override
@@ -412,17 +405,17 @@
EditProtocolUIModel model = ui.getModel();
TuttiProtocol bean = model.toBean();
-
+
// get the species protocols from the table
List<SpeciesProtocol> protocols = Lists.newArrayList();
- List<EditProtocolSpeciesRowModel> rows =
- ((AbstractTuttiTableModel<EditProtocolSpeciesRowModel>)ui.getSpeciesTable().getModel()).getRows();
+ List<EditProtocolSpeciesRowModel> rows =
+ ((AbstractTuttiTableModel<EditProtocolSpeciesRowModel>) ui.getSpeciesTable().getModel()).getRows();
for (EditProtocolSpeciesRowModel row : rows) {
SpeciesProtocol protocol = row.toBean();
protocols.add(protocol);
}
bean.setSpecies(protocols);
-
+
// split the hydro grouped pmfm
List<String> hydroPmfm = bean.getHydrologyPmfmId();
List<String> allIds = Lists.newArrayList();
@@ -432,7 +425,19 @@
}
}
bean.setHydrologyPmfmId(allIds);
-
+
+ List<SampleCategoryEnum> sampleOrder = Lists.newArrayList();
+ TableColumnModel columnModel = getTable().getColumnModel();
+ for (int i = 0; i < columnModel.getColumnCount(); i++) {
+ TableColumn column = columnModel.getColumn(i);
+ ColumnIdentifier identifier = (ColumnIdentifier) column.getIdentifier();
+ SampleCategoryEnum sampleCategory = columToSampleCategory.get(identifier);
+ if (sampleCategory != null) {
+ sampleOrder.add(sampleCategory);
+ }
+ }
+ bean.setSampleCategoryOrder(sampleOrder);
+
TuttiProtocol saved;
if (TuttiEntities.isNew(bean)) {
@@ -445,18 +450,20 @@
context.setScreen(TuttiScreen.SELECT_CRUISE);
}
-
+
public void addRow() {
- JComboBox<Species> speciesCombo = ui.getNewSpeciesRowCombo();
- Species species = (Species) speciesCombo.getSelectedItem();
- EditProtocolSpeciesRowModel protocol = new EditProtocolSpeciesRowModel(species, null);
- protocol.setMaturityEnabled(true);
- protocol.setSizeCategoryEnabled(true);
- protocol.setSexEnabled(true);
- protocol.setSortedUnsortedEnabled(true);
-
- getTableModel().addNewRow(getTable().getRowCount(), protocol);
- speciesCombo.removeItem(species);
- ui.getModel().setModify(true);
+ Species species = (Species) ui.getSpeciesComboBox().getSelectedItem();
+ EditProtocolSpeciesRowModel protocol = getTableModel().createNewRow();
+ protocol.setSpecies(species);
+ getTableModel().addNewRow(protocol);
+ ui.getSpeciesComboBox().removeItem(species);
+ selectFirstSpecies(ui.getSpeciesComboBox().getData());
+// getModel().setModify(true);
}
+
+ protected void selectFirstSpecies(List<Species> data) {
+ if (CollectionUtils.isNotEmpty(data)) {
+ ui.getSpeciesComboBox().setSelectedItem(data.get(0));
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-29 14:56:58 UTC (rev 126)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-29 14:58:26 UTC (rev 127)
@@ -25,15 +25,17 @@
*/
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.protocol.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import java.util.List;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.List;
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
@@ -45,21 +47,21 @@
public static final String PROPERTY_COMMENT = "comment";
public static final String PROPERTY_NAME = "name";
-
+
public static final String PROPERTY_GEAR_PMFM_ID = "gearPmfmId";
public static final String PROPERTY_ENVIRONMENT_PMFM_ID = "environmentPmfmId";
public static final String PROPERTY_HYDROLOGY_PMFM_ID = "hydrologyPmfmId";
-
+
public static final String PROPERTY_SPECIES = "species";
-
+
public static final String PROPERTY_SAMPLE_CATEGORY_ORDER = "sampleCategoryOrder";
protected String name;
protected String comment;
-
+
protected List<String> gearPmfmId;
protected List<String> environmentPmfmId;
@@ -67,15 +69,14 @@
protected List<String> hydrologyPmfmId;
protected List<SpeciesProtocol> species;
-
+
protected List<SampleCategoryEnum> sampleCategoryOrder = Lists.newArrayList(
- SampleCategoryEnum.speciesId,
- SampleCategoryEnum.sortedUnsorted,
- SampleCategoryEnum.size,
- SampleCategoryEnum.sex,
- SampleCategoryEnum.maturity,
- SampleCategoryEnum.age);
-
+ SampleCategoryEnum.sortedUnsorted,
+ SampleCategoryEnum.size,
+ SampleCategoryEnum.sex,
+ SampleCategoryEnum.maturity,
+ SampleCategoryEnum.age);
+
protected static Binder<EditProtocolUIModel, TuttiProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolUIModel.class,
TuttiProtocol.class);
@@ -83,7 +84,6 @@
protected static Binder<TuttiProtocol, EditProtocolUIModel> fromBeanBinder =
BinderFactory.newBinder(TuttiProtocol.class, EditProtocolUIModel.class);
-
public EditProtocolUIModel() {
super(TuttiProtocol.class, fromBeanBinder, toBeanBinder);
}
@@ -117,13 +117,13 @@
this.gearPmfmId = gearPmfmId;
firePropertyChange(PROPERTY_GEAR_PMFM_ID, oldValue, gearPmfmId);
}
-
+
public void setGearPmfm(List<Caracteristic> gearPmfm) {
- List<String> gearPmfmId = Lists.newArrayList();
+ List<String> ids = Lists.newArrayList();
for (Caracteristic caracteristic : gearPmfm) {
- gearPmfmId.add(caracteristic.getId());
+ ids.add(caracteristic.getId());
}
- setGearPmfmId(gearPmfmId);
+ setGearPmfmId(ids);
}
public List<String> getEnvironmentPmfmId() {
@@ -135,13 +135,13 @@
this.environmentPmfmId = environmentPmfmId;
firePropertyChange(PROPERTY_ENVIRONMENT_PMFM_ID, oldValue, environmentPmfmId);
}
-
+
public void setEnvironmentPmfm(List<Caracteristic> environmentPmfm) {
- List<String> environmentPmfmId = Lists.newArrayList();
+ List<String> ids = Lists.newArrayList();
for (Caracteristic caracteristic : environmentPmfm) {
- environmentPmfmId.add(caracteristic.getId());
+ ids.add(caracteristic.getId());
}
- setEnvironmentPmfmId(environmentPmfmId);
+ setEnvironmentPmfmId(ids);
}
public List<String> getHydrologyPmfmId() {
@@ -155,13 +155,13 @@
}
public void setHydrologyPmfm(List<Caracteristic> hydrologyPmfm) {
- List<String> hydrologyPmfmId = Lists.newArrayList();
+ List<String> ids = Lists.newArrayList();
for (Caracteristic caracteristic : hydrologyPmfm) {
- hydrologyPmfmId.add(caracteristic.getId());
+ ids.add(caracteristic.getId());
}
- setHydrologyPmfmId(hydrologyPmfmId);
+ setHydrologyPmfmId(ids);
}
-
+
public List<SpeciesProtocol> getSpecies() {
return species;
}
@@ -171,7 +171,7 @@
this.species = species;
firePropertyChange(PROPERTY_SPECIES, oldValue, species);
}
-
+
public List<SampleCategoryEnum> getSampleCategoryOrder() {
return sampleCategoryOrder;
}
@@ -181,4 +181,15 @@
this.sampleCategoryOrder = sampleCategoryOrder;
firePropertyChange(PROPERTY_SAMPLE_CATEGORY_ORDER, oldValue, sampleCategoryOrder);
}
+
+
+ //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
+
+ public Species getSelectedSpecies() {
+ return null;
+ }
+
+ public void setSelectedSpecies(Species selectedSpecies) {
+ }
+ //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
\ No newline at end of file
1
0
r126 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species: . split
by tchemit@users.forge.codelutin.com 29 Dec '12
by tchemit@users.forge.codelutin.com 29 Dec '12
29 Dec '12
Author: tchemit
Date: 2012-12-29 15:56:58 +0100 (Sat, 29 Dec 2012)
New Revision: 126
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/126
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (package split)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/
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
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-29 14:55:51 UTC (rev 125)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -37,6 +37,13 @@
private static final long serialVersionUID = 1L;
/**
+ * Sample category type.
+ *
+ * @since 0.3
+ */
+ protected SampleCategoryType categoryType;
+
+ /**
* Sample category value.
*
* @since 0.3
@@ -50,6 +57,23 @@
*/
protected Float categoryWeight;
+ public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryType categoryType) {
+ SampleCategory<C> result = new SampleCategory<C>();
+ result.setCategoryType(categoryType);
+ return result;
+ }
+
+ protected SampleCategory() {
+ }
+
+ public SampleCategoryType getCategoryType() {
+ return categoryType;
+ }
+
+ public void setCategoryType(SampleCategoryType categoryType) {
+ this.categoryType = categoryType;
+ }
+
public C getCategoryValue() {
return categoryValue;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2012-12-29 14:55:51 UTC (rev 125)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -24,10 +24,23 @@
* #L%
*/
+import jaxx.runtime.swing.editor.NumberEditor;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.AbstractCellEditor;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.io.Serializable;
/**
@@ -45,4 +58,178 @@
public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator) {
return new SampleCategoryEditor<C>(decorator);
}
+
+ /**
+ * SampleCategory cell editor.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+ public static class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor
+ implements TableCellEditor, FocusListener, AncestorListener {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final NumberEditor numberEditor;
+
+ protected final JPanel editor;
+
+ protected final JLabel editorLabel;
+
+ protected final Decorator<C> categoryDecorator;
+
+ public SampleCategoryEditor(Decorator<C> categoryDecorator) {
+ this.categoryDecorator = categoryDecorator;
+ numberEditor = new NumberEditor();
+ numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
+ numberEditor.getTextField().setBorder(null);
+ numberEditor.getTextField().addFocusListener(this);
+ numberEditor.getTextField().addAncestorListener(this);
+ numberEditor.setModelType(Float.class);
+ numberEditor.setUseSign(false);
+ numberEditor.init();
+
+ editor = new JPanel(new BorderLayout());
+ editor.add(BorderLayout.WEST, editorLabel = new JLabel());
+ editor.add(BorderLayout.CENTER, numberEditor);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+
+ SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
+
+ C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue();
+ Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight();
+
+ numberEditor.setModel(number);
+
+ // Check nullity and set the text that will be selected with the current value
+ if (number == null) {
+ numberEditor.setModelText("");
+ } else {
+ numberEditor.setModelText(String.valueOf(number));
+ }
+
+ String label = sampleCategory == null ? "-" :
+ categoryDecorator.toString(categoryValue);
+
+ editorLabel.setText(label);
+ return editor;
+ }
+
+ @Override
+ public Float getCellEditorValue() {
+ return (Float) numberEditor.getModel();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean result = super.stopCellEditing();
+ // Reset previous data to avoid keeping it on other cell edition
+ if (result) {
+ resetEditor();
+ }
+ return result;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ resetEditor();
+ super.cancelCellEditing();
+ }
+
+ protected void resetEditor() {
+ numberEditor.setModel(null);
+ // Use empty string, otherwise there is a NPE in NumberEditorHandler
+ numberEditor.setModelText("");
+ editorLabel.setText("-");
+ }
+ }
+
+ /**
+ * To render a {@link SampleCategory} in a table cell.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+ public static class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer {
+
+ protected final TableCellRenderer delegate;
+
+ protected final Decorator<C> categoryDecorator;
+
+ public SampleCategoryRenderer(TableCellRenderer delegate,
+ Decorator<C> categoryDecorator) {
+ this.delegate = delegate;
+ this.categoryDecorator = categoryDecorator;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
+
+ String text = null;
+ if (sampleCategory != null) {
+ C categoryValue = sampleCategory.getCategoryValue();
+ Float number = sampleCategory.getCategoryWeight();
+
+ text = categoryDecorator.toString(categoryValue) + " / ";
+
+ if (number == null) {
+ text = "-";
+ } else {
+ text += number;
+ }
+ }
+
+ return delegate.getTableCellRendererComponent(table,
+ text,
+ isSelected,
+ hasFocus,
+ row,
+ column);
+ }
+ }
}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java 2012-12-29 14:55:51 UTC (rev 125)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -1,167 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import jaxx.runtime.swing.editor.NumberEditor;
-import org.nuiton.util.decorator.Decorator;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.table.TableCellEditor;
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.io.Serializable;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since TODO
- */
-public class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor
- implements TableCellEditor, FocusListener, AncestorListener {
-
- private static final long serialVersionUID = 1L;
-
- protected final NumberEditor numberEditor;
-
- protected final JPanel editor;
-
- protected final JLabel editorLabel;
-
- protected final Decorator<C> categoryDecorator;
-
- public SampleCategoryEditor(Decorator<C> categoryDecorator) {
- this.categoryDecorator = categoryDecorator;
- numberEditor = new NumberEditor();
- numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
- numberEditor.getTextField().setBorder(null);
- numberEditor.getTextField().addFocusListener(this);
- numberEditor.getTextField().addAncestorListener(this);
- numberEditor.setModelType(Float.class);
- numberEditor.setUseSign(false);
- numberEditor.init();
-
- editor = new JPanel(new BorderLayout());
- editor.add(BorderLayout.WEST, editorLabel = new JLabel());
- editor.add(BorderLayout.CENTER, numberEditor);
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table,
- Object value,
- boolean isSelected,
- int row,
- int column) {
-
- SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
-
- C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue();
- Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight();
-
- numberEditor.setModel(number);
-
- // Check nullity and set the text that will be selected with the current value
- if (number == null) {
- numberEditor.setModelText("");
- } else {
- numberEditor.setModelText(String.valueOf(number));
- }
-
- String label = sampleCategory == null ? "-" :
- categoryDecorator.toString(categoryValue);
-
- editorLabel.setText(label);
- return editor;
- }
-
- @Override
- public Float getCellEditorValue() {
- return (Float) numberEditor.getModel();
- }
-
- @Override
- public void focusGained(FocusEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- }
-
- @Override
- public void ancestorAdded(AncestorEvent event) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean result = super.stopCellEditing();
- // Reset previous data to avoid keeping it on other cell edition
- if (result) {
- resetEditor();
- }
- return result;
- }
-
- @Override
- public void cancelCellEditing() {
- resetEditor();
- super.cancelCellEditing();
- }
-
- protected void resetEditor() {
- numberEditor.setModel(null);
- // Use empty string, otherwise there is a NPE in NumberEditorHandler
- numberEditor.setModelText("");
- editorLabel.setText("-");
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java 2012-12-29 14:55:51 UTC (rev 125)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -1,82 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.util.decorator.Decorator;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-import java.io.Serializable;
-
-/**
- * To render a {@link SampleCategory} in a table cell.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer {
-
- protected final TableCellRenderer delegate;
-
- protected final Decorator<C> categoryDecorator;
-
- public SampleCategoryRenderer(TableCellRenderer delegate,
- Decorator<C> categoryDecorator) {
- this.delegate = delegate;
- this.categoryDecorator = categoryDecorator;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
- SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
-
- String text = null;
- if (sampleCategory != null) {
- C categoryValue = sampleCategory.getCategoryValue();
- Float number = sampleCategory.getCategoryWeight();
-
- text = categoryDecorator.toString(categoryValue) + " / ";
-
- if (number == null) {
- text = "-";
- } else {
- text += number;
- }
- }
-
- return delegate.getTableCellRendererComponent(table,
- text,
- isSelected,
- hasFocus,
- row,
- column);
- }
-}
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-29 14:55:51 UTC (rev 125)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -142,142 +142,14 @@
// compute row valid
for (SpeciesBatchRowModel row : rows) {
- boolean rowValid = row.isRowValid();
+ boolean rowValid = isRowValid(row);
row.setValid(rowValid);
}
// build the new sampling tree from the new rows to edit
// getModel().getSamplingTreeModel().populate(rows);
}
-// @Override
-// protected String[] getRowPropertiesToIgnore() {
-// return new String[]{
-// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
-// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO};
-// }
-
@Override
- protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
- getDecorator(CaracteristicQualitativeValue.class, null);
-
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
- { // Species (by code) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
- }
-
- { // Species (by genusCode) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_GENUS);
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE,
- decorator, allSpecies);
- }
-
- { // SortedUnsortedCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- { // SizeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SIZE_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- { // SexCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SEX_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- { // MaturityCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.MATURITY_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- { // AgeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.AGE_CATEGORY,
- getDecorator(Float.class, null),
- defaultRenderer);
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- SpeciesBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Computed weight column (from frequencies)
-
- addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
- FrequencyCellComponent.newRender(),
- SpeciesBatchTableModel.COMPUTED_WEIGHT);
- }
-
- { // Computed number column (from frequencies)
-
- addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
- FrequencyCellComponent.newRender(),
- SpeciesBatchTableModel.COMPUTED_NUMBER);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- LongTextCellComponent.newEditor(ui.getLongTextEditor()),
- LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
- SpeciesBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- SpeciesBatchTableModel.ATTACHMENTS);
- }
-
- { // Species to confirm column
-
- addBooleanColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_TO_CONFIRM,
- getTable());
- }
- return columnModel;
- }
-
- @Override
protected void onRowModified(SpeciesBatchRowModel row,
String propertyName,
Object oldValue,
@@ -295,14 +167,14 @@
if (SAMPLING_PROPERTIES.contains(propertyName)) {
// species has changed, recompute valid property
- boolean rowValid = row.isRowValid();
+ boolean rowValid = isRowValid(row);
row.setValid(rowValid);
}
if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
// weight has changed, recompute valid property
- boolean rowValid = row.isRowValid();
+ boolean rowValid = isRowValid(row);
row.setValid(rowValid);
}
@@ -444,13 +316,21 @@
@Override
protected boolean isRowValid(SpeciesBatchRowModel row) {
+ boolean result = row.getSpecies() != null;
+ if (result) {
+ result = row.getWeight() != null;
- SpeciesBatchUIModel model = getModel();
+ if (!result) {
- SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
- SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
- boolean rowValid = samplingTreeModel.isValid(row, node);
- return row.isValid();
+ // No weight filled, so at least one sample category must be valid
+ result = row.getSortedUnsortedSampleCategory().isValid() ||
+ row.getSizeSampleCategory().isValid() ||
+ row.getSexSampleCategory().isValid() ||
+ row.getMaturitySampleCategory().isValid() ||
+ row.getAgeSampleCategory().isValid();
+ }
+ }
+ return result;
}
@Override
@@ -574,8 +454,124 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+ TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class);
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
+ getDecorator(CaracteristicQualitativeValue.class, null);
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ { // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ { // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+ }
+
+ { // SortedUnsortedCategory column
+
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
+ }
+
+ { // SizeCategory column
+
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SIZE_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
+ }
+
+ { // SexCategory column
+
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SEX_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
+ }
+
+ { // MaturityCategory column
+
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.MATURITY_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
+ }
+
+ { // AgeCategory column
+
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.AGE_CATEGORY,
+ getDecorator(Float.class, null),
+ defaultRenderer);
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ SpeciesBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Computed weight column (from frequencies)
+
+ addColumnToModel(columnModel,
+ FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newRender(),
+ SpeciesBatchTableModel.COMPUTED_WEIGHT);
+ }
+
+ { // Computed number column (from frequencies)
+
+ addColumnToModel(columnModel,
+ FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newRender(),
+ SpeciesBatchTableModel.COMPUTED_NUMBER);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditor()),
+ LongTextCellComponent.newRender(n_("tutti.tooltip.comment.none")),
+ SpeciesBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
+ AttachmentCellComponent.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none")),
+ SpeciesBatchTableModel.ATTACHMENTS);
+ }
+
+ { // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
// create table model
SpeciesBatchTableModel tableModel =
new SpeciesBatchTableModel(columnModel);
Added: 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 (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,103 @@
+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.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 Float getCategoryValue() {
+ return category.getCategoryWeight();
+ }
+
+ public void setCategoryValue(Serializable 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
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.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/SplitSampleCategoryTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,73 @@
+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> 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();
+ }
+
+ @Override
+ protected SplitSampleCategoryRowModel createNewRow() {
+
+ SplitSampleCategoryRowModel result = new SplitSampleCategoryRowModel();
+ result.setCategoryType(uiModel.getSelectedCategory());
+ result.setValid(false);
+ return result;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.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/SplitSampleCategoryUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,63 @@
+/*
+ * #%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"))};
+}
+
+#categoryLabelLabel {
+ text: "tutti.label.sampleCategoryConfiguration.category";
+ labelFor: {categoryComboBox};
+}
+
+#categoryComboBox {
+ property: "selectedCategory";
+ selectedItem: {model.getSelectedCategory()};
+}
+
+#sampleCheckBox {
+ text: "tutti.label.sampleCategoryConfiguration.sample";
+ selected: {model.isSample()};
+}
+
+#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
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.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/SplitSampleCategoryUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,106 @@
+<!--
+ #%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'/>
+ </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>
+ </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>
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.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/SplitSampleCategoryUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,373 @@
+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.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.PersistenceService;
+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.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.JDialog;
+import javax.swing.table.DefaultTableModel;
+import java.awt.Color;
+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;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.3
+ */
+ protected final PersistenceService persistenceService;
+
+ public SplitSampleCategoryUIHandler(SpeciesBatchUI parentUi,
+ SplitSampleCategoryUI ui) {
+ super(parentUi.getHandler().getContext(),
+ SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
+ SplitSampleCategoryRowModel.PROPERTY_WEIGHT);
+ this.parentUi = parentUi;
+ this.ui = ui;
+ this.persistenceService = getContext().getService(PersistenceService.class);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SplitSampleCategoryUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected SplitSampleCategoryTableModel getTableModel() {
+ return (SplitSampleCategoryTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected void onRowModified(SplitSampleCategoryRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+
+ // Need to recompute the total weight
+ computeComputedWeight(row);
+ }
+ }
+
+ @Override
+ protected void onRowValidStateChanged(SplitSampleCategoryRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(SplitSampleCategoryRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected boolean isRowValid(SplitSampleCategoryRowModel row) {
+ //TODO
+ return true;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @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());
+
+ JXTable table = getTable();
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+ table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+
+ // when category changed, remove selected category
+ model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ getModel().setSelectedCategory(null);
+ }
+ });
+
+ // 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) {
+
+ SampleCategoryEnum newValue = (SampleCategoryEnum) evt.getNewValue();
+ generateTableModel(newValue);
+ }
+ });
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void editBatch(SpeciesBatchRowModel row) {
+
+ // get possible the last used
+ List<SampleCategoryType> categories =
+ Lists.newArrayList(SampleCategoryType.values());
+
+ //TODO Use the samplingOrder
+ SampleCategory<?> lastCategory = null;
+
+ if (row.getSortedUnsortedSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sortedUnsorted);
+ lastCategory = row.getSortedUnsortedSampleCategory();
+ }
+
+ if (row.getSizeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.size);
+ lastCategory = row.getSizeSampleCategory();
+ }
+
+ if (row.getSexSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sex);
+ lastCategory = row.getSexSampleCategory();
+ }
+
+ if (row.getMaturitySampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.maturity);
+ lastCategory = row.getMaturitySampleCategory();
+ }
+
+ if (row.getAgeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.age);
+ lastCategory = row.getAgeSampleCategory();
+ }
+
+ Float batchWeight = lastCategory == null ? null :
+ lastCategory.getCategoryWeight();
+
+ SplitSampleCategoryUIModel model = getModel();
+
+ model.setCategory(categories);
+
+ model.setBatchWeight(batchWeight);
+
+ // keep batch (will be used to push back editing entry)
+ model.setBatch(row);
+ }
+
+ public void close() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will close UI " + ui);
+ }
+
+ SplitSampleCategoryUIModel model = getModel();
+
+ // transfer rows to editor
+ List<SplitSampleCategoryRowModel> safeRows = Lists.newArrayList();
+ for (SplitSampleCategoryRowModel row : model.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ safeRows.add(row);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Push back " + safeRows.size() +
+ " rows to batch " + model.getBatch());
+ }
+ //TODO Create rows in batch table model
+
+ editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void computeComputedWeight(SplitSampleCategoryRowModel row) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will recompute computed weight for frequency: " + row);
+ }
+ }
+
+
+ protected void generateTableModel(SampleCategoryEnum category) {
+
+ if (category == null) {
+
+ getTable().setModel(new DefaultTableModel());
+ } else {
+
+ Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
+ getDecorator(CaracteristicQualitativeValue.class, null);
+
+ Caracteristic data = null;
+
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
+ 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:
+ addFloatColumnToModel(columnModel,
+ SplitSampleCategoryTableModel.CATEGORY_VALUE,
+ TuttiUI.DECIMAL1_PATTERN);
+ break;
+ }
+
+ if (data != null) {
+
+ addComboDataColumnToModel(columnModel,
+ SplitSampleCategoryTableModel.CATEGORY_VALUE,
+ caracteristicDecorator,
+ data.getQualitativeValue());
+ }
+ { // Weight
+
+ addFloatColumnToModel(columnModel,
+ SplitSampleCategoryTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ // create table model
+ SplitSampleCategoryTableModel tableModel =
+ new SplitSampleCategoryTableModel(columnModel, getModel());
+
+ JXTable table = getTable();
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ //TODO Fix this!
+// installTableKeyListener(columnModel, table);
+
+ if (data != null) {
+
+ // add a row for each qualitive value
+ for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
+ newRow.setCategoryValue(qualitativeValue);
+ tableModel.addNewRow(tableModel.getRowCount(), newRow);
+ }
+ }
+ }
+
+ }
+
+}
\ 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/SplitSampleCategoryUIHandler.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/SplitSampleCategoryUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2012-12-29 14:56:58 UTC (rev 126)
@@ -0,0 +1,157 @@
+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.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_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) {
+ this.batch = batch;
+ }
+
+ 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
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r125 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 29 Dec '12
by tchemit@users.forge.codelutin.com 29 Dec '12
29 Dec '12
Author: tchemit
Date: 2012-12-29 15:55:51 +0100 (Sat, 29 Dec 2012)
New Revision: 125
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/125
Log:
improve beanList init + add LabelAware in decorator
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.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/AbstractTuttiUIHandler.java 2012-12-29 14:50:59 UTC (rev 124)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2012-12-29 14:55:51 UTC (rev 125)
@@ -56,6 +56,7 @@
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -159,16 +160,14 @@
*
* @param comboBox le component graphique à initialiser
*/
- protected <E extends IdAware> void initBeanComboBox(
+ protected <E extends Serializable> void initBeanComboBox(
BeanComboBox<E> comboBox,
List<E> data,
E selectedData) {
Class<E> beanType = (Class<E>) comboBox.getHandler().getTargetClass();
- DecoratorService decoratorService =
- context.getService(DecoratorService.class);
- Decorator<E> decorator = decoratorService.getDecoratorByType(beanType);
+ Decorator<E> decorator = getDecorator(beanType, null);
if (log.isInfoEnabled()) {
log.info("entity list [" + beanType.getName() + "] : " +
@@ -199,7 +198,10 @@
List<E> data,
List<E> selectedData) {
+ Preconditions.checkNotNull(list, "No list!");
+
Class<E> beanType = list.getBeanType();
+ Preconditions.checkNotNull(beanType, "No beanType on the double list!");
DecoratorService decoratorService =
context.getService(DecoratorService.class);
@@ -289,7 +291,14 @@
Preconditions.checkNotNull(type);
- Decorator<O> decorator = decoratorService.getDecoratorByType(type, name);
+ Decorator decorator = decoratorService.getDecoratorByType(type, name);
+ if (decorator == null) {
+
+ if (DecoratorService.LabelAware.class.isAssignableFrom(type)) {
+ decorator = getDecorator(DecoratorService.LabelAware.class, null);
+
+ }
+ }
Preconditions.checkNotNull(decorator);
return decorator;
}
1
0