Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4130 discussions
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
r124 - in trunk/tutti-service/src/main: java/fr/ifremer/tutti/service resources/i18n
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:50:59 +0100 (Sat, 29 Dec 2012)
New Revision: 124
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/124
Log:
add LabelAware decorator contract + missing i18n key
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-29 11:32:20 UTC (rev 123)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-29 14:50:59 UTC (rev 124)
@@ -42,6 +42,8 @@
import org.nuiton.util.decorator.Decorator;
import org.nuiton.util.decorator.DecoratorProvider;
+import java.io.Serializable;
+
import static org.nuiton.i18n.I18n.n_;
/**
@@ -52,6 +54,16 @@
*/
public class DecoratorService extends AbstractTuttiService {
+ /**
+ * A contract to decorate some objects
+ * (not known at this level but with a label property to display them).
+ *
+ * @since 0.3
+ */
+ public interface LabelAware extends Serializable {
+ String getLabel();
+ }
+
public static final String SPECIES_BY_CODE = "byCode";
public static final String SPECIES_BY_GENUS = "byGenus";
@@ -104,6 +116,7 @@
registerMultiJXPathDecorator(Species.class, SPECIES_BY_GENUS, "${genusSpecies}$s", SEPARATOR, " - ");
registerMultiJXPathDecorator(SpeciesProtocol.class, "${speciesId}", SEPARATOR, " - ");
registerMultiJXPathDecorator(Attachment.class, "${name}$s", SEPARATOR, " - ");
+ registerMultiJXPathDecorator(LabelAware.class, "${label}$s", SEPARATOR, " - ");
registerDecorator(new Decorator<Float>(Float.class) {
private static final long serialVersionUID = 1L;
@@ -133,6 +146,7 @@
n_("tutti.property.user");
n_("tutti.property.strata");
n_("tutti.property.codeMemo");
+ n_("tutti.property.species");
n_("tutti.property.genusSpecies");
n_("tutti.property.sortedUnsortedCategory");
n_("tutti.property.macroWasteCategory");
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2012-12-29 11:32:20 UTC (rev 123)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2012-12-29 14:50:59 UTC (rev 124)
@@ -20,6 +20,7 @@
tutti.property.protocol=Protocol de saisie
tutti.property.seaState=État de la mer
tutti.property.sortedUnsortedCategory=Vrac / Hors Vrac
+tutti.property.species=Espèce
tutti.property.stationNumber=Numéro de station
tutti.property.strata=Strate d'association
tutti.property.user=Utilisateur
1
0
Author: tchemit
Date: 2012-12-29 12:32:20 +0100 (Sat, 29 Dec 2012)
New Revision: 123
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/123
Log:
up to mavenpom 3.4.7 + use snapshot of jaxx
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-12-28 16:41:38 UTC (rev 122)
+++ trunk/pom.xml 2012-12-29 11:32:20 UTC (rev 123)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4.6</version>
+ <version>3.4.7</version>
</parent>
<groupId>fr.ifremer</groupId>
@@ -81,9 +81,6 @@
<platform>forge.codelutin.com</platform>
<projectId>tutti</projectId>
- <!-- Remove this when using mavenpom 3.4.7 -->
- <compilerPluginVersion>2.5.1</compilerPluginVersion>
-
<!-- libraries version -->
<nuitonUtilsVersion>2.6.5</nuitonUtilsVersion>
@@ -94,7 +91,7 @@
<h2Version>1.3.168</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
- <jaxxVersion>2.5.8</jaxxVersion>
+ <jaxxVersion>2.5.9-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<xworkVersion>2.3.7</xworkVersion>
1
0
r122 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/protocol util/table
by kmorin@users.forge.codelutin.com 28 Dec '12
by kmorin@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: kmorin
Date: 2012-12-28 17:41:38 +0100 (Fri, 28 Dec 2012)
New Revision: 122
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/122
Log:
refs ##1810: [PROTOCOLE] Ecran de saisie
colonnes des esp?\195?\168ces ordonnables
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java
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/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/table/ColumnIdentifier.java
Added: 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 (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesColumnIdentifier.java 2012-12-28 16:41:38 UTC (rev 122)
@@ -0,0 +1,35 @@
+
+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/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-28 16:35:52 UTC (rev 121)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-28 16:41:38 UTC (rev 122)
@@ -24,6 +24,7 @@
* #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;
@@ -37,35 +38,41 @@
*/
public class EditProtocolSpeciesTableModel extends AbstractTuttiTableModel<EditProtocolSpeciesRowModel> {
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SPECIES_ID = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SPECIES_ID = EditProtocolSpeciesColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SPECIES,
n_("tutti.table.protocol.species.header.speciesId"),
- n_("tutti.table.protocol.species.header.speciesId"));
+ n_("tutti.table.protocol.species.header.speciesId"),
+ SampleCategoryEnum.speciesId);
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SORTED_UNSORTED_ENABLED = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SORTED_UNSORTED_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SORTED_UNSORTED_ENABLED,
n_("tutti.table.protocol.species.header.sortedUnsorted"),
- n_("tutti.table.protocol.species.header.sortedUnsorted"));
+ n_("tutti.table.protocol.species.header.sortedUnsorted"),
+ SampleCategoryEnum.sortedUnsorted);
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_CATEGORY_ENABLED = ColumnIdentifier.newId(
+ 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"));
+ n_("tutti.table.protocol.species.header.sizeCategory"),
+ SampleCategoryEnum.size);
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_SEX_ENABLED,
n_("tutti.table.protocol.species.header.sex"),
- n_("tutti.table.protocol.species.header.sex"));
+ n_("tutti.table.protocol.species.header.sex"),
+ SampleCategoryEnum.sex);
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = EditProtocolSpeciesColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_MATURITY_ENABLED,
n_("tutti.table.protocol.species.header.maturity"),
- n_("tutti.table.protocol.species.header.maturity"));
+ n_("tutti.table.protocol.species.header.maturity"),
+ SampleCategoryEnum.maturity);
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_FRENQUENCY_PMFM_ID = ColumnIdentifier.newId(
+ 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"));
+ n_("tutti.table.protocol.species.header.sizeFrequency"),
+ SampleCategoryEnum.age);
private static final long serialVersionUID = 1L;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 16:35:52 UTC (rev 121)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 16:41:38 UTC (rev 122)
@@ -29,6 +29,7 @@
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.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -37,20 +38,27 @@
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;
@@ -139,51 +147,50 @@
(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;
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Species.class),
- EditProtocolSpeciesTableModel.SPECIES_ID);
- }
-
- {
+ case sex:
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SEX_ENABLED,
+ table);
+ break;
+
+ case maturity:
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.MATURITY_ENABLED,
+ table);
+ break;
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED,
- table);
+ case age:
+ addComboDataColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SIZE_FRENQUENCY_PMFM_ID,
+ decorator,
+ Lists.newArrayList(allLengthStepPmfm.values()));
+
+ }
}
-
- {
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SIZE_CATEGORY_ENABLED,
- table);
- }
-
- {
-
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SEX_ENABLED,
- table);
- }
-
- {
-
- addBooleanColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.MATURITY_ENABLED,
- table);
- }
-
- {
-
- addComboDataColumnToModel(columnModel,
- EditProtocolSpeciesTableModel.SIZE_FRENQUENCY_PMFM_ID,
- decorator,
- Lists.newArrayList(allLengthStepPmfm.values()));
- }
-
-
return columnModel;
}
@@ -196,7 +203,7 @@
if (protocolId == null) {
// create new protocol
-
+
if (log.isDebugEnabled()) {
log.debug("Will create a new protocol");
}
@@ -211,6 +218,7 @@
log.debug("Will edit protocol: " + protocolId);
}
}
+
listModelIsModify(model);
ui.setContextValue(model);
@@ -275,8 +283,31 @@
});
JXTable table = ui.getSpeciesTable();
- TableColumnModel columnModel = createTableColumnModel(
+ final TableColumnModel columnModel = createTableColumnModel(
table.getDefaultRenderer(Object.class));
+ columnModel.addColumnModelListener(new TableColumnModelListener() {
+
+ public void columnAdded(TableColumnModelEvent e) {
+ }
+
+ public void columnRemoved(TableColumnModelEvent e) {
+ }
+
+ 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);
+ }
+ }
+
+ public void columnMarginChanged(ChangeEvent e) {
+ }
+
+ public void columnSelectionChanged(ListSelectionEvent e) {
+ }
+ });
+
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
@@ -395,8 +426,10 @@
// split the hydro grouped pmfm
List<String> hydroPmfm = bean.getHydrologyPmfmId();
List<String> allIds = Lists.newArrayList();
- for (String id : hydroPmfm) {
- allIds.addAll(hydroCaracteristics.get(id));
+ if (hydroPmfm != null) {
+ for (String id : hydroPmfm) {
+ allIds.addAll(hydroCaracteristics.get(id));
+ }
}
bean.setHydrologyPmfmId(allIds);
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-28 16:35:52 UTC (rev 121)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-28 16:41:38 UTC (rev 122)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.protocol.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;
@@ -52,6 +53,8 @@
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;
@@ -65,6 +68,14 @@
protected List<SpeciesProtocol> species;
+ protected List<SampleCategoryEnum> sampleCategoryOrder = Lists.newArrayList(
+ SampleCategoryEnum.speciesId,
+ SampleCategoryEnum.sortedUnsorted,
+ SampleCategoryEnum.size,
+ SampleCategoryEnum.sex,
+ SampleCategoryEnum.maturity,
+ SampleCategoryEnum.age);
+
protected static Binder<EditProtocolUIModel, TuttiProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolUIModel.class,
TuttiProtocol.class);
@@ -160,4 +171,14 @@
this.species = species;
firePropertyChange(PROPERTY_SPECIES, oldValue, species);
}
+
+ public List<SampleCategoryEnum> getSampleCategoryOrder() {
+ return sampleCategoryOrder;
+ }
+
+ public void setSampleCategoryOrder(List<SampleCategoryEnum> sampleCategoryOrder) {
+ Object oldValue = getSampleCategoryOrder();
+ this.sampleCategoryOrder = sampleCategoryOrder;
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_ORDER, oldValue, sampleCategoryOrder);
+ }
}
\ No newline at end of file
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-28 16:35:52 UTC (rev 121)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2012-12-28 16:41:38 UTC (rev 122)
@@ -50,7 +50,7 @@
headerTipI18nKey);
}
- ColumnIdentifier(String propertyName,
+ protected ColumnIdentifier(String propertyName,
String headerI18nKey,
String headerTipI18nKey) {
this.propertyName = propertyName;
1
0