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
r141 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches/species java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split resources/i18n
by tchemit@users.forge.codelutin.com 02 Jan '13
by tchemit@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: tchemit
Date: 2013-01-02 11:58:52 +0100 (Wed, 02 Jan 2013)
New Revision: 141
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/141
Log:
adding species sample category
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -38,6 +38,9 @@
* @since 0.3
*/
public enum SampleCategoryType implements DecoratorService.LabelAware {
+ species(
+ n_("tutti.sampleCategoryType.species"),
+ null),
sortedUnsorted(
n_("tutti.sampleCategoryType.sortedUnsorted"),
SampleCategoryEnum.sortedUnsorted),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -49,10 +49,14 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_SPECIES = "species";
-
public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
+ public static final String PROPERTY_SPECIES_SAMPLE_CATEGORY = "speciesSampleCategory";
+
+ public static final String PROPERTY_SPECIES_CATEGORY = "speciesCategory";
+
+ public static final String PROPERTY_SPECIES_CATEGORY_WEIGHT = "speciesCategoryWeight";
+
public static final String PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
@@ -106,6 +110,13 @@
public static final String PROPERTY_BATCH_ROOT = "batchRoot";
/**
+ * Species category.
+ *
+ * @since 0.2
+ */
+ protected final SampleCategory<Species> speciesSampleCategory;
+
+ /**
* Is catch is vrac or horsVrac?.
*
* @since 0.2
@@ -230,6 +241,7 @@
public SpeciesBatchRowModel() {
super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
frequency = Lists.newArrayList();
+ speciesSampleCategory = SampleCategory.newSample(SampleCategoryType.species);
sortedUnsortedSampleCategory = SampleCategory.newSample(SampleCategoryType.sortedUnsorted);
sizeSampleCategory = SampleCategory.newSample(SampleCategoryType.size);
sexSampleCategory = SampleCategory.newSample(SampleCategoryType.sex);
@@ -245,52 +257,42 @@
SpeciesFrequencyRowModel.fromBeans(frequencies);
frequency.addAll(frequencyRows);
Collections.sort(frequency);
- updateTotalFromFrequencies();
}
- public void updateTotalFromFrequencies() {
- Float totalNumber = null;
- Float totalWeight = null;
- if (CollectionUtils.isNotEmpty(frequency)) {
- totalNumber = 0f;
- totalWeight = 0f;
- for (SpeciesFrequencyRowModel frequencyModel : frequency) {
- totalNumber += frequencyModel.getNumber();
- Float w = frequencyModel.getWeight();
- if (w == null) {
+ //------------------------------------------------------------------------//
+ //-- Species category --//
+ //------------------------------------------------------------------------//
- // can't sum when a null value appears
- totalWeight = null;
- } else if (totalWeight != null) {
+ public SampleCategory<Species> getSpeciesSampleCategory() {
+ return speciesSampleCategory;
+ }
- // still can sum weights
- totalWeight += w;
- }
- }
- }
-
- setComputedNumber(totalNumber);
- setComputedWeight(totalWeight);
+ public Species getSpeciesCategory() {
+ return speciesSampleCategory.getCategoryValue();
}
- public Species getSpecies() {
- return species;
+ public void setSpeciesCategory(Species speciesCategory) {
+ Object oldValue = getSpeciesCategory();
+ speciesSampleCategory.setCategoryValue(speciesCategory);
+ firePropertyChange(PROPERTY_SPECIES_CATEGORY, oldValue, speciesCategory);
}
- public void setSpecies(Species species) {
- Object oldValue = getSpecies();
- this.species = species;
- firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ public Float getSpeciesCategoryWeight() {
+ return speciesSampleCategory.getCategoryWeight();
}
- public Boolean getSpeciesToConfirm() {
- return speciesToConfirm;
+ public void setSpeciesCategoryWeight(Float speciesCategoryWeight) {
+ Object oldValue = getSpeciesCategoryWeight();
+ speciesSampleCategory.setCategoryWeight(speciesCategoryWeight);
+ firePropertyChange(PROPERTY_SPECIES_CATEGORY_WEIGHT, oldValue, speciesCategoryWeight);
}
- public void setSpeciesToConfirm(Boolean speciesToConfirm) {
- Object oldValue = getSpeciesToConfirm();
- this.speciesToConfirm = speciesToConfirm;
- firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ //------------------------------------------------------------------------//
+ //-- SortedUnsorted category --//
+ //------------------------------------------------------------------------//
+
+ public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedSampleCategory() {
+ return sortedUnsortedSampleCategory;
}
public CaracteristicQualitativeValue getSortedUnsortedCategory() {
@@ -313,6 +315,14 @@
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Size category --//
+ //------------------------------------------------------------------------//
+
+ public SampleCategory<CaracteristicQualitativeValue> getSizeSampleCategory() {
+ return sizeSampleCategory;
+ }
+
public CaracteristicQualitativeValue getSizeCategory() {
return sizeSampleCategory.getCategoryValue();
}
@@ -333,6 +343,14 @@
firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Sex category --//
+ //------------------------------------------------------------------------//
+
+ public SampleCategory<CaracteristicQualitativeValue> getSexSampleCategory() {
+ return sexSampleCategory;
+ }
+
public CaracteristicQualitativeValue getSexCategory() {
return sexSampleCategory.getCategoryValue();
}
@@ -353,6 +371,14 @@
firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Maturity category --//
+ //------------------------------------------------------------------------//
+
+ public SampleCategory<CaracteristicQualitativeValue> getMaturitySampleCategory() {
+ return maturitySampleCategory;
+ }
+
public CaracteristicQualitativeValue getMaturityCategory() {
return maturitySampleCategory.getCategoryValue();
}
@@ -373,6 +399,14 @@
firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Age category --//
+ //------------------------------------------------------------------------//
+
+ public SampleCategory<Float> getAgeSampleCategory() {
+ return ageSampleCategory;
+ }
+
public Float getAgeCategory() {
return ageSampleCategory.getCategoryValue();
}
@@ -393,6 +427,54 @@
firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight);
}
+ //------------------------------------------------------------------------//
+ //-- Navigation properties --//
+ //------------------------------------------------------------------------//
+
+ public SpeciesBatchRowModel getBatchParent() {
+ return batchParent;
+ }
+
+ public void setBatchParent(SpeciesBatchRowModel batchParent) {
+ Object oldValue = getBatchParent();
+ this.batchParent = batchParent;
+ firePropertyChange(PROPERTY_BATCH_PARENT, oldValue, batchParent);
+ firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
+ }
+
+ public List<SpeciesBatchRowModel> getBatchChild() {
+ return batchChild;
+ }
+
+ public void setChilds(List<SpeciesBatchRowModel> batchChild) {
+ this.batchChild = batchChild;
+ // force to propagate child changes
+ firePropertyChange(PROPERTY_BATCH_CHILD, null, batchChild);
+ firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
+ }
+
+ public boolean isBatchLeaf() {
+ return CollectionUtils.isEmpty(batchChild);
+ }
+
+ public boolean isBatchRoot() {
+ return batchParent == null;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Other properties --//
+ //------------------------------------------------------------------------//
+
+ public Boolean getSpeciesToConfirm() {
+ return speciesToConfirm;
+ }
+
+ public void setSpeciesToConfirm(Boolean speciesToConfirm) {
+ Object oldValue = getSpeciesToConfirm();
+ this.speciesToConfirm = speciesToConfirm;
+ firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ }
+
public Float getWeight() {
return weight;
}
@@ -443,36 +525,6 @@
firePropertyChange(PROPERTY_FREQUENCY, null, frequency);
}
- public SpeciesBatchRowModel getBatchParent() {
- return batchParent;
- }
-
- public void setBatchParent(SpeciesBatchRowModel batchParent) {
- Object oldValue = getBatchParent();
- this.batchParent = batchParent;
- firePropertyChange(PROPERTY_BATCH_PARENT, oldValue, batchParent);
- firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
- }
-
- public List<SpeciesBatchRowModel> getBatchChild() {
- return batchChild;
- }
-
- public void setChilds(List<SpeciesBatchRowModel> batchChild) {
- this.batchChild = batchChild;
- // force to propagate child changes
- firePropertyChange(PROPERTY_BATCH_CHILD, null, batchChild);
- firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
- }
-
- public boolean isBatchLeaf() {
- return CollectionUtils.isEmpty(batchChild);
- }
-
- public boolean isBatchRoot() {
- return batchParent == null;
- }
-
public Float getComputedWeight() {
return computedWeight;
}
@@ -495,23 +547,4 @@
computedNumber);
}
- public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedSampleCategory() {
- return sortedUnsortedSampleCategory;
- }
-
- public SampleCategory<CaracteristicQualitativeValue> getSizeSampleCategory() {
- return sizeSampleCategory;
- }
-
- public SampleCategory<CaracteristicQualitativeValue> getSexSampleCategory() {
- return sexSampleCategory;
- }
-
- public SampleCategory<CaracteristicQualitativeValue> getMaturitySampleCategory() {
- return maturitySampleCategory;
- }
-
- public SampleCategory<Float> getAgeSampleCategory() {
- return ageSampleCategory;
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -72,16 +72,12 @@
}
}
- public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- n_("tutti.table.species.batch.header.speciesByCode"),
- n_("tutti.table.species.batch.header.speciesByCode"));
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES_CATEGORY = SampleColumnIdentifier.newId(
+ SpeciesBatchRowModel.PROPERTY_SPECIES_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_CATEGORY_WEIGHT,
+ n_("tutti.table.species.batch.header.speciesCategory"),
+ n_("tutti.table.species.batch.header.speciesCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- n_("tutti.table.species.batch.header.speciesByGenusCode"),
- n_("tutti.table.species.batch.header.speciesByGenusCode"));
-
public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
@@ -155,12 +151,13 @@
super(columnModel, false, false);
setNoneEditableCols();
-// setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
+
noneEditableColIfNoSpecies = Sets.newHashSet();
noneEditableColIfNoSpecies.add(COMPUTED_NUMBER);
noneEditableColIfNoSpecies.add(COMPUTED_WEIGHT);
sampleCols = Sets.newHashSet();
+ sampleCols.add(SPECIES_CATEGORY);
sampleCols.add(SORTED_UNSORTED_CATEGORY);
sampleCols.add(SIZE_CATEGORY);
sampleCols.add(SEX_CATEGORY);
@@ -190,24 +187,9 @@
super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
}
- if (propertyName == SPECIES_BY_CODE) {
+ if (propertyName == COMPUTED_NUMBER) {
// update also other columns
- fireTableCellUpdated(rowIndex,
- SPECIES_BY_GENUS_CODE,
- COMPUTED_NUMBER,
- COMPUTED_WEIGHT);
-
- } else if (propertyName == SPECIES_BY_GENUS_CODE) {
-
- // update also other columns
- fireTableCellUpdated(rowIndex,
- SPECIES_BY_CODE,
- COMPUTED_NUMBER,
- COMPUTED_WEIGHT);
- } else if (propertyName == COMPUTED_NUMBER) {
-
- // update also other columns
fireTableCellUpdated(rowIndex, COMPUTED_WEIGHT);
} else if (propertyName == COMPUTED_WEIGHT) {
@@ -238,7 +220,7 @@
// must have filled a species to edit this column
SpeciesBatchRowModel entry = getEntry(rowIndex);
- result = entry.getSpecies() != null;
+ result = entry.isValid() && entry.isBatchLeaf();
} else if (sampleCols.contains(propertyName)) {
// can only edit if a category value is setted
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -89,7 +89,7 @@
SpeciesBatchRowModel.PROPERTY_WEIGHT);
public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
@@ -113,7 +113,8 @@
SpeciesBatchUI ui) {
super(parentUi,
SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
- SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
@@ -170,7 +171,7 @@
SpeciesBatchRowModel entry =
new SpeciesBatchRowModel(aBatch, frequencies);
rows.add(entry);
- speciesUsed.add(entry.getSpecies());
+ speciesUsed.add(entry.getSpeciesCategory());
}
availableSpecies.removeAll(speciesUsed);
}
@@ -197,20 +198,12 @@
@Override
protected boolean isRowValid(SpeciesBatchRowModel row) {
- boolean result = row.getSpecies() != null;
- if (result) {
- result = row.getWeight() != null;
-
- if (!result) {
-
- // No weight filled, so at least one sample category must be valid
- result = row.getSortedUnsortedSampleCategory().isValid() ||
+ boolean result = row.getSpeciesSampleCategory().isValid() ||
+ row.getSortedUnsortedSampleCategory().isValid() ||
row.getSizeSampleCategory().isValid() ||
row.getSexSampleCategory().isValid() ||
row.getMaturitySampleCategory().isValid() ||
row.getAgeSampleCategory().isValid();
- }
- }
return result;
}
@@ -415,26 +408,16 @@
Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
getDecorator(CaracteristicQualitativeValue.class, null);
- { // Species (by code) column
+ { // SpeciesCategory column
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
+ Decorator<Species> decorator = getDecorator(Species.class, null);
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
}
- { // 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,
@@ -611,8 +594,8 @@
SpeciesBatchTableModel tableModel = getTableModel();
SpeciesBatchRowModel newRow = tableModel.createNewRow();
- newRow.setSpecies(createModel.getSpecies());
- newRow.setWeight(createModel.getBatchWeight());
+ newRow.setSpeciesCategory(createModel.getSpecies());
+ newRow.setSexCategoryWeight(createModel.getBatchWeight());
recomputeRowValidState(newRow);
@@ -621,7 +604,7 @@
saveRow(newRow);
// update available species list
- getModel().getAvailableSpecies().remove(newRow.getSpecies());
+ getModel().getAvailableSpecies().remove(newRow.getSpeciesCategory());
}
@@ -675,7 +658,7 @@
// can keep this row
SpeciesBatchRowModel newBatch = tableModel.createNewRow();
- newBatch.setSpecies(parentBatch.getSpecies());
+ newBatch.setSpeciesCategory(parentBatch.getSpeciesCategory());
newBatch.setSpeciesToConfirm(parentBatch.getSpeciesToConfirm());
if (selectedCategory == SampleCategoryType.sortedUnsorted) {
newBatch.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
@@ -787,6 +770,33 @@
return speciesFrequencyEditor;
}
+ public void updateTotalFromFrequencies(SpeciesBatchRowModel row) {
+ Float totalNumber = null;
+ Float totalWeight = null;
+ List<SpeciesFrequencyRowModel> frequency = row.getFrequency();
+
+ if (CollectionUtils.isNotEmpty(frequency)) {
+ totalNumber = 0f;
+ totalWeight = 0f;
+ for (SpeciesFrequencyRowModel frequencyModel : frequency) {
+ totalNumber += frequencyModel.getNumber();
+ Float w = frequencyModel.getWeight();
+ if (w == null) {
+
+ // can't sum when a null value appears
+ totalWeight = null;
+ } else if (totalWeight != null) {
+
+ // still can sum weights
+ totalWeight += w;
+ }
+ }
+ }
+
+ row.setComputedNumber(totalNumber);
+ row.setComputedWeight(totalWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -29,6 +29,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
@@ -137,15 +138,16 @@
log.info("Will edit frequencies for row: " + rowIndex);
}
+ SpeciesBatchUIHandler handler = ui.getHandler();
SpeciesFrequencyUI frequencyEditor =
- ui.getHandler().getSpeciesFrequencyEditor();
+ handler.getSpeciesFrequencyEditor();
frequencyEditor.editBatch(editRow);
// open frequency dialog
- ui.getHandler().openDialog(ui,
- frequencyEditor,
- _("tutti.title.frequency"),
- ui.getPreferredSize());
+ handler.openDialog(ui,
+ frequencyEditor,
+ _("tutti.title.frequency"),
+ ui.getPreferredSize());
SpeciesFrequencyUIModel frequencyModel = frequencyEditor.getModel();
@@ -171,7 +173,8 @@
// push back to batch
editRow.setFrequency(frequency);
- editRow.updateTotalFromFrequencies();
+ // update frequencies total
+ handler.updateTotalFromFrequencies(editRow);
}
frequencyEditor.editBatch(null);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-01-02 10:58:52 UTC (rev 141)
@@ -38,7 +38,7 @@
* @since 0.3
*/
public class SplitSpeciesBatchUIModel
- extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+ extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
private static final long serialVersionUID = 1L;
@@ -111,7 +111,7 @@
}
public Species getSpecies() {
- return batch == null ? null : batch.getSpecies();
+ return batch == null ? null : batch.getSpeciesCategory();
}
public List<SampleCategoryType> getCategory() {
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-02 10:14:19 UTC (rev 140)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-02 10:58:52 UTC (rev 141)
@@ -172,6 +172,7 @@
tutti.sampleCategoryType.sex=Sexe
tutti.sampleCategoryType.size=Class Tri.
tutti.sampleCategoryType.sortedUnsorted=V/HV
+tutti.sampleCategoryType.species=Espèce
tutti.table.accidental.batch.header.comment=Commentaire
tutti.table.accidental.batch.header.file=Pièces-jointes
tutti.table.accidental.batch.header.speciesByCode=Espèce
@@ -226,6 +227,7 @@
tutti.table.species.batch.header.sortedUnsortedCategory=Vrac / Hors Vrac
tutti.table.species.batch.header.speciesByCode=Espèce
tutti.table.species.batch.header.speciesByGenusCode=Espèce
+tutti.table.species.batch.header.speciesCategory=
tutti.table.species.batch.header.toConfirm=A Confirmer
tutti.table.species.batch.header.weight=Poids
tutti.table.species.frequency.header.computedWeight=Poids calculé
1
0
r140 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
by kmorin@users.forge.codelutin.com 02 Jan '13
by kmorin@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: kmorin
Date: 2013-01-02 11:14:19 +0100 (Wed, 02 Jan 2013)
New Revision: 140
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/140
Log:
refs #1810: [PROTOCOLE] Ecran de saisie
debug colonnes des esp?\195?\168ces ordonnables
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-02 10:12:53 UTC (rev 139)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-02 10:14:19 UTC (rev 140)
@@ -41,6 +41,15 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.TableColumnModelEvent;
+import javax.swing.event.TableColumnModelListener;
+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;
@@ -50,17 +59,7 @@
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ListSelectionEvent;
-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
*
@@ -198,7 +197,26 @@
initUI(ui);
EditProtocolUIModel model = getModel();
+
+ // load protocol if existing
+ String protocolId = context.getProtocolId();
+ TuttiProtocol protocol = null;
+ if (protocolId == null) {
+
+ // create new protocol
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will create a new protocol");
+ }
+ } else {
+
+ // load existing protocol
+ protocol = persistenceService.getProtocol(protocolId);
+
+ model.fromBean(protocol);
+ }
+
SwingValidatorUtil.installUI(ui.getErrorTable(),
new SwingValidatorMessageTableRenderer());
@@ -261,25 +279,8 @@
List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
- // load protocol if existing
-
- String protocolId = context.getProtocolId();
- if (protocolId == null) {
-
- // create new protocol
-
- if (log.isDebugEnabled()) {
- log.debug("Will create a new protocol");
- }
- } else {
-
- // load existing protocol
- TuttiProtocol protocol = persistenceService.getProtocol(protocolId);
-
- model.fromBean(protocol);
-
- // build speciesProtocol rows
-
+ // build speciesProtocol rows
+ if (protocol != null) {
List<SpeciesProtocol> speciesProtocols = protocol.getSpecies();
if (CollectionUtils.isNotEmpty(speciesProtocols)) {
for (SpeciesProtocol speciesProtocol : speciesProtocols) {
1
0
r139 - trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence
by kmorin@users.forge.codelutin.com 02 Jan '13
by kmorin@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: kmorin
Date: 2013-01-02 11:12:53 +0100 (Wed, 02 Jan 2013)
New Revision: 139
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/139
Log:
change method name
Modified:
trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevFixtures.java
Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevFixtures.java
===================================================================
--- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevFixtures.java 2013-01-02 10:07:34 UTC (rev 138)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevFixtures.java 2013-01-02 10:12:53 UTC (rev 139)
@@ -234,23 +234,23 @@
Caracteristic ca;
- ca = createQuantitativeCaracteristic("Vent Beaufort",
+ ca = createQualitativeCaracteristic("Vent Beaufort",
CaracteristicEnum.FishingOperationEnvironment.name());
- createCaracteristicQuantitativeValue(ca, "Calme");
- createCaracteristicQuantitativeValue(ca, "Très légère brise");
- createCaracteristicQuantitativeValue(ca, "Petite brise");
- createCaracteristicQuantitativeValue(ca, "Jolie brise");
- createCaracteristicQuantitativeValue(ca, "Vent frais");
- createCaracteristicQuantitativeValue(ca, "Grand frais");
- createCaracteristicQuantitativeValue(ca, "Coup de vent");
- createCaracteristicQuantitativeValue(ca, "Fort coup de vent");
+ createCaracteristicQualitativeValue(ca, "Calme");
+ createCaracteristicQualitativeValue(ca, "Très légère brise");
+ createCaracteristicQualitativeValue(ca, "Petite brise");
+ createCaracteristicQualitativeValue(ca, "Jolie brise");
+ createCaracteristicQualitativeValue(ca, "Vent frais");
+ createCaracteristicQualitativeValue(ca, "Grand frais");
+ createCaracteristicQualitativeValue(ca, "Coup de vent");
+ createCaracteristicQualitativeValue(ca, "Fort coup de vent");
- ca = createQuantitativeCaracteristic("État de la mer",
+ ca = createQualitativeCaracteristic("État de la mer",
CaracteristicEnum.FishingOperationEnvironment.name());
- createCaracteristicQuantitativeValue(ca, "Mer calme");
- createCaracteristicQuantitativeValue(ca, "Mer agitée");
+ createCaracteristicQualitativeValue(ca, "Mer calme");
+ createCaracteristicQualitativeValue(ca, "Mer agitée");
createNumberCaracteristic("Direction du vent",
CaracteristicEnum.FishingOperationEnvironment.name());
@@ -345,66 +345,66 @@
sp.setGenusSpecies("Limande");
cache.put(Species.class, sp);
- ca = createQuantitativeCaracteristic("MacroWaste", CaracteristicEnum.MacroWasteCategory.name());
+ ca = createQualitativeCaracteristic("MacroWaste", CaracteristicEnum.MacroWasteCategory.name());
- createCaracteristicQuantitativeValue(ca, "Bottle");
- createCaracteristicQuantitativeValue(ca, "Sheet");
- createCaracteristicQuantitativeValue(ca, "Bag");
- createCaracteristicQuantitativeValue(ca, "Caps/ lids");
- createCaracteristicQuantitativeValue(ca, "Fishing line (monofilament)");
- createCaracteristicQuantitativeValue(ca, "Fishing line (entangled)");
- createCaracteristicQuantitativeValue(ca, "Synthetic rope");
- createCaracteristicQuantitativeValue(ca, "Cable ties");
- createCaracteristicQuantitativeValue(ca, "Strapping band");
- createCaracteristicQuantitativeValue(ca, "Crates abd containers");
- createCaracteristicQuantitativeValue(ca, "Boots");
- createCaracteristicQuantitativeValue(ca, "Balloons");
- createCaracteristicQuantitativeValue(ca, "bobbins (fishing)");
- createCaracteristicQuantitativeValue(ca, "tyre");
- createCaracteristicQuantitativeValue(ca, "glove");
- createCaracteristicQuantitativeValue(ca, "diapers");
- createCaracteristicQuantitativeValue(ca, "cotton buds");
- createCaracteristicQuantitativeValue(ca, "cigarette butts");
- createCaracteristicQuantitativeValue(ca, "condoms");
- createCaracteristicQuantitativeValue(ca, "syringes");
- createCaracteristicQuantitativeValue(ca, "sanitary towels / tampon");
- createCaracteristicQuantitativeValue(ca, "jar");
- createCaracteristicQuantitativeValue(ca, "piece");
+ createCaracteristicQualitativeValue(ca, "Bottle");
+ createCaracteristicQualitativeValue(ca, "Sheet");
+ createCaracteristicQualitativeValue(ca, "Bag");
+ createCaracteristicQualitativeValue(ca, "Caps/ lids");
+ createCaracteristicQualitativeValue(ca, "Fishing line (monofilament)");
+ createCaracteristicQualitativeValue(ca, "Fishing line (entangled)");
+ createCaracteristicQualitativeValue(ca, "Synthetic rope");
+ createCaracteristicQualitativeValue(ca, "Cable ties");
+ createCaracteristicQualitativeValue(ca, "Strapping band");
+ createCaracteristicQualitativeValue(ca, "Crates abd containers");
+ createCaracteristicQualitativeValue(ca, "Boots");
+ createCaracteristicQualitativeValue(ca, "Balloons");
+ createCaracteristicQualitativeValue(ca, "bobbins (fishing)");
+ createCaracteristicQualitativeValue(ca, "tyre");
+ createCaracteristicQualitativeValue(ca, "glove");
+ createCaracteristicQualitativeValue(ca, "diapers");
+ createCaracteristicQualitativeValue(ca, "cotton buds");
+ createCaracteristicQualitativeValue(ca, "cigarette butts");
+ createCaracteristicQualitativeValue(ca, "condoms");
+ createCaracteristicQualitativeValue(ca, "syringes");
+ createCaracteristicQualitativeValue(ca, "sanitary towels / tampon");
+ createCaracteristicQualitativeValue(ca, "jar");
+ createCaracteristicQualitativeValue(ca, "piece");
- ca = createQuantitativeCaracteristic("MacroWaste Size category",
+ ca = createQualitativeCaracteristic("MacroWaste Size category",
CaracteristicEnum.MacroWasteSizeCategory.name());
- createCaracteristicQuantitativeValue(ca, "<5*5cm = 25cm²");
- createCaracteristicQuantitativeValue(ca, "<10*10cm = 100cm²");
- createCaracteristicQuantitativeValue(ca, "<20*20cm = 400cm²");
- createCaracteristicQuantitativeValue(ca, "<50*50cm = 2500cm²");
- createCaracteristicQuantitativeValue(ca, "<100*100cm = 1m²");
- createCaracteristicQuantitativeValue(ca, ">100*100cm = 1m²");
+ createCaracteristicQualitativeValue(ca, "<5*5cm = 25cm²");
+ createCaracteristicQualitativeValue(ca, "<10*10cm = 100cm²");
+ createCaracteristicQualitativeValue(ca, "<20*20cm = 400cm²");
+ createCaracteristicQualitativeValue(ca, "<50*50cm = 2500cm²");
+ createCaracteristicQualitativeValue(ca, "<100*100cm = 1m²");
+ createCaracteristicQualitativeValue(ca, ">100*100cm = 1m²");
- ca = createQuantitativeCaracteristic("Sorted / Unsorted Category", CaracteristicEnum.SpeciesSortedUnsorted.name());
+ ca = createQualitativeCaracteristic("Sorted / Unsorted Category", CaracteristicEnum.SpeciesSortedUnsorted.name());
- createCaracteristicQuantitativeValue(ca, "Vrac");
- createCaracteristicQuantitativeValue(ca, "Hors Vrac");
+ createCaracteristicQualitativeValue(ca, "Vrac");
+ createCaracteristicQualitativeValue(ca, "Hors Vrac");
- ca = createQuantitativeCaracteristic("Species Sex Category", CaracteristicEnum.SpeciesSex.name());
+ ca = createQualitativeCaracteristic("Species Sex Category", CaracteristicEnum.SpeciesSex.name());
- createCaracteristicQuantitativeValue(ca, "Male");
- createCaracteristicQuantitativeValue(ca, "Femelle");
- createCaracteristicQuantitativeValue(ca, "Indéterminé");
+ createCaracteristicQualitativeValue(ca, "Male");
+ createCaracteristicQualitativeValue(ca, "Femelle");
+ createCaracteristicQualitativeValue(ca, "Indéterminé");
- ca = createQuantitativeCaracteristic("Species Maturity Category", CaracteristicEnum.SpeciesMaturity.name());
+ ca = createQualitativeCaracteristic("Species Maturity Category", CaracteristicEnum.SpeciesMaturity.name());
- createCaracteristicQuantitativeValue(ca, "0");
- createCaracteristicQuantitativeValue(ca, "1");
- createCaracteristicQuantitativeValue(ca, "2");
+ createCaracteristicQualitativeValue(ca, "0");
+ createCaracteristicQualitativeValue(ca, "1");
+ createCaracteristicQualitativeValue(ca, "2");
- ca = createQuantitativeCaracteristic("Species Size Category", CaracteristicEnum.SpeciesSizeCategory.name());
+ ca = createQualitativeCaracteristic("Species Size Category", CaracteristicEnum.SpeciesSizeCategory.name());
- createCaracteristicQuantitativeValue(ca, "Petit");
- createCaracteristicQuantitativeValue(ca, "Gros");
+ createCaracteristicQualitativeValue(ca, "Petit");
+ createCaracteristicQualitativeValue(ca, "Gros");
}
- protected void createCaracteristicQuantitativeValue(Caracteristic ca, String name) {
+ protected void createCaracteristicQualitativeValue(Caracteristic ca, String name) {
CaracteristicQualitativeValue cqv = new CaracteristicQualitativeValue();
cqv.setId(UUID.randomUUID().toString());
cqv.setName(name);
@@ -412,7 +412,7 @@
cache.put(CaracteristicQualitativeValue.class, cqv);
}
- protected Caracteristic createQuantitativeCaracteristic(String name, String category) {
+ protected Caracteristic createQualitativeCaracteristic(String name, String category) {
Caracteristic ca = new Caracteristic();
ca.setId(UUID.randomUUID().toString());
ca.setName(name);
1
0
r138 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: . config content/cruise content/home content/operation content/operation/catches content/operation/catches/species content/operation/catches/species/frequency content/operation/catches/species/split content/operation/fishing/environment content/operation/fishing/gearshooting content/operation/fishing/hydrology content/program content/protocol
by tchemit@users.forge.codelutin.com 02 Jan '13
by tchemit@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: tchemit
Date: 2013-01-02 11:07:34 +0100 (Wed, 02 Jan 2013)
New Revision: 138
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/138
Log:
add close on ui (for the moment just log, but you never know)
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/config/TuttiConfigUI.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/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -403,4 +403,8 @@
}
combo.setSelectedItem(selectedItem);
}
+
+ protected void closeUI(TuttiUI ui) {
+ ui.getHandler().onCloseUI();
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
import fr.ifremer.tutti.ui.swing.MainUI;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIHelper;
import jaxx.runtime.swing.editor.config.model.MainCallBackFinalizer;
@@ -116,9 +117,13 @@
helper.setFinalizer(new MainCallBackFinalizer(CALLBACK_APPLICATION));
- helper.buildUI(mainUI, "tutti.config.category.applications");
+ ConfigUI configUI = helper.buildUI(
+ mainUI,
+ "tutti.config.category.applications");
helper.displayUI(mainUI, false);
+
+ mainUI.getHandler().getContext().getSwingSession().add(configUI);
}
protected void reloadApplication() {
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -147,6 +147,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
@Override
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -222,6 +222,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
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/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -287,6 +287,14 @@
@Override
public void onCloseUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+
+ closeUI(ui.getGearShootingTabContent());
+ closeUI(ui.getEnvironmentTabContent());
+ closeUI(ui.getHydrologyTabContent());
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -107,6 +107,11 @@
}
// close batches tabs, then general tab
+ closeUI(ui.getSpeciesTabContent());
+ closeUI(ui.getBenthosTabContent());
+ closeUI(ui.getPlanktonTabContent());
+ closeUI(ui.getMacroWasteTabContent());
+ closeUI(ui.getAccidentalTabContent());
}
@Override
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-01-02 10:07:34 UTC (rev 138)
@@ -27,9 +27,6 @@
<import>
fr.ifremer.tutti.ui.swing.TuttiUI
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
@@ -79,11 +76,6 @@
component='speciesTotalUnsortedWeightField'/>
</BeanValidator>
- <SpeciesFrequencyUI id='frequencyEditor' constructorParams='this'/>
-
- <CreateSpeciesBatchUI id='createSpeciesBatchUI' constructorParams='this'/>
- <SplitSpeciesBatchUI id='splitSpeciesBatchUI' constructorParams='this'/>
-
<LongTextEditorUI id='longTextEditor'/>
<AttachmentEditorUI id='attachmentEditor'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -45,6 +45,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
@@ -102,6 +103,12 @@
*/
private final SpeciesBatchUI ui;
+ private SplitSpeciesBatchUI splitSpeciesBatchEditor;
+
+ private CreateSpeciesBatchUI createSpeciesBatchEditor;
+
+ private SpeciesFrequencyUI speciesFrequencyEditor;
+
public SpeciesBatchUIHandler(TuttiUI<?, ?> parentUi,
SpeciesBatchUI ui) {
super(parentUi,
@@ -529,8 +536,23 @@
@Override
public void onCloseUI() {
if (log.isInfoEnabled()) {
- log.info("closing: " + ui);
+ log.info("Closing: " + ui);
}
+
+ if (splitSpeciesBatchEditor != null) {
+ getContext().getSwingSession().add(splitSpeciesBatchEditor);
+ closeUI(splitSpeciesBatchEditor);
+ }
+
+ if (createSpeciesBatchEditor != null) {
+ getContext().getSwingSession().add(createSpeciesBatchEditor);
+ closeUI(createSpeciesBatchEditor);
+ }
+
+ if (speciesFrequencyEditor != null) {
+ getContext().getSwingSession().add(speciesFrequencyEditor);
+ closeUI(speciesFrequencyEditor);
+ }
}
//------------------------------------------------------------------------//
@@ -573,7 +595,7 @@
public void createSpeciesBatch() {
CreateSpeciesBatchUI createBatchEditor =
- ui.getCreateSpeciesBatchUI();
+ getCreateSpeciesBatchEditor();
createBatchEditor.getHandler().openUI(getModel());
@@ -626,7 +648,7 @@
if (log.isInfoEnabled()) {
log.info("Open split batch ui for row [" + rowIndex + "]");
}
- SplitSpeciesBatchUI splitBatchEditor = ui.getSplitSpeciesBatchUI();
+ SplitSpeciesBatchUI splitBatchEditor = getSplitSpeciesBatchEditor();
splitBatchEditor.getHandler().editBatch(parentBatch);
openDialog(ui,
@@ -744,6 +766,27 @@
getTableModel().getRowCount() - 1);
}
+ public SplitSpeciesBatchUI getSplitSpeciesBatchEditor() {
+ if (splitSpeciesBatchEditor == null) {
+ splitSpeciesBatchEditor = new SplitSpeciesBatchUI(ui);
+ }
+ return splitSpeciesBatchEditor;
+ }
+
+ public CreateSpeciesBatchUI getCreateSpeciesBatchEditor() {
+ if (createSpeciesBatchEditor == null) {
+ createSpeciesBatchEditor = new CreateSpeciesBatchUI(ui);
+ }
+ return createSpeciesBatchEditor;
+ }
+
+ public SpeciesFrequencyUI getSpeciesFrequencyEditor() {
+ if (speciesFrequencyEditor == null) {
+ speciesFrequencyEditor = new SpeciesFrequencyUI(ui);
+ }
+ return speciesFrequencyEditor;
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
@@ -897,8 +940,7 @@
columnIdentifier);
}
-
-// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
+ // protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
// SpeciesBatchTreeNode node) {
//
// SpeciesBatchTreeNode superSamplingNode = node.getParent();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -137,7 +137,8 @@
log.info("Will edit frequencies for row: " + rowIndex);
}
- SpeciesFrequencyUI frequencyEditor = ui.getFrequencyEditor();
+ SpeciesFrequencyUI frequencyEditor =
+ ui.getHandler().getSpeciesFrequencyEditor();
frequencyEditor.editBatch(editRow);
// open frequency dialog
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -250,6 +250,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-02 10:07:34 UTC (rev 138)
@@ -113,8 +113,7 @@
<!-- Messages report -->
<JPanel id='messagePanel' layout='{new GridLayout()}'>
- <JScrollPane id='errorTableScrollPane'
- columnHeaderView='{errorTable.getTableHeader()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
<JTable id='errorTable'/>
</JScrollPane>
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -208,6 +208,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
@@ -373,8 +376,8 @@
if (data != null) {
- if (log.isInfoEnabled()) {
- log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
+ if (log.isDebugEnabled()) {
+ log.debug("Got " + data.sizeQualitativeValue() + " qualitative data to add");
}
addColumnToModel(columnModel,
null,
@@ -401,8 +404,8 @@
uninstallTableSaveOnRowChangedSelectionListener();
uninstallTableKeyListener();
- if (log.isInfoEnabled()) {
- log.info("Install new table model " + tableModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Install new table model " + tableModel);
}
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -419,8 +422,8 @@
// add a row for each qualitive value
for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
- if (log.isInfoEnabled()) {
- log.info("Add QV: " + qualitativeValue);
+ if (log.isDebugEnabled()) {
+ log.debug("Add QV: " + qualitativeValue);
}
SplitSpeciesBatchRowModel newRow = tableModel.createNewRow();
newRow.setCategoryValue(qualitativeValue);
@@ -428,8 +431,8 @@
}
}
- if (log.isInfoEnabled()) {
- log.info("Will add " + rows.size() + " rows in table model " +
+ if (log.isDebugEnabled()) {
+ log.debug("Will add " + rows.size() + " rows in table model " +
"(can add a first empty row? " + editableCategoryValue + ").");
}
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -154,6 +154,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -158,6 +158,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -226,6 +226,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -113,6 +113,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
ui.getValidator().setBean(null);
}
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 2013-01-01 23:04:02 UTC (rev 137)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-02 10:07:34 UTC (rev 138)
@@ -346,6 +346,9 @@
@Override
public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
}
//------------------------------------------------------------------------//
1
0
r137 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/operation/catches/species java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split java/fr/ifremer/tutti/ui/swing/util resources/i18n
by tchemit@users.forge.codelutin.com 01 Jan '13
by tchemit@users.forge.codelutin.com 01 Jan '13
01 Jan '13
Author: tchemit
Date: 2013-01-02 00:04:02 +0100 (Wed, 02 Jan 2013)
New Revision: 137
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/137
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (ajout creation lot esp?\195?\168ce) + am?\195?\169lioration des dialog
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -30,9 +30,12 @@
import fr.ifremer.tutti.persistence.entities.IdAware;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.UIMessageNotifier;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.NumberEditor;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
@@ -45,14 +48,24 @@
import org.nuiton.util.decorator.JXPathDecorator;
import org.nuiton.validator.bean.simple.SimpleBeanValidator;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
import javax.swing.JList;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
@@ -87,6 +100,10 @@
this.context = context;
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void showInformationMessage(String message) {
context.showInformationMessage(message);
@@ -137,6 +154,62 @@
}
}
+ public void openDialog(TuttiUI ui,
+ TuttiUI dialogContent,
+ String title, Dimension dim) {
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ JDialog result = new JDialog(frame, true);
+ result.setTitle(title);
+ result.add((Component) dialogContent);
+ result.setResizable(true);
+
+ result.setSize(dim);
+
+ final AbstractTuttiUIHandler handler = dialogContent.getHandler();
+
+ if (handler instanceof Cancelable) {
+
+ // add a auto-close action
+ JRootPane rootPane = result.getRootPane();
+
+ KeyStroke shortcutClosePopup = getConfig().getShortcutClosePopup();
+
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ shortcutClosePopup, "close");
+ rootPane.getActionMap().put("close", new AbstractAction() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ((Cancelable) handler).cancel();
+ }
+ });
+ }
+
+ result.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isInfoEnabled()) {
+ log.info("Destroy ui " + ui);
+ }
+ JAXXUtil.destroy(ui);
+ }
+ });
+ SwingUtil.center(frame, result);
+ result.setVisible(true);
+ }
+
+ public void closeDialog(TuttiUI ui) {
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
protected void initUI(TuttiUI ui) {
for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -97,6 +97,14 @@
public static final String PROPERTY_ATTACHMENTS = "attachments";
+ public static final String PROPERTY_BATCH_PARENT = "batchParent";
+
+ public static final String PROPERTY_BATCH_CHILD = "batchChild";
+
+ public static final String PROPERTY_BATCH_LEAF = "batchLeaf";
+
+ public static final String PROPERTY_BATCH_ROOT = "batchRoot";
+
/**
* Is catch is vrac or horsVrac?.
*
@@ -195,6 +203,22 @@
*/
protected List<SpeciesFrequencyRowModel> frequency;
+ /**
+ * Parent of this batch (can be null if batch is root).
+ *
+ * @see #isBatchRoot()
+ * @since 0.3
+ */
+ protected SpeciesBatchRowModel batchParent;
+
+ /**
+ * List of child batches (can be null or empty if batch is a leaf).
+ *
+ * @see #isBatchLeaf()
+ * @since 0.3
+ */
+ protected List<SpeciesBatchRowModel> batchChild;
+
protected static final Binder<SpeciesBatch, SpeciesBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(SpeciesBatch.class,
SpeciesBatchRowModel.class);
@@ -419,6 +443,36 @@
firePropertyChange(PROPERTY_FREQUENCY, null, frequency);
}
+ public SpeciesBatchRowModel getBatchParent() {
+ return batchParent;
+ }
+
+ public void setBatchParent(SpeciesBatchRowModel batchParent) {
+ Object oldValue = getBatchParent();
+ this.batchParent = batchParent;
+ firePropertyChange(PROPERTY_BATCH_PARENT, oldValue, batchParent);
+ firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
+ }
+
+ public List<SpeciesBatchRowModel> getBatchChild() {
+ return batchChild;
+ }
+
+ public void setChilds(List<SpeciesBatchRowModel> batchChild) {
+ this.batchChild = batchChild;
+ // force to propagate child changes
+ firePropertyChange(PROPERTY_BATCH_CHILD, null, batchChild);
+ firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
+ }
+
+ public boolean isBatchLeaf() {
+ return CollectionUtils.isEmpty(batchChild);
+ }
+
+ public boolean isBatchRoot() {
+ return batchParent == null;
+ }
+
public Float getComputedWeight() {
return computedWeight;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -45,16 +45,15 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,7 +64,6 @@
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
-import java.awt.Frame;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.io.Serializable;
@@ -236,82 +234,6 @@
// when row valid state has changed, recompute action enabled states
recomputeBatchActionEnable();
-
-
-// SpeciesBatchUIModel model = getModel();
-//
-// SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
-//
-// if (SAMPLING_PROPERTIES.contains(propertyName)) {
-//
-// // Need to rebuilt this row sampling tree path (and then recompute
-// // old super - samplingRatio and new super - samplingRatio)
-//
-// // old node of the previous sampling def for this row
-// // and remove it from any cache
-// SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
-//
-// boolean rowWasValid = row.isValid();
-// if (oldNode != null && rowWasValid) {
-//
-// // remove this row from his super sampling
-// recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
-// }
-//
-// // get new sampling node
-// SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
-//
-// // check this row is valid
-// boolean rowValid = samplingTreeModel.isValid(row, newNode);
-//
-// // push this state back to the row
-// row.setValid(rowValid);
-//
-// if (rowValid) {
-//
-// // can add it to his super-sampling
-// recomputeSuperSamplingRatio(samplingTreeModel, newNode);
-// } else {
-//
-// if (rowWasValid) {
-//
-//// row.setSampleWeight(null);
-//// row.setSamplingRatio(null);
-//
-// getTableModel().updateSamplingRatio(Sets.newHashSet(row));
-// }
-// }
-// }
-//
-// if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
-//
-// // Need to recompute the super - samplingRatio
-//
-// SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
-//
-// boolean rowWasValid = row.isValid();
-//
-// // check this row is valid
-// boolean rowValid = samplingTreeModel.isValid(row, node);
-//
-// // push this state back to the row
-// row.setValid(rowValid);
-//
-// if (rowValid) {
-// recomputeSuperSamplingRatio(samplingTreeModel, node);
-// } else {
-// if (rowWasValid) {
-//
-// // must remove this row from his super-sampling
-// recomputeSuperSamplingRatio(samplingTreeModel, node);
-//
-//// row.setSampleWeight(null);
-//// row.setSamplingRatio(null);
-//
-// getTableModel().updateSamplingRatio(Sets.newHashSet(row));
-// }
-// }
-// }
}
@Override
@@ -354,7 +276,6 @@
@Override
protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
super.onModelRowsChanged(rows);
-
// build the new sampling tree from the new rows to edit
// getModel().getSamplingTreeModel().populate(rows);
}
@@ -478,7 +399,8 @@
JXTable table = getTable();
// create table column model
- TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class);
+ TableCellRenderer defaultRenderer =
+ table.getDefaultRenderer(Object.class);
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -556,7 +478,7 @@
{ // Computed weight column (from frequencies)
addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newEditor(ui),
FrequencyCellComponent.newRender(),
SpeciesBatchTableModel.COMPUTED_WEIGHT);
}
@@ -564,7 +486,7 @@
{ // Computed number column (from frequencies)
addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newEditor(ui),
FrequencyCellComponent.newRender(),
SpeciesBatchTableModel.COMPUTED_NUMBER);
}
@@ -650,6 +572,41 @@
public void createSpeciesBatch() {
+ CreateSpeciesBatchUI createBatchEditor =
+ ui.getCreateSpeciesBatchUI();
+
+ createBatchEditor.getHandler().openUI(getModel());
+
+ openDialog(ui,
+ createBatchEditor,
+ _("tutti.title.createBatch"),
+ ui.getPreferredSize());
+
+ CreateSpeciesBatchUIModel createModel = createBatchEditor.getModel();
+
+ if (createModel.isValid()) {
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ SpeciesBatchRowModel newRow = tableModel.createNewRow();
+ newRow.setSpecies(createModel.getSpecies());
+ newRow.setWeight(createModel.getBatchWeight());
+
+ recomputeRowValidState(newRow);
+
+ tableModel.addNewRow(newRow);
+
+ saveRow(newRow);
+
+ // update available species list
+ getModel().getAvailableSpecies().remove(newRow.getSpecies());
+
+ }
+
+ // reset create ui
+ createBatchEditor.getHandler().openUI(null);
+
+ recomputeBatchActionEnable();
}
public void splitSpeciesBatch() {
@@ -658,104 +615,145 @@
// get selected row
int rowIndex = table.getSelectedRow();
- SpeciesBatchRowModel selectedRow = getTableModel().getEntry(rowIndex);
+ Preconditions.checkState(rowIndex != -1,
+ "Cant split batch if no batch selected");
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ SpeciesBatchRowModel parentBatch = tableModel.getEntry(rowIndex);
+
if (log.isInfoEnabled()) {
- log.info("Open split batch for row [" + rowIndex + "]");
+ log.info("Open split batch ui for row [" + rowIndex + "]");
}
- SplitSpeciesBatchUI sampleCategoryEditor = ui.getSplitSpeciesBatchUI();
- sampleCategoryEditor.getHandler().editBatch(selectedRow);
+ SplitSpeciesBatchUI splitBatchEditor = ui.getSplitSpeciesBatchUI();
+ splitBatchEditor.getHandler().editBatch(parentBatch);
- Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+ openDialog(ui,
+ splitBatchEditor,
+ _("tutti.title.splitBatch"),
+ ui.getPreferredSize());
- // open split batch dialog
- TuttiUIUtil.openInDialog(sampleCategoryEditor,
- frame,
- _("tutti.title.splitBatch"), true, null);
-
// at close, synch back batches ?
- SplitSpeciesBatchUIModel splitModel = sampleCategoryEditor.getModel();
+ SplitSpeciesBatchUIModel splitModel = splitBatchEditor.getModel();
if (splitModel.isValid()) {
// create batch rows
- SpeciesBatchTableModel batchTableModel = getTableModel();
-
int insertRow = rowIndex;
SampleCategoryType selectedCategory = splitModel.getSelectedCategory();
// Create rows in batch table model
- List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList();
+ List<SpeciesBatchRowModel> newBatches = Lists.newArrayList();
for (SplitSpeciesBatchRowModel row : splitModel.getRows()) {
if (row.isValid()) {
// can keep this row
- SpeciesBatchRowModel batchNewRow = batchTableModel.createNewRow();
- batchNewRow.setSpecies(selectedRow.getSpecies());
- batchNewRow.setSpeciesToConfirm(selectedRow.getSpeciesToConfirm());
+ SpeciesBatchRowModel newBatch = tableModel.createNewRow();
+ newBatch.setSpecies(parentBatch.getSpecies());
+ newBatch.setSpeciesToConfirm(parentBatch.getSpeciesToConfirm());
if (selectedCategory == SampleCategoryType.sortedUnsorted) {
- batchNewRow.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSortedUnsortedCategoryWeight(row.getWeight());
+ newBatch.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSortedUnsortedCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSortedUnsortedCategory(selectedRow.getSortedUnsortedCategory());
- batchNewRow.setSortedUnsortedCategoryWeight(selectedRow.getSortedUnsortedCategoryWeight());
+ newBatch.setSortedUnsortedCategory(parentBatch.getSortedUnsortedCategory());
+ newBatch.setSortedUnsortedCategoryWeight(parentBatch.getSortedUnsortedCategoryWeight());
}
if (selectedCategory == SampleCategoryType.size) {
- batchNewRow.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSizeCategoryWeight(row.getWeight());
+ newBatch.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSizeCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSizeCategory(selectedRow.getSizeCategory());
- batchNewRow.setSizeCategoryWeight(selectedRow.getSizeCategoryWeight());
+ newBatch.setSizeCategory(parentBatch.getSizeCategory());
+ newBatch.setSizeCategoryWeight(parentBatch.getSizeCategoryWeight());
}
if (selectedCategory == SampleCategoryType.sex) {
- batchNewRow.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSexCategoryWeight(row.getWeight());
+ newBatch.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSexCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSexCategory(selectedRow.getSexCategory());
- batchNewRow.setSexCategoryWeight(selectedRow.getSexCategoryWeight());
+ newBatch.setSexCategory(parentBatch.getSexCategory());
+ newBatch.setSexCategoryWeight(parentBatch.getSexCategoryWeight());
}
if (selectedCategory == SampleCategoryType.maturity) {
- batchNewRow.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setMaturityCategoryWeight(row.getWeight());
+ newBatch.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setMaturityCategoryWeight(row.getWeight());
} else {
- batchNewRow.setMaturityCategory(selectedRow.getMaturityCategory());
- batchNewRow.setMaturityCategoryWeight(selectedRow.getMaturityCategoryWeight());
+ newBatch.setMaturityCategory(parentBatch.getMaturityCategory());
+ newBatch.setMaturityCategoryWeight(parentBatch.getMaturityCategoryWeight());
}
if (selectedCategory == SampleCategoryType.age) {
- batchNewRow.setAgeCategory((Float) row.getCategoryValue());
- batchNewRow.setAgeCategoryWeight(row.getWeight());
+ newBatch.setAgeCategory((Float) row.getCategoryValue());
+ newBatch.setAgeCategoryWeight(row.getWeight());
} else {
- batchNewRow.setAgeCategory(selectedRow.getAgeCategory());
- batchNewRow.setAgeCategoryWeight(selectedRow.getAgeCategoryWeight());
+ newBatch.setAgeCategory(parentBatch.getAgeCategory());
+ newBatch.setAgeCategoryWeight(parentBatch.getAgeCategoryWeight());
}
- batchTableModel.addNewRow(++insertRow, batchNewRow);
- boolean rowValid = isRowValid(batchNewRow);
- batchNewRow.setValid(rowValid);
- saveRow(batchNewRow);
+ tableModel.addNewRow(++insertRow, newBatch);
+ boolean rowValid = isRowValid(newBatch);
+ newBatch.setValid(rowValid);
+ newBatch.setBatchParent(parentBatch);
+ newBatches.add(newBatch);
}
}
+ // add new batches to his parent
+ parentBatch.setChilds(newBatches);
+
+ //TODO Should only save parentBatch (will persist all his childs)
+ //saveRow(parentBatch);
+
+ // save new batches
+ saveRows(newBatches);
}
// reset split ui
- sampleCategoryEditor.getHandler().editBatch(null);
+ splitBatchEditor.getHandler().editBatch(null);
+ recomputeBatchActionEnable();
- // reselect this cell
- AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
- table.requestFocus();
+// // reselect this cell
+// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
+// table.requestFocus();
}
public void removeSpeciesSubBatch() {
//TODO
+ int rowIndex = getTable().getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove sub batch if no batch selected");
+
+ SpeciesBatchRowModel parentBatch = getTableModel().getEntry(rowIndex);
+
+ // collect of rows to remove from model
+ Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet();
+ collectChilds(parentBatch, rowToRemove);
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // remove childs from parent batch
+ parentBatch.setChilds(null);
+
+ // save parent batch (will destroy all his childs from db)
+ saveRow(parentBatch);
+
+ // refresh table from parent batch row index to the end
+ getTableModel().fireTableRowsUpdated(rowIndex,
+ getTableModel().getRowCount() - 1);
}
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRows(Iterable<SpeciesBatchRowModel> rows) {
+ for (SpeciesBatchRowModel row : rows) {
+ saveRow(row);
+ }
+ }
+
protected void saveRow(SpeciesBatchRowModel row) {
SpeciesBatch catchBean = row.toBean();
@@ -792,50 +790,6 @@
row.setFrequency(frequencyRows);
}
-// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
-// SpeciesBatchTreeNode node) {
-//
-// SpeciesBatchTreeNode superSamplingNode = node.getParent();
-//
-// Preconditions.checkNotNull(superSamplingNode,
-// "Super sampling node can't be null");
-//
-// SpeciesBatchTreeModel.SamplingContext samplingContext =
-// samplingTreeModel.createSamplingContext(superSamplingNode);
-//
-// float samplingTotalWeight = samplingContext.getTotalWeight();
-// Float superSamplingTotalWeight;
-// SpeciesBatchRowModel superSamplingRow =
-// samplingContext.getSuperSamplingRow();
-// if (superSamplingRow == null) {
-//
-// // Use directly the batch total weight (means no super-sampling)
-//
-// superSamplingTotalWeight = getModel().getSpeciesTotalWeight();
-// } else {
-// superSamplingTotalWeight = superSamplingRow.getWeight();
-// }
-//
-// if (log.isInfoEnabled()) {
-// log.info("Super sampling total weight: " +
-// superSamplingTotalWeight);
-// }
-//
-// Float samplingRatio = null;
-// if (superSamplingTotalWeight != null) {
-// samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
-// }
-//
-// if (log.isInfoEnabled()) {
-// log.info("Sampling ratio: " + samplingRatio);
-// }
-//
-// samplingContext.applyNewSampleValues(samplingTotalWeight,
-// samplingRatio);
-//
-// getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
-// }
-
protected void recomputeTotalHorsVrac() {
// recompute total hors vrac
@@ -873,6 +827,7 @@
// getModel().setTotalVracWeight(totalVrac);
}
+
protected void recomputeBatchActionEnable() {
int rowIndex = getTable().getSelectedRow();
@@ -903,13 +858,15 @@
if (enableSplit) {
- // the select batch can not have any batch child
+ // can split if selected batch is a leaf
+ enableSplit = row.isBatchLeaf();
}
if (enableRemove) {
- // the selected batch must have some batch child
+ // can remove sub batch if selected batch is not a leaf
+ enableRemove = !row.isBatchLeaf();
}
}
getModel().setCreateSpeciesBatchEnabled(enableAdd);
@@ -918,6 +875,18 @@
}
+ protected void collectChilds(SpeciesBatchRowModel row,
+ Set<SpeciesBatchRowModel> collectedRows) {
+
+ if (!row.isBatchLeaf()) {
+
+ for (SpeciesBatchRowModel batchChild : row.getBatchChild()) {
+ collectedRows.add(batchChild);
+ collectChilds(batchChild, collectedRows);
+ }
+ }
+ }
+
protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel,
ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier,
Decorator<C> decorator,
@@ -927,4 +896,49 @@
SampleCategoryComponent.newRender(defaultRenderer, decorator),
columnIdentifier);
}
+
+
+// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
+// SpeciesBatchTreeNode node) {
+//
+// SpeciesBatchTreeNode superSamplingNode = node.getParent();
+//
+// Preconditions.checkNotNull(superSamplingNode,
+// "Super sampling node can't be null");
+//
+// SpeciesBatchTreeModel.SamplingContext samplingContext =
+// samplingTreeModel.createSamplingContext(superSamplingNode);
+//
+// float samplingTotalWeight = samplingContext.getTotalWeight();
+// Float superSamplingTotalWeight;
+// SpeciesBatchRowModel superSamplingRow =
+// samplingContext.getSuperSamplingRow();
+// if (superSamplingRow == null) {
+//
+// // Use directly the batch total weight (means no super-sampling)
+//
+// superSamplingTotalWeight = getModel().getSpeciesTotalWeight();
+// } else {
+// superSamplingTotalWeight = superSamplingRow.getWeight();
+// }
+//
+// if (log.isInfoEnabled()) {
+// log.info("Super sampling total weight: " +
+// superSamplingTotalWeight);
+// }
+//
+// Float samplingRatio = null;
+// if (superSamplingTotalWeight != null) {
+// samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
+// }
+//
+// if (log.isInfoEnabled()) {
+// log.info("Sampling ratio: " + samplingRatio);
+// }
+//
+// samplingContext.applyNewSampleValues(samplingTotalWeight,
+// samplingRatio);
+//
+// getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
+// }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -25,9 +25,10 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
@@ -42,11 +43,11 @@
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
-import java.awt.Frame;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -76,7 +77,7 @@
return new FrequencyCellRenderer();
}
- public static TableCellEditor newEditor(SpeciesFrequencyUI ui) {
+ public static TableCellEditor newEditor(SpeciesBatchUI ui) {
return new FrequencyCellEditor(ui);
}
@@ -86,10 +87,8 @@
protected final FrequencyCellComponent component;
- protected final SpeciesFrequencyUI ui;
+ protected final SpeciesBatchUI ui;
- protected Frame frame;
-
protected JTable table;
protected SpeciesBatchTableModel tableModel;
@@ -102,7 +101,7 @@
protected Integer columnIndex;
- public FrequencyCellEditor(SpeciesFrequencyUI ui) {
+ public FrequencyCellEditor(SpeciesBatchUI ui) {
this.ui = ui;
component = new FrequencyCellComponent();
component.setBorder(new LineBorder(Color.BLACK));
@@ -138,20 +137,44 @@
log.info("Will edit frequencies for row: " + rowIndex);
}
- if (frame == null) {
- frame = SwingUtil.getParentContainer(ui, Frame.class);
- }
+ SpeciesFrequencyUI frequencyEditor = ui.getFrequencyEditor();
+ frequencyEditor.editBatch(editRow);
- ui.editBatch(editRow);
-
// open frequency dialog
- TuttiUIUtil.openInDialog(
- ui, frame, _("tutti.title.frequency"), true, null);
+ ui.getHandler().openDialog(ui,
+ frequencyEditor,
+ _("tutti.title.frequency"),
+ ui.getPreferredSize());
- // at close, synch back frequencies
+ SpeciesFrequencyUIModel frequencyModel = frequencyEditor.getModel();
- editRow.updateTotalFromFrequencies();
+ if (frequencyModel.isValid()) {
+ // at close, synch back frequencies
+
+ // transfer rows to editor
+ List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
+ for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ frequency.add(row);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Push back " + frequency.size() +
+ " frequency to batch " + frequencyModel.getBatch());
+ }
+
+ // push back to batch
+ editRow.setFrequency(frequency);
+
+ editRow.updateTotalFromFrequencies();
+ }
+
+ frequencyEditor.editBatch(null);
+
int r = rowIndex;
int c = columnIndex;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -35,7 +35,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -31,17 +31,17 @@
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.JDialog;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
@@ -54,7 +54,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
+public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -253,6 +253,27 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model (in that way)
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
@@ -352,8 +373,11 @@
newRow.setComputedWeight(rowModel.getComputedWeight());
editFrequency.add(newRow);
}
- lengthStepCaracteristic =
- frequency.get(0).getLengthStepCaracteristic();
+
+ if (CollectionUtils.isNotEmpty(frequency)) {
+ lengthStepCaracteristic =
+ frequency.get(0).getLengthStepCaracteristic();
+ }
}
if (log.isInfoEnabled()) {
@@ -363,6 +387,9 @@
SpeciesFrequencyUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
model.setRows(editFrequency);
if (lengthStepCaracteristic == null) {
@@ -387,49 +414,13 @@
model.setBatch(speciesBatch);
}
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- // when canceling always invalid model (in that way)
- getModel().setValid(false);
-
- ui.editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
if (log.isInfoEnabled()) {
- log.info("Will Save and close UI " + ui);
+ log.info("Save UI " + ui);
}
- SpeciesFrequencyUIModel model = getModel();
-
- // transfer rows to editor
- List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
- for (SpeciesFrequencyRowModel row : model.getRows()) {
- if (row.isValid()) {
-
- // can keep this row
- frequency.add(row);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Push back " + frequency.size() +
- " frequency to batch " + model.getBatch());
- }
-
- // push back to batch
- model.getBatch().setFrequency(frequency);
-
- ui.editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ closeDialog(ui);
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -36,7 +36,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 23:04:02 UTC (rev 137)
@@ -75,7 +75,7 @@
<field name='batchWeight' component='batchWeightField'/>
</BeanValidator>
- <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+ <JSplitPane id='splitPane' constraints='BorderLayout.NORTH'>
<Table id='configurationPanel' fill='both'>
@@ -113,7 +113,8 @@
<!-- Messages report -->
<JPanel id='messagePanel' layout='{new GridLayout()}'>
- <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JScrollPane id='errorTableScrollPane'
+ columnHeaderView='{errorTable.getTableHeader()}'>
<JTable id='errorTable'/>
</JScrollPane>
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -29,13 +29,12 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
-import jaxx.runtime.SwingUtil;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.JDialog;
import java.util.List;
/**
@@ -44,7 +43,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> {
+public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -104,15 +103,42 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
- public void editBatch(SpeciesBatchUIModel batchModel) {
+ public void openUI(SpeciesBatchUIModel batchModel) {
- getModel().setSpecies(null);
- getModel().setBatchWeight(null);
+ CreateSpeciesBatchUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
+ model.setSpecies(null);
+ model.setBatchWeight(null);
+
List<Species> speciesToUse = Lists.newArrayList();
+
if (batchModel != null) {
speciesToUse.addAll(batchModel.getAvailableSpecies());
@@ -121,26 +147,13 @@
ui.getSpeciesComboBox().setData(speciesToUse);
}
- public void cancel() {
-
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- // wehn canceling always invalid model
- getModel().setValid(false);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
-
if (log.isInfoEnabled()) {
log.info("Save UI " + ui);
}
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ // close dialog
+ closeDialog(ui);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -30,7 +30,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -33,18 +33,16 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.JDialog;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
@@ -56,7 +54,7 @@
* @since 0.3
*/
public class SplitSpeciesBatchUIHandler
- extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+ extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -198,15 +196,6 @@
}
});
- // when sample weight changed, revalidate model
- model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- validateModel();
- }
- });
-
generateTableModel(null);
initTable(getTable());
@@ -222,6 +211,27 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
@@ -285,6 +295,9 @@
SplitSpeciesBatchUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
model.setSampleWeight(null);
model.setCategory(categories);
model.setBatchWeight(batchWeight);
@@ -293,24 +306,13 @@
model.setBatch(batch);
}
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
if (log.isInfoEnabled()) {
log.info("Save UI " + ui);
}
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ closeDialog(ui);
}
//------------------------------------------------------------------------//
@@ -334,25 +336,6 @@
getModel().setSampleWeight(result);
}
- protected void validateModel() {
-
- SplitSpeciesBatchUIModel model = getModel();
-
- int rowCount = model.getRowCount();
-
- // at least one row
- boolean valid = rowCount > 0;
-
- if (valid && !model.isSample()) {
-
- // sample Weight = batch weight
- valid = ObjectUtils.equals(model.getBatchWeight(),
- model.getSampleWeight());
- }
-
- model.setValid(valid);
- }
-
protected void generateTableModel(SampleCategoryType category) {
// when generate a new table model, then reset previous rows from model
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -0,0 +1,36 @@
+package fr.ifremer.tutti.ui.swing.util;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * To cancel contract.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public interface Cancelable {
+
+ void cancel();
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -26,8 +26,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.TuttiServiceTechnicalException;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,20 +33,11 @@
import org.jdesktop.swingx.decorator.Highlighter;
import org.nuiton.util.FileUtil;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.io.File;
/**
@@ -66,51 +55,51 @@
// never instanciate util class
}
- public static JDialog openInDialog(JComponent ui,
- Frame frame,
- String title,
- boolean modal,
- Action closeAction) {
- return openInDialog(ui, frame, title, modal, closeAction, null);
- }
+ // public static JDialog openInDialog(JComponent ui,
+// Frame frame,
+// String title,
+// boolean modal,
+// Action closeAction) {
+// return openInDialog(ui, frame, title, modal, closeAction, null);
+// }
+//
+// public static JDialog openInDialog(JComponent ui,
+// Frame frame,
+// String title,
+// boolean modal,
+// Action closeAction,
+// Dimension dim) {
+//
+// JDialog result = new JDialog(frame, modal);
+// result.setTitle(title);
+// result.add(ui);
+// result.setResizable(true);
+// if (dim == null) {
+// result.setSize(550, 450);
+// } else {
+// result.setSize(dim);
+// }
+// if (closeAction != null) {
+// JRootPane rootPane = result.getRootPane();
+// rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+// rootPane.getActionMap().put("close", closeAction);
+// }
+// result.addWindowListener(new WindowAdapter() {
+//
+// @Override
+// public void windowClosed(WindowEvent e) {
+// Component ui = (Component) e.getSource();
+// if (log.isInfoEnabled()) {
+// log.info("Destroy ui " + ui);
+// }
+// JAXXUtil.destroy(ui);
+// }
+// });
+// SwingUtil.center(frame, result);
+// result.setVisible(true);
+// return result;
+// }
- public static JDialog openInDialog(JComponent ui,
- Frame frame,
- String title,
- boolean modal,
- Action closeAction,
- Dimension dim) {
-
- JDialog result = new JDialog(frame, modal);
- result.setTitle(title);
- result.add(ui);
- result.setResizable(true);
- if (dim == null) {
- result.setSize(550, 450);
- } else {
- result.setSize(dim);
- }
- if (closeAction != null) {
- JRootPane rootPane = result.getRootPane();
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
- rootPane.getActionMap().put("close", closeAction);
- }
- result.addWindowListener(new WindowAdapter() {
-
- @Override
- public void windowClosed(WindowEvent e) {
- Component ui = (Component) e.getSource();
- if (log.isInfoEnabled()) {
- log.info("Destroy ui " + ui);
- }
- JAXXUtil.destroy(ui);
- }
- });
- SwingUtil.center(frame, result);
- result.setVisible(true);
- return result;
- }
-
/**
* Choisir un fichier via un sélecteur graphique de fichiers.
*
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 23:04:02 UTC (rev 137)
@@ -240,6 +240,7 @@
tutti.title.create.cruise=Créer une nouvelle campagne
tutti.title.create.program=Créer une nouvelle série de campagne
tutti.title.create.protocol=Créer un nouveau protocol de saisie
+tutti.title.createBatch=Créer un lot pour une nouvelle espèce
tutti.title.edit.cruise=Éditer une campagne existante
tutti.title.edit.operations=Saisie des opérations de pêches (%s)
tutti.title.edit.program=Éditer une série de campagne existante
1
0
r136 - in trunk: tutti-persistence tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split
by tchemit@users.forge.codelutin.com 01 Jan '13
by tchemit@users.forge.codelutin.com 01 Jan '13
01 Jan '13
Author: tchemit
Date: 2013-01-01 19:27:33 +0100 (Tue, 01 Jan 2013)
New Revision: 136
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/136
Log:
optimize dependencies
Modified:
trunk/tutti-persistence/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-persistence/pom.xml 2013-01-01 18:27:33 UTC (rev 136)
@@ -26,6 +26,11 @@
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 18:27:33 UTC (rev 136)
@@ -26,7 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
@@ -38,7 +38,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
1
0
01 Jan '13
Author: tchemit
Date: 2013-01-01 17:10:44 +0100 (Tue, 01 Jan 2013)
New Revision: 135
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/135
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons
- am?\195?\169lioration de l'api table
- am?\195?\169lioration de la saisie des mensurations
- ajout de la validation ?\195?\160 diff?\195?\169rents endroits
- d?\195?\169but d'utilisation du protocole dans l'?\195?\169cran de saisie des lots de poisson (mais non test?\195?\169 et non fini)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java
Modified:
trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -72,6 +72,8 @@
List<Species> getAllSpecies();
+ Species getSpecies(String speciesId);
+
List<FishingOperationLocation> getAllFishingOperationStrata(String zoneId);
List<FishingOperationLocation> getAllFishingOperationSubStrata(String locationId);
Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
===================================================================
--- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -191,6 +191,12 @@
}
@Override
+ public Species getSpecies(String id) {
+ Species result = getBean(Species.class, id);
+ return result;
+ }
+
+ @Override
public List<Zone> getAllZone() {
List<Zone> result = getDataInNewList(Zone.class);
return result;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -137,6 +137,12 @@
}
@Override
+ public Species getSpecies(String speciesId) {
+ checkDriverExists();
+ return driver.getSpecies(speciesId);
+ }
+
+ @Override
public List<Zone> getAllZone() {
checkDriverExists();
return driver.getAllZone();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -57,7 +57,7 @@
text: "tutti.action.manageProtocol";
toolTipText: "tutti.action.manageProtocol.tip";
mnemonic: P;
- enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
+ enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.isProtocolFilled()};
/*actionIcon: "protocol";*/
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -68,11 +68,12 @@
PROPERTY_CRUISE_ID,
PROPERTY_PROTOCOL_ID);
-
public static final String PROPERTY_SCREEN = "screen";
public static final String PROPERTY_CRUISE_CONTEXT_FILLED = "cruiseContextFilled";
+ public static final String PROPERTY_PROTOCOL_FILLED = "protocolFilled";
+
/**
* Application context (only one for all the application).
*
@@ -190,6 +191,10 @@
StringUtils.isNotBlank(cruiseId);
}
+ public boolean isProtocolFilled() {
+ return StringUtils.isNotBlank(protocolId);
+ }
+
public TuttiScreen getScreen() {
return screen;
}
@@ -217,11 +222,13 @@
}
public void setProtocolId(String protocolId) {
-
+ boolean oldValue = isProtocolFilled();
this.protocolId = protocolId;
// always propagate the change
firePropertyChange(PROPERTY_PROTOCOL_ID, null, protocolId);
+ firePropertyChange(PROPERTY_PROTOCOL_FILLED,
+ oldValue, isProtocolFilled());
}
public void setScreen(TuttiScreen screen) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -143,7 +143,7 @@
}
#headOfMissionList {
- property: "headOfMission";
+ property: headOfMission;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfMission"))};
}
@@ -177,17 +177,18 @@
text: "tutti.action.generateCampaignName";
enabled: {model.isCanGenerateName()};
}
+
#messagePanel {
border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
- height: 200;
- width: 500;
+ /*height: 200;
+ width: 500;*/
}
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -36,6 +36,7 @@
property: program;
beanType: {Program.class};
selectedItem: {model.getProgram()};
+ enabled: {!programCombobox.isEmpty()};
}
#editProgramButton {
@@ -56,8 +57,8 @@
#cruiseCombobox {
property: cruise;
- enabled: {model.isProgramFound()};
selectedItem: {model.getCruise()};
+ enabled: {!cruiseCombobox.isEmpty()};
}
#editCruiseButton {
@@ -80,6 +81,7 @@
#protocolCombobox {
property: protocol;
selectedItem: {model.getProtocol()};
+ enabled: {!protocolCombobox.isEmpty()};
}
#editProtocolButton {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -30,7 +30,6 @@
import com.ezware.oxbow.swingbits.table.filter.JTableFilter;
import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
@@ -114,7 +113,7 @@
TableColumnModel columnModel,
AbstractTuttiTableModel<R> tableModel) {
- installTableKeyListener(columnModel, table, true);
+ installTableKeyListener(columnModel, table);
JTableFilter tableFilter = new JTableFilter(table);
TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -276,8 +276,8 @@
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -67,7 +67,7 @@
public AccidentalBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel,true, true);
setNoneEditableCols();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -130,6 +130,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ AccidentalBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor,
AccidentalBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -82,7 +82,7 @@
n_("tutti.table.benthos.batch.header.toConfirm"));
public BenthosBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -34,6 +34,7 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentRowModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
@@ -133,6 +134,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ BenthosBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor,
BenthosBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -70,7 +70,7 @@
n_("tutti.table.macrowaste.batch.header.file"));
public MacroWasteBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -132,6 +132,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ MacroWasteBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor,
MacroWasteBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -75,7 +75,7 @@
n_("tutti.table.plankton.batch.header.file"));
public PlanktonBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -131,6 +131,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ PlanktonBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor,
PlanktonBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
+import org.apache.commons.lang.ObjectUtils;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -70,4 +71,15 @@
public SampleCategoryEnum getType() {
return type;
}
+
+ public static SampleCategoryType valueOf(SampleCategoryEnum type) {
+ SampleCategoryType result = null;
+ for (SampleCategoryType sampleCategoryType : values()) {
+ if (ObjectUtils.equals(type, sampleCategoryType.type)) {
+ result = sampleCategoryType;
+ break;
+ }
+ }
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -152,7 +152,7 @@
protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
public SpeciesBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols();
// setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -79,14 +79,18 @@
label: "tutti.title.batchActions";
}
-#splitBatchMenu {
- text: "tutti.action.splitBatch";
+#splitSpeciesBatchMenu {
+ text: "tutti.action.splitSpeciesBatch";
+ mnemonic: S;
actionIcon: batch-split;
+ enabled: {model.isSplitSpeciesBatchEnabled()};
}
-#removeSubBatchMenu {
- text: "tutti.action.removeSubBatch";
+#removeSpeciesSubBatchMenu {
+ text: "tutti.action.removeSpeciesSubBatch";
+ mnemonic: R;
actionIcon: batch-delete;
+ enabled: {model.isRemoveSpeciesSubBatchEnabled()};
}
#table {
@@ -97,8 +101,10 @@
}
#createSpeciesBatchButton {
- actionIcon: batch-split;
+ actionIcon: batch-create;
+ mnemonic: C;
text: "tutti.action.createSpeciesBatch";
+ enabled: {model.isCreateSpeciesBatchEnabled()};
}
#filterTablePane {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -26,10 +26,10 @@
<import>
fr.ifremer.tutti.ui.swing.TuttiUI
- fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
@@ -81,18 +81,19 @@
<SpeciesFrequencyUI id='frequencyEditor' constructorParams='this'/>
- <SplitSampleCategoryUI id='sampleCategoryEditor' constructorParams='this'/>
+ <CreateSpeciesBatchUI id='createSpeciesBatchUI' constructorParams='this'/>
+ <SplitSpeciesBatchUI id='splitSpeciesBatchUI' constructorParams='this'/>
<LongTextEditorUI id='longTextEditor'/>
<AttachmentEditorUI id='attachmentEditor'/>
- <JPopupMenu id='tablePopup'
- onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>
- <JMenuItem id='splitBatchMenu'
- onActionPerformed='handler.splitBatch()'/>
- <JMenuItem id='removeSubBatchMenu'
- onActionPerformed='handler.removeBatch()'/>
+ <JPopupMenu id='tablePopup'>
+ <!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>-->
+ <JMenuItem id='splitSpeciesBatchMenu'
+ onActionPerformed='handler.splitSpeciesBatch()'/>
+ <JMenuItem id='removeSpeciesSubBatchMenu'
+ onActionPerformed='handler.removeSpeciesSubBatch()'/>
</JPopupMenu>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
@@ -144,7 +145,6 @@
<JRadioButton id='filterSpeciesBatchRootButton'
onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
</JPanel>
-
</JPanel>
</cell>
</row>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -30,8 +30,11 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -42,9 +45,9 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUI;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
@@ -52,6 +55,7 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -134,6 +138,9 @@
SpeciesBatchUIModel model = getModel();
+ List<Species> availableSpecies =
+ Lists.newArrayList(model.getAllSpecies());
+
List<SpeciesBatchRowModel> rows;
if (empty) {
@@ -147,6 +154,9 @@
rows = Lists.newArrayList();
if (!TuttiEntities.isNew(bean)) {
+
+ Set<Species> speciesUsed = Sets.newHashSet();
+
List<SpeciesBatch> catches =
persistenceService.getAllSpeciesBatch(bean.getId());
for (SpeciesBatch aBatch : catches) {
@@ -155,10 +165,15 @@
SpeciesBatchRowModel entry =
new SpeciesBatchRowModel(aBatch, frequencies);
rows.add(entry);
+ speciesUsed.add(entry.getSpecies());
}
+ availableSpecies.removeAll(speciesUsed);
}
}
+
+ model.setAvailableSpecies(availableSpecies);
model.setRows(rows);
+ recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -195,59 +210,12 @@
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
- SpeciesBatchRowModel row) {
-
- if (row.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + row + " was modified, will save it");
- }
-
- showInformationMessage(
- "[ Captures - Espèces ] " +
- "Sauvegarde des modifications de " + row + ".");
-
- saveRow(row);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- SpeciesBatch catchBean = row.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteSpeciesBatch(catchBean.getId());
- }
- }
- }
-
- @Override
- protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // build the new sampling tree from the new rows to edit
-// getModel().getSamplingTreeModel().populate(rows);
- }
-
- @Override
protected void onRowModified(int rowIndex,
SpeciesBatchRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
-
if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
// Need to recompute totalHorsVracWeight
@@ -257,17 +225,19 @@
if (SAMPLING_PROPERTIES.contains(propertyName)) {
// species has changed, recompute valid property
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
+ recomputeRowValidState(row);
}
if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
// weight has changed, recompute valid property
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
+ recomputeRowValidState(row);
}
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+
+
// SpeciesBatchUIModel model = getModel();
//
// SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
@@ -344,6 +314,70 @@
// }
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
+ SpeciesBatchRowModel row) {
+
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
+
+ showInformationMessage(
+ "[ Captures - Espèces ] " +
+ "Sauvegarde des modifications de " + row + ".");
+
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ SpeciesBatch catchBean = row.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteSpeciesBatch(catchBean.getId());
+ }
+ }
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // build the new sampling tree from the new rows to edit
+// getModel().getSamplingTreeModel().populate(rows);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex, SpeciesBatchRowModel row, Boolean oldValue, Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
+ @Override
+ protected void onAfterSelectedRowChanged(int oldRowIndex,
+ SpeciesBatchRowModel oldRow,
+ int newRowIndex,
+ SpeciesBatchRowModel newRow) {
+ super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
+
+ // when selected row has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -386,17 +420,60 @@
initUI(ui);
- //TODO Will come from protocol
- List<String> samplingOrder = Lists.newArrayList(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY
- );
+ List<SampleCategoryType> samplingOrder;
+ List<Species> allSpecies;
+
+ if (getContext().isProtocolFilled()) {
+
+ // there is a protocol
+
+ TuttiProtocol protocol =
+ persistenceService.getProtocol(getContext().getProtocolId());
+
+ // fill sampling order from protocol
+
+ List<SampleCategoryEnum> sampleCategoryOrder =
+ protocol.getSampleCategoryOrder();
+ samplingOrder = Lists.newArrayList();
+ for (SampleCategoryEnum sampleCategoryEnum : sampleCategoryOrder) {
+
+ SampleCategoryType sampleCategoryType =
+ SampleCategoryType.valueOf(sampleCategoryEnum);
+ samplingOrder.add(sampleCategoryType);
+ }
+
+ // fill available species from protocol
+
+ allSpecies = Lists.newArrayList();
+ List<SpeciesProtocol> protocolSpecies = protocol.getSpecies();
+ for (SpeciesProtocol protocolSpecy : protocolSpecies) {
+ Species species = persistenceService.getSpecies(
+ protocolSpecy.getSpeciesId());
+ allSpecies.add(species);
+ }
+
+ } else {
+ // no protocol, use default values
+
+ samplingOrder = Lists.newArrayList(
+ SampleCategoryType.sortedUnsorted,
+ SampleCategoryType.size,
+ SampleCategoryType.sex,
+ SampleCategoryType.maturity,
+ SampleCategoryType.age);
+
+ allSpecies = Lists.newArrayList(
+ persistenceService.getAllSpecies());
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will use sampling order: " + samplingOrder);
+ log.info("Will use " + allSpecies.size() + " species.");
+ }
+
getModel().setSamplingOrder(samplingOrder);
+ getModel().setAllSpecies(allSpecies);
JXTable table = getTable();
@@ -409,8 +486,6 @@
Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
getDecorator(CaracteristicQualitativeValue.class, null);
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
{ // Species (by code) column
Decorator<Species> decorator = getDecorator(
@@ -541,9 +616,11 @@
//------------------------------------------------------------------------//
public void autoSelectRowInTable(MouseEvent e) {
- if (SwingUtilities.isRightMouseButton(e) ||
- e.isPopupTrigger()) {
+ boolean rightClick = SwingUtilities.isRightMouseButton(e);
+
+ if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
+
// get the coordinates of the mouse click
Point p = e.getPoint();
@@ -552,56 +629,31 @@
// get the row index at this point
int rowIndex = source.rowAtPoint(p);
- if (log.isInfoEnabled()) {
- log.info("At point [" + p + "] found Row " + rowIndex);
+ if (log.isDebugEnabled()) {
+ log.debug("At point [" + p + "] found Row " + rowIndex);
}
- if (rowIndex != -1) {
- // select new row
+ // select row (could empty selection)
+ if (rowIndex == -1) {
+ source.clearSelection();
+ } else {
source.setRowSelectionInterval(rowIndex, rowIndex);
}
- ui.getTablePopup().show(source, e.getX(), e.getY());
- }
- }
+ if (rightClick) {
- public void updateTablePopup() {
-
- int rowIndex = getTable().getSelectedRow();
- boolean enableSplit = false;
- boolean enableRemove = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
-
- if (row.isValid()) {
-
- // must have at least species filled in row
- // otherwise nothing can be done
-
- enableSplit = true;
+ // on right click show popup
+ ui.getTablePopup().show(source, e.getX(), e.getY());
}
}
-
- ui.getSplitBatchMenu().setEnabled(enableSplit);
- ui.getRemoveSubBatchMenu().setEnabled(enableRemove);
}
- public void removeBatch() {
- //TODO
- }
-
public void createSpeciesBatch() {
}
- public void splitBatch() {
+ public void splitSpeciesBatch() {
+
JXTable table = getTable();
// get selected row
@@ -611,7 +663,7 @@
if (log.isInfoEnabled()) {
log.info("Open split batch for row [" + rowIndex + "]");
}
- SplitSampleCategoryUI sampleCategoryEditor = ui.getSampleCategoryEditor();
+ SplitSpeciesBatchUI sampleCategoryEditor = ui.getSplitSpeciesBatchUI();
sampleCategoryEditor.getHandler().editBatch(selectedRow);
Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
@@ -622,7 +674,7 @@
_("tutti.title.splitBatch"), true, null);
// at close, synch back batches ?
- SplitSampleCategoryUIModel splitModel = sampleCategoryEditor.getModel();
+ SplitSpeciesBatchUIModel splitModel = sampleCategoryEditor.getModel();
if (splitModel.isValid()) {
@@ -637,7 +689,7 @@
// Create rows in batch table model
List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList();
- for (SplitSampleCategoryRowModel row : splitModel.getRows()) {
+ for (SplitSpeciesBatchRowModel row : splitModel.getRows()) {
if (row.isValid()) {
// can keep this row
@@ -696,6 +748,10 @@
table.requestFocus();
}
+ public void removeSpeciesSubBatch() {
+ //TODO
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
@@ -817,6 +873,51 @@
// getModel().setTotalVracWeight(totalVrac);
}
+ protected void recomputeBatchActionEnable() {
+
+ int rowIndex = getTable().getSelectedRow();
+
+ boolean enableAdd =
+ CollectionUtils.isNotEmpty(getModel().getAvailableSpecies());
+
+ boolean enableSplit = false;
+ boolean enableRemove = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+
+ if (row.isValid()) {
+
+ // must have at least species filled in row
+ // otherwise nothing can be done
+
+ enableSplit = true;
+ enableRemove = true;
+ }
+
+ if (enableSplit) {
+
+ // the select batch can not have any batch child
+
+ }
+
+ if (enableRemove) {
+
+ // the selected batch must have some batch child
+ }
+ }
+ getModel().setCreateSpeciesBatchEnabled(enableAdd);
+ getModel().setSplitSpeciesBatchEnabled(enableSplit);
+ getModel().setRemoveSpeciesSubBatchEnabled(enableRemove);
+
+ }
+
protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel,
ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier,
Decorator<C> decorator,
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
@@ -40,15 +41,38 @@
public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode";
+ public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies";
+ public static final String PROPERTY_ALL_SPECIES = "allSpecies";
+
+ public static final String PROPERTY_CREATE_SPECIES_BATCH_ENABLED = "createSpeciesBatchEnabled";
+
+ public static final String PROPERTY_SPLIT_SPECIES_BATCH_ENABLED = "splitSpeciesBatchEnabled";
+
+ public static final String PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED = "removeSpeciesSubBatchEnabled";
+
/**
* Sampling order (sets by protocol).
*
* @since 0.2
*/
- protected List<String> samplingOrder;
+ protected List<SampleCategoryType> samplingOrder;
/**
+ * All usable species (sets by protocol).
+ *
+ * @since 0.3
+ */
+ protected List<Species> allSpecies;
+
+ /**
+ * All available species (says available species that are not used in any batch).
+ *
+ * @since 0.3
+ */
+ protected List<Species> availableSpecies;
+
+ /**
* What to show in the table.
*
* @since 0.3
@@ -56,6 +80,27 @@
protected TableViewMode tableViewMode;
/**
+ * Can user create a new species batch ?
+ *
+ * @since 0.3
+ */
+ protected boolean createSpeciesBatchEnabled;
+
+ /**
+ * Can user split a selected species batch ?
+ *
+ * @since 0.3
+ */
+ protected boolean splitSpeciesBatchEnabled;
+
+ /**
+ * Can user remove a selected species sub batches?
+ *
+ * @since 0.3
+ */
+ protected boolean removeSpeciesSubBatchEnabled;
+
+ /**
* Tree of sampling for batch rows.
*
* @since 0.2
@@ -107,13 +152,12 @@
return samplingTreeModel;
}
- public List<String> getSamplingOrder() {
+ public List<SampleCategoryType> getSamplingOrder() {
return samplingOrder;
}
- public void setSamplingOrder(List<String> samplingOrder) {
+ public void setSamplingOrder(List<SampleCategoryType> samplingOrder) {
this.samplingOrder = samplingOrder;
- samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()]));
}
public TableViewMode getTableViewMode() {
@@ -140,4 +184,54 @@
public boolean isTableViewModeRoot() {
return TableViewMode.ROOT.equals(tableViewMode);
}
+
+ public List<Species> getAllSpecies() {
+ return allSpecies;
+ }
+
+ public void setAllSpecies(List<Species> allSpecies) {
+ Object oldValue = getAllSpecies();
+ this.allSpecies = allSpecies;
+ firePropertyChange(PROPERTY_ALL_SPECIES, oldValue, allSpecies);
+ }
+
+ public List<Species> getAvailableSpecies() {
+ return availableSpecies;
+ }
+
+ public void setAvailableSpecies(List<Species> availableSpecies) {
+ Object oldValue = getAvailableSpecies();
+ this.availableSpecies = availableSpecies;
+ firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies);
+ }
+
+ public boolean isCreateSpeciesBatchEnabled() {
+ return createSpeciesBatchEnabled;
+ }
+
+ public void setCreateSpeciesBatchEnabled(boolean createSpeciesBatchEnabled) {
+ Object oldValue = isCreateSpeciesBatchEnabled();
+ this.createSpeciesBatchEnabled = createSpeciesBatchEnabled;
+ firePropertyChange(PROPERTY_CREATE_SPECIES_BATCH_ENABLED, oldValue, createSpeciesBatchEnabled);
+ }
+
+ public boolean isSplitSpeciesBatchEnabled() {
+ return splitSpeciesBatchEnabled;
+ }
+
+ public void setSplitSpeciesBatchEnabled(boolean splitSpeciesBatchEnabled) {
+ Object oldValue = isSplitSpeciesBatchEnabled();
+ this.splitSpeciesBatchEnabled = splitSpeciesBatchEnabled;
+ firePropertyChange(PROPERTY_SPLIT_SPECIES_BATCH_ENABLED, oldValue, splitSpeciesBatchEnabled);
+ }
+
+ public boolean isRemoveSpeciesSubBatchEnabled() {
+ return removeSpeciesSubBatchEnabled;
+ }
+
+ public void setRemoveSpeciesSubBatchEnabled(boolean removeSpeciesSubBatchEnabled) {
+ Object oldValue = isRemoveSpeciesSubBatchEnabled();
+ this.removeSpeciesSubBatchEnabled = removeSpeciesSubBatchEnabled;
+ firePropertyChange(PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED, oldValue, removeSpeciesSubBatchEnabled);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -177,11 +177,11 @@
firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
}
- //TODO Use validator
- @Override
- public boolean isValid() {
- return lengthStep != null && number != null && lengthStepCaracteristic != null;
- }
+// //TODO Use validator
+// @Override
+// public boolean isValid() {
+// return lengthStep != null && number != null && lengthStepCaracteristic != null;
+// }
@Override
public int compareTo(SpeciesFrequencyRowModel o) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -71,7 +71,7 @@
public SpeciesFrequencyTableModel(TableColumnModel columnModel,
SpeciesFrequencyUIModel uiModel) {
- super(columnModel);
+ super(columnModel, true, true);
this.uiModel = uiModel;
this.rowCache = Maps.newTreeMap();
setNoneEditableCols(COMPUTED_WEIGHT);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -33,6 +33,13 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
}
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
#stepLabel {
text: "tutti.label.frequencyConfiguration.step";
labelFor: {stepField};
@@ -46,12 +53,12 @@
bean: {model};
}
-#lenghtStepCaracteristicLabel {
+#lengthStepCaracteristicLabel {
text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic";
- labelFor: {lenghtStepCaracteristicComboBox};
+ labelFor: {lengthStepCaracteristicComboBox};
}
-#lenghtStepCaracteristicComboBox {
+#lengthStepCaracteristicComboBox {
property: lengthStepCaracteristic;
selectedItem: {model.getLengthStepCaracteristic()};
}
@@ -157,4 +164,32 @@
selectionForeground: {Color.BLACK};
sortable: false;
enabled: {model.getLengthStepCaracteristic() != null}
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ mnemonic: C;
+ text: "tutti.action.cancel";
+}
+
+#saveButton {
+ actionIcon: save;
+ mnemonic: S;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -35,6 +35,9 @@
jaxx.runtime.swing.editor.bean.BeanComboBox
jaxx.runtime.swing.editor.NumberEditor
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
org.jdesktop.swingx.JXTable
javax.swing.ListSelectionModel
@@ -71,113 +74,135 @@
<SpeciesFrequencyUIModel id='model'
initializer='getContextValue(SpeciesFrequencyUIModel.class)'/>
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='lengthStepCaracteristic' component='lengthStepCaracteristicComboBox'/>
+ <field name='rows' component='tableScrollPane'/>
+ </BeanValidator>
+
<CardLayout2Ext id='modeConfigurationLayout'
constructorParams='this, "modeConfigurationPanel"'/>
- <JPanel id='configurationPanel' layout='{new BorderLayout()}'
- constraints='BorderLayout.NORTH'>
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
- <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
- <VBox id='modePanel' constraints='BorderLayout.WEST'
- verticalAlignment='{SwingConstants.CENTER}'>
- <JRadioButton id='simpleModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/>
- <JRadioButton id='autoGenModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/>
- <JRadioButton id='rafaleModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/>
- </VBox>
+ <JPanel layout='{new BorderLayout()}'>
- <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'>
- <JPanel id='simpleModePanel' constraints='"simpleMode"'
- layout='{new BorderLayout()}'>
- <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/>
+ <JPanel id='configurationPanel' layout='{new BorderLayout()}'
+ constraints='BorderLayout.NORTH'>
+
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
+ <VBox id='modePanel' constraints='BorderLayout.WEST'
+ verticalAlignment='{SwingConstants.CENTER}'>
+ <JRadioButton id='simpleModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/>
+ <JRadioButton id='autoGenModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/>
+ <JRadioButton id='rafaleModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/>
+ </VBox>
+
+ <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'>
+ <JPanel id='simpleModePanel' constraints='"simpleMode"'
+ layout='{new BorderLayout()}'>
+ <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/>
+ </JPanel>
+ <JPanel id='autoGenModePanel' constraints='"autoGenMode"'>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <!-- Min step-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='minStepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='minStepField' constructorParams='this'/>
+ </cell>
+ </row>
+ <!-- Max step-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='maxStepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='maxStepField' constructorParams='this'/>
+ </cell>
+ </row>
+ <!-- Actions -->
+ <row>
+ <cell columns='2'>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='generateButton'
+ onActionPerformed='handler.generateLengthSteps()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ <JPanel id='rafaleModePanel' constraints='"rafaleMode"'>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <!-- Rafale step-->
+ <row>
+ <cell weightx='1.0'>
+ <JLabel id='rafaleStepLabel'/>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1.0'>
+ <NumberEditor id='rafaleStepField'
+ constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </JPanel>
</JPanel>
- <JPanel id='autoGenModePanel' constraints='"autoGenMode"'>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <!-- Min step-->
- <row>
- <cell anchor='west'>
- <JLabel id='minStepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='minStepField' constructorParams='this'/>
- </cell>
- </row>
- <!-- Max step-->
- <row>
- <cell anchor='west'>
- <JLabel id='maxStepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='maxStepField' constructorParams='this'/>
- </cell>
- </row>
- <!-- Actions -->
- <row>
- <cell columns='2'>
- <JPanel layout='{new GridLayout(1, 0)}'>
- <JButton id='generateButton'
- onActionPerformed='handler.generateLengthSteps()'/>
- </JPanel>
- </cell>
- </row>
- </Table>
- </JPanel>
- <JPanel id='rafaleModePanel' constraints='"rafaleMode"'>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <!-- Rafale step-->
- <row>
- <cell weightx='1.0'>
- <JLabel id='rafaleStepLabel'/>
- </cell>
- </row>
- <row>
- <cell weightx='1.0'>
- <NumberEditor id='rafaleStepField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
- </JPanel>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <row>
+ <cell columns='2'>
+ <JSeparator/>
+ </cell>
+ </row>
+ <!-- length step caracteristic -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='lengthStepCaracteristicLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='lengthStepCaracteristicComboBox'
+ constructorParams='this'
+ genericType='Caracteristic'/>
+ </cell>
+ </row>
+ <!-- Step -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='stepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='stepField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
</JPanel>
- </JPanel>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <row>
- <cell columns='2'>
- <JSeparator/>
- </cell>
- </row>
- <!-- length step caracteristic -->
- <row>
- <cell anchor='west'>
- <JLabel id='lenghtStepCaracteristicLabel'/>
- </cell>
- <cell weightx='1.0'>
- <BeanComboBox id='lenghtStepCaracteristicComboBox'
- constructorParams='this'
- genericType='Caracteristic'/>
- </cell>
- </row>
- <!-- Step -->
- <row>
- <cell anchor='west'>
- <JLabel id='stepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='stepField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table'/>
- </JScrollPane>
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
- <!-- actions -->
- <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
- constraints='BorderLayout.SOUTH'>
- <JButton id='closeButton' onActionPerformed='handler.close()'/>
- </JPanel>
+ <!-- actions -->
+ <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+ </JPanel>
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
</JPanel>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -34,7 +34,8 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
-import org.apache.commons.collections.CollectionUtils;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -92,23 +93,20 @@
@Override
protected boolean isRowValid(SpeciesFrequencyRowModel row) {
- //TODO
- return row.getLengthStep() != null && row.getWeight() != null;
+ return row.getLengthStepCaracteristic() != null &&
+ row.getLengthStep() != null &&
+ row.getNumber() != null;
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesFrequencyRowModel> rowMonitor,
- SpeciesFrequencyRowModel row) {
- }
-
- @Override
protected void onRowModified(int rowIndex,
SpeciesFrequencyRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+ recomputeRowValidState(row);
+
if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
// Need to recompute the computedWeight
@@ -116,6 +114,20 @@
}
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesFrequencyRowModel> rowMonitor,
+ SpeciesFrequencyRowModel row) {
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex,
+ SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+ ui.getValidator().doValidate();
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -147,7 +159,7 @@
SpeciesFrequencyUIModel model = getModel();
//TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
- initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(),
+ initBeanComboBox(ui.getLengthStepCaracteristicComboBox(),
lengthStepCaracterics,
model.getLengthStepCaracteristic());
@@ -180,7 +192,9 @@
Caracteristic newValue = (Caracteristic) evt.getNewValue();
for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
rowModel.setLengthStepCaracteristic(newValue);
+ recomputeRowValidState(rowModel);
}
+ ui.getValidator().doValidate();
}
});
@@ -224,9 +238,14 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- installTableKeyListener(columnModel, table, true);
+ installTableKeyListener(columnModel, table);
initTable(table);
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), model);
}
@Override
@@ -240,6 +259,7 @@
public void generateLengthSteps() {
SpeciesFrequencyUIModel model = getModel();
+ SpeciesFrequencyTableModel tableModel = getTableModel();
Map<Float, SpeciesFrequencyRowModel> rowsByStep =
getTableModel().getRowCache();
@@ -251,7 +271,7 @@
if (!rowsByStep.containsKey(i)) {
// add it
- SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel();
+ SpeciesFrequencyRowModel newRow = tableModel.createNewRow();
newRow.setLengthStep(i);
rowsByStep.put(i, newRow);
}
@@ -289,7 +309,8 @@
} else {
// create a new row
- row = new SpeciesFrequencyRowModel();
+
+ row = tableModel.createNewRow();
row.setLengthStep(aroundLengthStep);
row.setNumber(1);
@@ -307,28 +328,36 @@
getTable().scrollRowToVisible(rowIndex);
}
- public void editBatch(SpeciesBatchRowModel row) {
+ public void editBatch(SpeciesBatchRowModel speciesBatch) {
List<SpeciesFrequencyRowModel> frequency = null;
Caracteristic lengthStepCaracteristic = null;
- if (row != null) {
- frequency = row.getFrequency();
+ if (speciesBatch != null) {
+ frequency = speciesBatch.getFrequency();
}
- List<SpeciesFrequencyRowModel> editFrequency;
- if (CollectionUtils.isEmpty(frequency)) {
+ List<SpeciesFrequencyRowModel> editFrequency = Lists.newArrayList();
- // new list
- editFrequency = Lists.newArrayList();
- } else {
+ if (frequency != null) {
- editFrequency = Lists.newArrayList(frequency);
- lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic();
+ SpeciesFrequencyTableModel tableModel = getTableModel();
+
+ for (SpeciesFrequencyRowModel rowModel : frequency) {
+
+ SpeciesFrequencyRowModel newRow = tableModel.createNewRow();
+ newRow.setLengthStepCaracteristic(rowModel.getLengthStepCaracteristic());
+ newRow.setLengthStep(rowModel.getLengthStep());
+ newRow.setNumber(rowModel.getNumber());
+ newRow.setComputedWeight(rowModel.getComputedWeight());
+ editFrequency.add(newRow);
+ }
+ lengthStepCaracteristic =
+ frequency.get(0).getLengthStepCaracteristic();
}
if (log.isInfoEnabled()) {
- log.info("Will edit batch row: " + row + " with " +
+ log.info("Will edit batch row: " + speciesBatch + " with " +
editFrequency.size() + " frequency");
}
@@ -355,15 +384,29 @@
}
// keep batch (will be used to push back editing entry)
- model.setBatch(row);
+ model.setBatch(speciesBatch);
}
- public void close() {
+ public void cancel() {
if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
+ log.info("Cancel UI " + ui);
}
+ // when canceling always invalid model (in that way)
+ getModel().setValid(false);
+
+ ui.editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will Save and close UI " + ui);
+ }
+
SpeciesFrequencyUIModel model = getModel();
// transfer rows to editor
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -192,4 +192,18 @@
float result = correctIntStep / 10f;
return result;
}
+
+ public boolean isOneRowValid() {
+ boolean result = getRowCount() > 0;
+ if (result) {
+ result = false;
+ for (SpeciesFrequencyRowModel row : rows) {
+ if (row.isValid()) {
+ result = true;
+ break;
+ }
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,92 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+BeanComboBox {
+ showReset: true;
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ showReset: true;
+}
+
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
+#speciesLabel {
+ text: "tutti.label.createSpeciesBatch.species";
+ labelFor: {speciesComboBox};
+}
+
+#speciesComboBox {
+ property: species;
+ selectedItem: {model.getSpecies()};
+ data: {model.getAvailableSpecies()};
+}
+
+#batchWeightLabel {
+ text: "tutti.label.createSpeciesBatch.batchWeight";
+ labelFor: {batchWeightField};
+}
+
+#batchWeightField {
+ property: batchWeight;
+ model: {model.getBatchWeight()};
+ useFloat: true;
+ numberPattern: {DECIMAL1_PATTERN};
+ bean: {model};
+}
+
+#saveButton {
+ actionIcon: save;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ text: "tutti.action.cancel";
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,122 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.Species
+
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
+
+ fr.ifremer.tutti.ui.swing.TuttiUI
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+public CreateSpeciesBatchUI(SpeciesBatchUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ CreateSpeciesBatchUIHandler handler = new CreateSpeciesBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <CreateSpeciesBatchUIHandler id='handler'
+ initializer='getContextValue(CreateSpeciesBatchUIHandler.class)'/>
+
+ <CreateSpeciesBatchUIModel id='model'
+ initializer='getContextValue(CreateSpeciesBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='species' component='speciesComboBox'/>
+ <field name='batchWeight' component='batchWeightField'/>
+ </BeanValidator>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+
+ <Table id='configurationPanel' fill='both'>
+
+ <!-- Species -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='speciesLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='speciesComboBox' constructorParams='this'
+ genericType='Species'/>
+ </cell>
+ </row>
+
+ <!-- Species batch weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='batchWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='batchWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ <!-- Form Actions -->
+ <row>
+ <cell columns='2'>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
+
+</JPanel>
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,146 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JDialog;
+import java.util.List;
+
+/**
+ * Handler of {@link CreateSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CreateSpeciesBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
+ private final CreateSpeciesBatchUI ui;
+
+ public CreateSpeciesBatchUIHandler(SpeciesBatchUI parentUi, CreateSpeciesBatchUI ui) {
+ super(parentUi.getHandler().getContext());
+ this.ui = ui;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ CreateSpeciesBatchUIModel model = new CreateSpeciesBatchUIModel();
+ ui.setContextValue(model);
+ listModelIsModify(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ initBeanComboBox(ui.getSpeciesComboBox(),
+ Lists.<Species>newArrayList(),
+ null);
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), getModel());
+ }
+
+ @Override
+ public void onCloseUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+
+ }
+
+ @Override
+ protected CreateSpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void editBatch(SpeciesBatchUIModel batchModel) {
+
+ getModel().setSpecies(null);
+ getModel().setBatchWeight(null);
+
+ List<Species> speciesToUse = Lists.newArrayList();
+ if (batchModel != null) {
+
+ speciesToUse.addAll(batchModel.getAvailableSpecies());
+ }
+
+ ui.getSpeciesComboBox().setData(speciesToUse);
+ }
+
+ public void cancel() {
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // wehn canceling always invalid model
+ getModel().setValid(false);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Save UI " + ui);
+ }
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+
+import java.util.List;
+
+/**
+ * Model of {@link CreateSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CreateSpeciesBatchUIModel extends AbstractTuttiBeanUIModel<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
+
+ /**
+ * All available species (sets by protocol).
+ *
+ * @since 0.3
+ */
+ protected List<Species> availableSpecies;
+
+ /**
+ * Species to select.
+ *
+ * @since 0.3
+ */
+ protected Species species;
+
+ /**
+ * Incoming batch weight to split.
+ *
+ * @since 0.3
+ */
+ protected Float batchWeight;
+
+ public CreateSpeciesBatchUIModel() {
+ super(CreateSpeciesBatchUIModel.class, null, null);
+ }
+
+ public List<Species> getAvailableSpecies() {
+ return availableSpecies;
+ }
+
+ public void setAvailableSpecies(List<Species> availableSpecies) {
+ Object oldValue = getAvailableSpecies();
+ this.availableSpecies = availableSpecies;
+ firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldSpecies = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
+ }
+
+ public Float getBatchWeight() {
+ return batchWeight;
+ }
+
+ public void setBatchWeight(Float batchWeight) {
+ Object oldValue = getBatchWeight();
+ this.batchWeight = batchWeight;
+ firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,115 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.io.Serializable;
-
-/**
- * A row in the {@link SplitSampleCategoryUIModel}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryRowModel extends AbstractTuttiBeanUIModel<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- /**
- * Delegate sample category which contains category value + weight.
- *
- * @since 0.3
- */
- protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
-
- protected static final Binder<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> fromBeanBinder =
- BinderFactory.newBinder(SplitSampleCategoryRowModel.class,
- SplitSampleCategoryRowModel.class);
-
- protected static final Binder<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> toBeanBinder =
- BinderFactory.newBinder(SplitSampleCategoryRowModel.class,
- SplitSampleCategoryRowModel.class);
-
- public SplitSampleCategoryRowModel() {
- super(SplitSampleCategoryRowModel.class, fromBeanBinder, toBeanBinder);
- }
-
- public SampleCategoryType getCategoryType() {
- return category.getCategoryType();
- }
-
- public void setCategoryType(SampleCategoryType categoryType) {
- category.setCategoryType(categoryType);
- }
-
- public Serializable getCategoryValue() {
- return category.getCategoryValue();
- }
-
- public void setCategoryValue(Serializable categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(Float categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public Float getWeight() {
- return category.getCategoryWeight();
- }
-
- public void setWeight(Float weight) {
- Object oldValue = getWeight();
- category.setCategoryWeight(weight);
- firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
- }
-
- //TODO Use validator
- @Override
- public boolean isValid() {
- return category.isValid();
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,76 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-
-import javax.swing.table.TableColumnModel;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * Table model of sample categories values.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryTableModel extends AbstractTuttiTableModel<SplitSampleCategoryRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- n_("tutti.table.species.sampleCategory.header.category"),
- n_("tutti.table.species.sampleCategory.header.category"));
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- n_("tutti.table.species.sampleCategory.header.category"),
- n_("tutti.table.species.sampleCategory.header.category"));
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> WEIGHT = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_WEIGHT,
- n_("tutti.table.species.sampleCategory.header.weight"),
- n_("tutti.table.species.sampleCategory.header.weight"));
-
- private final SplitSampleCategoryUIModel uiModel;
-
- public SplitSampleCategoryTableModel(TableColumnModel columnModel,
- SplitSampleCategoryUIModel uiModel) {
- super(columnModel);
- this.uiModel = uiModel;
- setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
- }
-
- @Override
- public SplitSampleCategoryRowModel createNewRow() {
- SplitSampleCategoryRowModel result = new SplitSampleCategoryRowModel();
- result.setCategoryType(uiModel.getSelectedCategory());
- result.setValid(false);
- return result;
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,93 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-BeanComboBox {
- showReset: true;
- i18nPrefix: "tutti.property.";
- bean: {model};
-}
-
-#configurationPanel {
- border: {new TitledBorder(null, _("tutti.legend.sampleCategoryConfiguration"))};
-}
-
-#categoryLabel {
- text: "tutti.label.sampleCategoryConfiguration.category";
- labelFor: {categoryComboBox};
-}
-
-#categoryComboBox {
- property: selectedCategory;
- selectedItem: {model.getSelectedCategory()};
-}
-
-#sampleCheckBox {
- text: "tutti.label.sampleCategoryConfiguration.sample";
- selected: {model.isSample()};
-}
-
-#speciesLabel {
- text: "tutti.label.sampleCategoryConfiguration.species";
- labelFor: {speciesField};
-}
-
-#speciesField {
- editable: false;
- text: {handler.decorateSpecies(model.getSpecies())};
-}
-
-#batchWeightLabel {
- text: "tutti.label.sampleCategoryConfiguration.batchWeight";
- labelFor: {batchWeightField};
-}
-
-#batchWeightField {
- editable: false;
- text: {getStringValue(model.getBatchWeight())};
-}
-
-#sampleWeightLabel {
- text: "tutti.label.sampleCategoryConfiguration.sampleWeight";
- labelFor: {sampleWeightField};
-}
-
-#sampleWeightField {
- editable: false;
- text: {getStringValue(model.getSampleWeight())};
-}
-
-#closeButton {
- actionIcon: close;
- text: "tutti.action.close";
- mnemonic: F;
- enabled: {model.isValid()};
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
- enabled: {model.getSelectedCategory() != null}
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,144 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<SplitSampleCategoryUIModel, SplitSampleCategoryUIHandler>'>
-
- <import>
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
-
- fr.ifremer.tutti.ui.swing.TuttiUI
- fr.ifremer.tutti.ui.swing.TuttiUIContext
-
- org.jdesktop.swingx.JXTable
-
- jaxx.runtime.swing.editor.bean.BeanComboBox
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.ListSelectionModel
-
- java.awt.Color
-
- static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
- </import>
-
- <script><![CDATA[
-
-public SplitSampleCategoryUI(SpeciesBatchUI parentUI) {
- JAXXUtil.initContext(this, parentUI);
- SplitSampleCategoryUIHandler handler = new SplitSampleCategoryUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <SplitSampleCategoryUIHandler id='handler'
- initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
-
- <SplitSampleCategoryUIModel id='model'
- initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='category' component='categoryComboBox'/>
- <field name='sample' component='sampleCheckBox'/>
- <field name='sampleWeight' component='sampleWeightField'/>
- </BeanValidator>
-
- <Table id='configurationPanel' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- SampleCategory choice -->
- <row>
- <cell anchor='west'>
- <JLabel id='categoryLabel'/>
- </cell>
- <cell weightx='1.0'>
- <BeanComboBox id='categoryComboBox' constructorParams='this'
- genericType='SampleCategoryType'/>
- </cell>
- </row>
-
- <!-- Split as a sample or not ? -->
- <row>
- <cell columns='2'>
- <JCheckBox id='sampleCheckBox'
- onItemStateChanged='handler.setBoolean(event, "sample")'/>
- </cell>
- </row>
-
- <row>
- <cell columns="2">
- <JSeparator/>
- </cell>
- </row>
-
- <!-- Incoming Batch Species -->
- <row>
- <cell anchor='west'>
- <JLabel id='speciesLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='speciesField'/>
- </cell>
- </row>
-
- <!-- Incoming Batch Total weight -->
- <row>
- <cell anchor='west'>
- <JLabel id='batchWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='batchWeightField'/>
- </cell>
- </row>
-
- <!-- Sample Total weight -->
- <row>
- <cell anchor='west'>
- <JLabel id='sampleWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='sampleWeightField'/>
- </cell>
- </row>
-
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table'/>
- </JScrollPane>
-
- <!-- actions -->
- <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
- constraints='BorderLayout.SOUTH'>
- <JButton id='closeButton' onActionPerformed='handler.close()'/>
- </JPanel>
-
-</JPanel>
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,428 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.TuttiUI;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-
-import javax.swing.JDialog;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-/**
- * Handler of {@link SplitSampleCategoryUI}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryUIHandler extends AbstractTuttiTableUIHandler<SplitSampleCategoryRowModel, SplitSampleCategoryUIModel> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SplitSampleCategoryUIHandler.class);
-
- /**
- * Parent UI.
- *
- * @since 0.3
- */
- private final SpeciesBatchUI parentUi;
-
- /**
- * UI.
- *
- * @since 0.3
- */
- private final SplitSampleCategoryUI ui;
-
- public SplitSampleCategoryUIHandler(SpeciesBatchUI parentUi,
- SplitSampleCategoryUI ui) {
- super(parentUi.getHandler().getContext(),
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- SplitSampleCategoryRowModel.PROPERTY_WEIGHT);
- this.parentUi = parentUi;
- this.ui = ui;
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SplitSampleCategoryTableModel getTableModel() {
- return (SplitSampleCategoryTableModel) getTable().getModel();
- }
-
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
-
- @Override
- protected boolean isRowValid(SplitSampleCategoryRowModel row) {
- //TODO
- return row.getCategoryValue() != null && row.getWeight() != null;
- }
-
- @Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
- SplitSampleCategoryRowModel row) {
- if (rowMonitor.wasModified()) {
-
- if (row.isValid()) {
- if (log.isInfoEnabled()) {
- log.info("Change row that was modified and valid");
- }
- }
-
- rowMonitor.clearModified();
- }
- }
-
- @Override
- protected void onRowModified(int rowIndex,
- SplitSampleCategoryRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
-
- if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
-
- // Need to recompute the sample weight
- computeSampleWeight(row);
- }
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SplitSampleCategoryUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
- public void beforeInitUI() {
-
- SplitSampleCategoryUIModel model = new SplitSampleCategoryUIModel();
-
- ui.setContextValue(model);
- }
-
- @Override
- public void afterInitUI() {
-
- initUI(ui);
-
- SplitSampleCategoryUIModel model = getModel();
-
- //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
- initBeanComboBox(ui.getCategoryComboBox(),
- Lists.<SampleCategoryType>newArrayList(),
- model.getSelectedCategory());
-
- // when category changed, remove selected category
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- SplitSampleCategoryUIModel source =
- (SplitSampleCategoryUIModel) evt.getSource();
-
- // unselect previous selected category
- source.setSelectedCategory(null);
-
- // fill comboBox with new list
- ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
- }
- });
-
- // when selected category changed, regenerate the table model + add inside some default rows
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_SELECTED_CATEGORY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- SampleCategoryType newValue =
- (SampleCategoryType) evt.getNewValue();
- generateTableModel(newValue);
- }
- });
-
- // when sample weight changed, revalidate model
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- validateModel();
- }
- });
-
- generateTableModel(null);
-
- initTable(getTable());
- }
-
- @Override
- public void onCloseUI() {
- }
-
- //------------------------------------------------------------------------//
- //-- Public methods --//
- //------------------------------------------------------------------------//
-
- public String decorateSpecies(Species object) {
- String result = object == null ? "" : super.decorate(object);
- return result;
- }
-
- public void editBatch(SpeciesBatchRowModel batch) {
-
- // get possible the last used
- List<SampleCategoryType> categories =
- Lists.newArrayList(SampleCategoryType.values());
-
- Float batchWeight = null;
-
- if (batch != null) {
- //TODO Use the samplingOrder
- List<String> samplingOrder =
- parentUi.getModel().getSamplingOrder();
-
- SampleCategory<?> lastCategory = null;
-
- if (batch.getSortedUnsortedSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sortedUnsorted);
- lastCategory = batch.getSortedUnsortedSampleCategory();
- }
-
- if (batch.getSizeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.size);
- lastCategory = batch.getSizeSampleCategory();
- }
-
- if (batch.getSexSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sex);
- lastCategory = batch.getSexSampleCategory();
- }
-
- if (batch.getMaturitySampleCategory().isValid()) {
- categories.remove(SampleCategoryType.maturity);
- lastCategory = batch.getMaturitySampleCategory();
- }
-
- if (batch.getAgeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.age);
- lastCategory = batch.getAgeSampleCategory();
- }
-
-
- if (lastCategory == null) {
-
- // no category, then must only come from the weight
- batchWeight = batch.getWeight();
-
- } else {
-
- // use last category weight
- batchWeight = lastCategory.getCategoryWeight();
- }
- }
-
- SplitSampleCategoryUIModel model = getModel();
-
- model.setSampleWeight(null);
- model.setCategory(categories);
- model.setBatchWeight(batchWeight);
-
- // keep batch (will be used to push back editing entry)
- model.setBatch(batch);
- }
-
- public void close() {
-
- if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
- }
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void computeSampleWeight(SplitSampleCategoryRowModel row) {
-
- if (log.isInfoEnabled()) {
- log.info("Will recompute sample weight from row: " + row);
- }
-
- Float result = 0f;
- List<SplitSampleCategoryRowModel> rows = getTableModel().getRows();
- for (SplitSampleCategoryRowModel rowModel : rows) {
- Float weight = rowModel.getWeight();
- if (weight != null) {
- result += weight;
- }
- }
- getModel().setSampleWeight(result);
- }
-
- protected void validateModel() {
-
- SplitSampleCategoryUIModel model = getModel();
-
- int rowCount = model.getRowCount();
-
- // at least one row
- boolean valid = rowCount > 0;
-
- if (valid && !model.isSample()) {
-
- // sample Weight = batch weight
- valid = ObjectUtils.equals(model.getBatchWeight(),
- model.getSampleWeight());
- }
-
- model.setValid(valid);
- }
-
- protected void generateTableModel(SampleCategoryType category) {
-
- // when generate a new table model, then reset previous rows from model
- getModel().setRows(null);
-
- Caracteristic data = null;
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- boolean editableCategoryValue = false;
- if (category != null) {
-
- switch (category) {
-
- case sortedUnsorted:
- data = persistenceService.getSortedUnsortedCaracteristic();
- break;
- case size:
- data = persistenceService.getSizeCategoryCaracteristic();
- break;
- case sex:
- data = persistenceService.getSexCaracteristic();
- break;
- case maturity:
- data = persistenceService.getMaturityCaracteristic();
- break;
- case age:
- editableCategoryValue = true;
- addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.EDITABLE_CATEGORY_VALUE,
- TuttiUI.DECIMAL1_PATTERN);
- break;
- }
-
- if (data != null) {
-
- if (log.isInfoEnabled()) {
- log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
- }
- addColumnToModel(columnModel,
- null,
- newTableCellRender(CaracteristicQualitativeValue.class),
- SplitSampleCategoryTableModel.READ_ONLY_CATEGORY_VALUE);
- }
- { // Weight
-
- addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
- }
-
- // create table model
- SplitSampleCategoryTableModel tableModel =
- new SplitSampleCategoryTableModel(columnModel, getModel());
-
- JXTable table = getTable();
-
- // remove all listener on tables we could add before
- uninstallTableSaveOnRowChangedSelectionListener();
-// uninstallTableKeyListener();
-
- if (log.isInfoEnabled()) {
- log.info("Install new table model " + tableModel);
- }
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
-
- // install table listeners
- installTableSaveOnRowChangedSelectionListener();
-// installTableKeyListener(columnModel, table, editableCategoryValue);
-
- // fill datas
-
- List<SplitSampleCategoryRowModel> rows = Lists.newArrayList();
-
- if (data != null) {
-
- // add a row for each qualitive value
- for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
- if (log.isInfoEnabled()) {
- log.info("Add QV: " + qualitativeValue);
- }
- SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
- newRow.setCategoryValue(qualitativeValue);
- rows.add(newRow);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will add " + rows.size() + " rows in table model.");
- }
-
- getModel().setRows(rows);
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,165 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-
-import java.util.List;
-
-/**
- * Model of {@link SplitSampleCategoryUI}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSampleCategoryRowModel, SplitSampleCategoryUIModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY = "category";
-
- public static final String PROPERTY_SPECIES = "species";
-
- public static final String PROPERTY_SAMPLE = "sample";
-
- public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory";
-
- public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
-
- public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
-
- /**
- * Batch which fires the editor.
- *
- * @since 0.3
- */
- protected SpeciesBatchRowModel batch;
-
- /**
- * Sample categories.
- *
- * @since 0.3
- */
- protected List<SampleCategoryType> category;
-
- /**
- * Selected Sample category.
- *
- * @since 0.3
- */
- protected SampleCategoryType selectedCategory;
-
- /**
- * Flag when the batch to split is a sample.
- *
- * @since 0.3
- */
- protected boolean sample;
-
- /**
- * Incoming batch weight to split.
- *
- * @since 0.3
- */
- protected Float batchWeight;
-
- /**
- * Sample weight of split batches.
- *
- * @since 0.3
- */
- protected Float sampleWeight;
-
- public SplitSampleCategoryUIModel() {
- super(SpeciesBatchRowModel.class, null, null);
- }
-
- public SpeciesBatchRowModel getBatch() {
- return batch;
- }
-
- public void setBatch(SpeciesBatchRowModel batch) {
- Object oldSpecies = getSpecies();
- this.batch = batch;
- firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
- }
-
- public Species getSpecies() {
- return batch == null ? null : batch.getSpecies();
- }
-
- public List<SampleCategoryType> getCategory() {
- return category;
- }
-
- public void setCategory(List<SampleCategoryType> category) {
- Object oldValue = getCategory();
- this.category = category;
- firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
- }
-
- public SampleCategoryType getSelectedCategory() {
- return selectedCategory;
- }
-
- public void setSelectedCategory(SampleCategoryType selectedCategory) {
- Object oldValue = getSelectedCategory();
- this.selectedCategory = selectedCategory;
- firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
- }
-
- public boolean isSample() {
- return sample;
- }
-
- public void setSample(boolean sample) {
- Object oldValue = isSample();
- this.sample = sample;
- firePropertyChange(PROPERTY_SAMPLE, oldValue, sample);
- }
-
- public Float getBatchWeight() {
- return batchWeight;
- }
-
- public void setBatchWeight(Float batchWeight) {
- Object oldValue = getBatchWeight();
- this.batchWeight = batchWeight;
- firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
- }
-
- public Float getSampleWeight() {
- return sampleWeight;
- }
-
- public void setSampleWeight(Float sampleWeight) {
- Object oldValue = getSampleWeight();
- this.sampleWeight = sampleWeight;
- firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
- }
-}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.io.Serializable;
+
+/**
+ * A row in the {@link SplitSpeciesBatchUIModel}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchRowModel
+ extends AbstractTuttiBeanUIModel<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ /**
+ * Delegate sample category which contains category value + weight.
+ *
+ * @since 0.3
+ */
+ protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
+
+ protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
+ SplitSpeciesBatchRowModel.class);
+
+ protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> toBeanBinder =
+ BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
+ SplitSpeciesBatchRowModel.class);
+
+ public SplitSpeciesBatchRowModel() {
+ super(SplitSpeciesBatchRowModel.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public SampleCategoryType getCategoryType() {
+ return category.getCategoryType();
+ }
+
+ public void setCategoryType(SampleCategoryType categoryType) {
+ category.setCategoryType(categoryType);
+ }
+
+ public Serializable getCategoryValue() {
+ return category.getCategoryValue();
+ }
+
+ public void setCategoryValue(Serializable categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(Float categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public Float getWeight() {
+ return category.getCategoryWeight();
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ category.setCategoryWeight(weight);
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ //TODO Use validator
+ @Override
+ public boolean isValid() {
+ return category.isValid();
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,78 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Table model of sample categories values.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchTableModel
+ extends AbstractTuttiTableModel<SplitSpeciesBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ n_("tutti.table.species.sampleCategory.header.category"),
+ n_("tutti.table.species.sampleCategory.header.category"));
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ n_("tutti.table.species.sampleCategory.header.category"),
+ n_("tutti.table.species.sampleCategory.header.category"));
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.species.sampleCategory.header.weight"),
+ n_("tutti.table.species.sampleCategory.header.weight"));
+
+ private final SplitSpeciesBatchUIModel uiModel;
+
+ public SplitSpeciesBatchTableModel(TableColumnModel columnModel,
+ SplitSpeciesBatchUIModel uiModel,
+ boolean createEmptyRowIsEmpty) {
+ super(columnModel, createEmptyRowIsEmpty, createEmptyRowIsEmpty);
+ this.uiModel = uiModel;
+ setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
+ }
+
+ @Override
+ public SplitSpeciesBatchRowModel createNewRow() {
+ SplitSpeciesBatchRowModel result = new SplitSpeciesBatchRowModel();
+ result.setCategoryType(uiModel.getSelectedCategory());
+ result.setValid(false);
+ return result;
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,121 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+BeanComboBox {
+ showReset: true;
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
+#configurationPanel {
+ border: {new TitledBorder(null, _("tutti.legend.splitSpeciesBatchConfiguration"))};
+}
+
+#categoryLabel {
+ text: "tutti.label.sampleCategoryConfiguration.category";
+ labelFor: {categoryComboBox};
+}
+
+#categoryComboBox {
+ property: selectedCategory;
+ selectedItem: {model.getSelectedCategory()};
+}
+
+#sampleCheckBox {
+ text: "tutti.label.sampleCategoryConfiguration.sample";
+ selected: {model.isSample()};
+}
+
+#speciesLabel {
+ text: "tutti.label.sampleCategoryConfiguration.species";
+ labelFor: {speciesField};
+}
+
+#speciesField {
+ editable: false;
+ text: {handler.decorateSpecies(model.getSpecies())};
+}
+
+#batchWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.batchWeight";
+ labelFor: {batchWeightField};
+}
+
+#batchWeightField {
+ editable: false;
+ text: {getStringValue(model.getBatchWeight())};
+}
+
+#sampleWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.sampleWeight";
+ labelFor: {sampleWeightField};
+}
+
+#sampleWeightField {
+ editable: false;
+ text: {getStringValue(model.getSampleWeight())};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ enabled: {model.getSelectedCategory() != null}
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ mnemonic: C;
+ text: "tutti.action.cancel";
+}
+
+#saveButton {
+ actionIcon: save;
+ mnemonic: S;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,160 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<SplitSpeciesBatchUIModel, SplitSpeciesBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
+
+ fr.ifremer.tutti.ui.swing.TuttiUI
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+public SplitSpeciesBatchUI(SpeciesBatchUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ SplitSpeciesBatchUIHandler handler = new SplitSpeciesBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <SplitSpeciesBatchUIHandler id='handler'
+ initializer='getContextValue(SplitSpeciesBatchUIHandler.class)'/>
+
+ <SplitSpeciesBatchUIModel id='model'
+ initializer='getContextValue(SplitSpeciesBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='selectedCategory' component='categoryComboBox'/>
+ <field name='sample' component='sampleCheckBox'/>
+ <field name='sampleWeight' component='sampleWeightField'/>
+ </BeanValidator>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+
+ <JPanel layout='{new BorderLayout()}'>
+
+ <Table id='configurationPanel' fill='both'
+ constraints='BorderLayout.NORTH'>
+
+ <!-- SampleCategory choice -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='categoryLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='categoryComboBox' constructorParams='this'
+ genericType='SampleCategoryType'/>
+ </cell>
+ </row>
+
+ <!-- Split as a sample or not ? -->
+ <row>
+ <cell columns='2'>
+ <JCheckBox id='sampleCheckBox'
+ onItemStateChanged='handler.setBoolean(event, "sample")'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="2">
+ <JSeparator/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Species -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='speciesLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='speciesField'/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='batchWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='batchWeightField'/>
+ </cell>
+ </row>
+
+ <!-- Sample Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='sampleWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='sampleWeightField'/>
+ </cell>
+ </row>
+
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
+
+ <!-- actions -->
+ <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+
+ </JPanel>
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
+
+
+</JPanel>
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,456 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+
+import javax.swing.JDialog;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+/**
+ * Handler of {@link SplitSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchUIHandler
+ extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SplitSpeciesBatchUIHandler.class);
+
+ /**
+ * Parent UI.
+ *
+ * @since 0.3
+ */
+ private final SpeciesBatchUI parentUi;
+
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
+ private final SplitSpeciesBatchUI ui;
+
+ public SplitSpeciesBatchUIHandler(SpeciesBatchUI parentUi,
+ SplitSpeciesBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ SplitSpeciesBatchRowModel.PROPERTY_WEIGHT);
+ this.parentUi = parentUi;
+ this.ui = ui;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SplitSpeciesBatchTableModel getTableModel() {
+ return (SplitSpeciesBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected boolean isRowValid(SplitSpeciesBatchRowModel row) {
+ //TODO
+ return row.getCategoryValue() != null && row.getWeight() != null;
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSpeciesBatchRowModel> rowMonitor,
+ SplitSpeciesBatchRowModel row) {
+ if (rowMonitor.wasModified()) {
+
+ if (row.isValid()) {
+ if (log.isInfoEnabled()) {
+ log.info("Change row that was modified and valid");
+ }
+ }
+
+ rowMonitor.clearModified();
+ }
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ SplitSpeciesBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ recomputeRowValidState(row);
+
+ if (SplitSpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+
+ // Need to recompute the sample weight
+ computeSampleWeight(row);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SplitSpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel();
+
+ ui.setContextValue(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
+ initBeanComboBox(ui.getCategoryComboBox(),
+ Lists.<SampleCategoryType>newArrayList(),
+ model.getSelectedCategory());
+
+ // when category changed, remove selected category
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ SplitSpeciesBatchUIModel source =
+ (SplitSpeciesBatchUIModel) evt.getSource();
+
+ // unselect previous selected category
+ source.setSelectedCategory(null);
+
+ // fill comboBox with new list
+ ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
+ }
+ });
+
+ // when selected category changed, regenerate the table model + add inside some default rows
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SELECTED_CATEGORY, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ SplitSpeciesBatchUIModel source =
+ (SplitSpeciesBatchUIModel) evt.getSource();
+
+ // when selected category change, sample total weight is reset
+ source.setSampleWeight(null);
+
+ SampleCategoryType newValue =
+ (SampleCategoryType) evt.getNewValue();
+ generateTableModel(newValue);
+ }
+ });
+
+ // when sample weight changed, revalidate model
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ validateModel();
+ }
+ });
+
+ generateTableModel(null);
+
+ initTable(getTable());
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), model);
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public String decorateSpecies(Species object) {
+ String result = object == null ? "" : super.decorate(object);
+ return result;
+ }
+
+ public void editBatch(SpeciesBatchRowModel batch) {
+
+ // get possible the last used
+ List<SampleCategoryType> categories =
+ Lists.newArrayList(SampleCategoryType.values());
+
+ Float batchWeight = null;
+
+ if (batch != null) {
+ //TODO Use the samplingOrder
+ List<SampleCategoryType> samplingOrder =
+ parentUi.getModel().getSamplingOrder();
+
+ SampleCategory<?> lastCategory = null;
+
+ if (batch.getSortedUnsortedSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sortedUnsorted);
+ lastCategory = batch.getSortedUnsortedSampleCategory();
+ }
+
+ if (batch.getSizeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.size);
+ lastCategory = batch.getSizeSampleCategory();
+ }
+
+ if (batch.getSexSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sex);
+ lastCategory = batch.getSexSampleCategory();
+ }
+
+ if (batch.getMaturitySampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.maturity);
+ lastCategory = batch.getMaturitySampleCategory();
+ }
+
+ if (batch.getAgeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.age);
+ lastCategory = batch.getAgeSampleCategory();
+ }
+
+
+ if (lastCategory == null) {
+
+ // no category, then must only come from the weight
+ batchWeight = batch.getWeight();
+
+ } else {
+
+ // use last category weight
+ batchWeight = lastCategory.getCategoryWeight();
+ }
+ }
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ model.setSampleWeight(null);
+ model.setCategory(categories);
+ model.setBatchWeight(batchWeight);
+
+ // keep batch (will be used to push back editing entry)
+ model.setBatch(batch);
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Save UI " + ui);
+ }
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void computeSampleWeight(SplitSpeciesBatchRowModel row) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will recompute sample weight from row: " + row);
+ }
+
+ Float result = 0f;
+ List<SplitSpeciesBatchRowModel> rows = getTableModel().getRows();
+ for (SplitSpeciesBatchRowModel rowModel : rows) {
+ Float weight = rowModel.getWeight();
+ if (weight != null) {
+ result += weight;
+ }
+ }
+ getModel().setSampleWeight(result);
+ }
+
+ protected void validateModel() {
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ int rowCount = model.getRowCount();
+
+ // at least one row
+ boolean valid = rowCount > 0;
+
+ if (valid && !model.isSample()) {
+
+ // sample Weight = batch weight
+ valid = ObjectUtils.equals(model.getBatchWeight(),
+ model.getSampleWeight());
+ }
+
+ model.setValid(valid);
+ }
+
+ protected void generateTableModel(SampleCategoryType category) {
+
+ // when generate a new table model, then reset previous rows from model
+ getModel().setRows(null);
+
+ Caracteristic data = null;
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ boolean editableCategoryValue = false;
+ if (category != null) {
+
+ switch (category) {
+
+ case sortedUnsorted:
+ data = persistenceService.getSortedUnsortedCaracteristic();
+ break;
+ case size:
+ data = persistenceService.getSizeCategoryCaracteristic();
+ break;
+ case sex:
+ data = persistenceService.getSexCaracteristic();
+ break;
+ case maturity:
+ data = persistenceService.getMaturityCaracteristic();
+ break;
+ case age:
+ editableCategoryValue = true;
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
+ TuttiUI.DECIMAL1_PATTERN);
+ break;
+ }
+
+ if (data != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
+ }
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(CaracteristicQualitativeValue.class),
+ SplitSpeciesBatchTableModel.READ_ONLY_CATEGORY_VALUE);
+ }
+ { // Weight
+
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+ }
+
+ // create table model
+ SplitSpeciesBatchTableModel tableModel =
+ new SplitSpeciesBatchTableModel(columnModel,
+ getModel(),
+ editableCategoryValue);
+
+ JXTable table = getTable();
+
+ // remove all listener on tables we could add before
+ uninstallTableSaveOnRowChangedSelectionListener();
+ uninstallTableKeyListener();
+
+ if (log.isInfoEnabled()) {
+ log.info("Install new table model " + tableModel);
+ }
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ // install table listeners
+ installTableSaveOnRowChangedSelectionListener();
+ installTableKeyListener(columnModel, table);
+
+ // fill datas
+
+ List<SplitSpeciesBatchRowModel> rows = Lists.newArrayList();
+
+ if (data != null) {
+
+ // add a row for each qualitive value
+ for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ if (log.isInfoEnabled()) {
+ log.info("Add QV: " + qualitativeValue);
+ }
+ SplitSpeciesBatchRowModel newRow = tableModel.createNewRow();
+ newRow.setCategoryValue(qualitativeValue);
+ rows.add(newRow);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will add " + rows.size() + " rows in table model " +
+ "(can add a first empty row? " + editableCategoryValue + ").");
+ }
+
+ getModel().setRows(rows);
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,166 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+
+import java.util.List;
+
+/**
+ * Model of {@link SplitSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchUIModel
+ extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY = "category";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SAMPLE = "sample";
+
+ public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory";
+
+ public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
+
+ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+
+ /**
+ * Batch which fires the editor.
+ *
+ * @since 0.3
+ */
+ protected SpeciesBatchRowModel batch;
+
+ /**
+ * Sample categories.
+ *
+ * @since 0.3
+ */
+ protected List<SampleCategoryType> category;
+
+ /**
+ * Selected Sample category.
+ *
+ * @since 0.3
+ */
+ protected SampleCategoryType selectedCategory;
+
+ /**
+ * Flag when the batch to split is a sample.
+ *
+ * @since 0.3
+ */
+ protected boolean sample;
+
+ /**
+ * Incoming batch weight to split.
+ *
+ * @since 0.3
+ */
+ protected Float batchWeight;
+
+ /**
+ * Sample weight of split batches.
+ *
+ * @since 0.3
+ */
+ protected Float sampleWeight;
+
+ public SplitSpeciesBatchUIModel() {
+ super(SpeciesBatchRowModel.class, null, null);
+ }
+
+ public SpeciesBatchRowModel getBatch() {
+ return batch;
+ }
+
+ public void setBatch(SpeciesBatchRowModel batch) {
+ Object oldSpecies = getSpecies();
+ this.batch = batch;
+ firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
+ }
+
+ public Species getSpecies() {
+ return batch == null ? null : batch.getSpecies();
+ }
+
+ public List<SampleCategoryType> getCategory() {
+ return category;
+ }
+
+ public void setCategory(List<SampleCategoryType> category) {
+ Object oldValue = getCategory();
+ this.category = category;
+ firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
+ }
+
+ public SampleCategoryType getSelectedCategory() {
+ return selectedCategory;
+ }
+
+ public void setSelectedCategory(SampleCategoryType selectedCategory) {
+ Object oldValue = getSelectedCategory();
+ this.selectedCategory = selectedCategory;
+ firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
+ }
+
+ public boolean isSample() {
+ return sample;
+ }
+
+ public void setSample(boolean sample) {
+ Object oldValue = isSample();
+ this.sample = sample;
+ firePropertyChange(PROPERTY_SAMPLE, oldValue, sample);
+ }
+
+ public Float getBatchWeight() {
+ return batchWeight;
+ }
+
+ public void setBatchWeight(Float batchWeight) {
+ Object oldValue = getBatchWeight();
+ this.batchWeight = batchWeight;
+ firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
+ }
+
+ public Float getSampleWeight() {
+ return sampleWeight;
+ }
+
+ public void setSampleWeight(Float sampleWeight) {
+ Object oldValue = getSampleWeight();
+ this.sampleWeight = sampleWeight;
+ firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
+ }
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -86,6 +86,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ EnvironmentRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EnvironmentRowModel> rowMonitor,
EnvironmentRowModel row) {
// getModel().setCaracteristic(row.getKey(), row.getValue());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -50,7 +50,7 @@
n_("tutti.table.fishing.environment.header.value"));
public EnvironmentTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(KEY);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -86,6 +86,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ GearShootingRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<GearShootingRowModel> rowMonitor,
GearShootingRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -50,7 +50,7 @@
n_("tutti.table.fishing.gearShooting.header.value"));
public GearShootingTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(KEY);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -29,6 +29,7 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentRowModel;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil.Type;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
@@ -92,6 +93,24 @@
}
@Override
+ protected boolean isRowValid(HydrologyRowModel row) {
+ //TODO
+ return row.getGearShootingStartValue() != null ||
+ row.getGearShootingEndValue() != null ||
+ row.getAverageValue() != null;
+ }
+
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ HydrologyRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<HydrologyRowModel> rowMonitor,
HydrologyRowModel row) {
@@ -115,14 +134,6 @@
getModel().addCaracteristics(map);
}
- @Override
- protected boolean isRowValid(HydrologyRowModel row) {
- //TODO
- return row.getGearShootingStartValue() != null ||
- row.getGearShootingEndValue() != null ||
- row.getAverageValue() != null;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -60,7 +60,7 @@
n_("tutti.table.fishing.hydrology.header.averageValue"));
public HydrologyTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(KEY);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -87,8 +87,8 @@
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -33,6 +33,7 @@
jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
java.awt.Dimension
+ javax.swing.ListSelectionModel
static org.nuiton.i18n.I18n._
static jaxx.runtime.SwingUtil.getStringValue
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -75,7 +75,7 @@
private static final long serialVersionUID = 1L;
public EditProtocolSpeciesTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(SPECIES_ID);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -72,16 +72,16 @@
#messagePanel {
border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
- height: 200;
- width: 500;
+ /*height: 200;
+ width: 500;*/
}
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Lists;
@@ -125,23 +126,21 @@
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
- EditProtocolSpeciesRowModel row) {
-
- // nothing to save when row changes, model is marked to be save
- // when a row has changed and is valid or other protocol properties are modified
- }
-
- @Override
protected void onRowModified(int rowIndex,
EditProtocolSpeciesRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
- if (row.isValid()) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex, EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+
+ if (row != null && row.isModify() && newValue != null && newValue) {
// row was modified and is valid, we can save protocol
// even if after the row becomes again not valid, this is not a
// problem since we will only save valid data!
@@ -149,6 +148,14 @@
}
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
+ EditProtocolSpeciesRowModel row) {
+
+ // nothing to save when row changes, model is marked to be save
+ // when a row has changed and is valid or other protocol properties are modified
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -163,7 +170,7 @@
EditProtocolUIModel model = new EditProtocolUIModel();
- // can't load directly model fro database here, since we want to
+ // can't load directly model from database here, since we want to
// fill only the model with rows (transformed from speciesProtocol)
// As we still don't have the table model at this point, wait the
// afterUI method to fill model
@@ -177,6 +184,7 @@
allLengthStepPmfm = TuttiEntities.splitById(
persistenceService.getAllSpeciesLengthStepCaracteristic());
+ hydroCaracteristics = ArrayListMultimap.create();
for (Caracteristic caracteristic :
persistenceService.getAllFishingOperationHydrologicCaracteristic()) {
String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
@@ -251,6 +259,8 @@
List<Species> speciesList = Lists.newArrayList(allSpecies.values());
+ List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
+
// load protocol if existing
String protocolId = context.getProtocolId();
@@ -269,7 +279,6 @@
model.fromBean(protocol);
// build speciesProtocol rows
- List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
List<SpeciesProtocol> speciesProtocols = protocol.getSpecies();
if (CollectionUtils.isNotEmpty(speciesProtocols)) {
@@ -287,11 +296,11 @@
log.debug("Will edit protocol: " + protocolId + " with " +
rows.size() + " species declared.");
}
-
- // set to model ( will propagate to tableModel)
- model.setRows(rows);
}
+ // set to model ( will propagate to tableModel)
+ model.setRows(rows);
+
// init species combo box
initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
selectFirstInCombo(ui.getSpeciesComboBox());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,22 +44,24 @@
private static final Log log =
LogFactory.getLog(AbstractSelectTableAction.class);
- private final JTable table;
+ public static void doSelectCell(JTable table,
+ int rowIndex,
+ int columnIndex) {
+ table.setColumnSelectionInterval(columnIndex, columnIndex);
+ table.setRowSelectionInterval(rowIndex, rowIndex);
+ table.editCellAt(rowIndex, columnIndex);
+ }
+
private final M model;
+ private final JTable table;
+
public AbstractSelectTableAction(M model, JTable table) {
this.model = model;
this.table = table;
}
- public static void doSelectCell(JTable table, int rowIndex, int columnIndex) {
-
- table.setColumnSelectionInterval(columnIndex, columnIndex);
- table.setRowSelectionInterval(rowIndex, rowIndex);
- table.editCellAt(rowIndex, columnIndex);
- }
-
protected void doSelectCell(int rowIndex, int columnIndex) {
if (log.isDebugEnabled()) {
@@ -69,7 +71,6 @@
doSelectCell(table, rowIndex, columnIndex);
}
-
protected int getSelectedRow() {
int result = table.getSelectedRow();
return result;
@@ -89,9 +90,17 @@
}
protected boolean isCellEditable(int rowIndex, int columnIndex) {
- return table.isCellEditable(rowIndex, columnIndex);
+ boolean result;
+ result = rowIndex > -1 && columnIndex > -1 &&
+// rowIndex < getRowCount() && columnIndex < getColumnCount() &&
+ table.isCellEditable(rowIndex, columnIndex);
+ return result;
}
+ protected boolean isCreateNewRow() {
+ return model.isCreateNewRow();
+ }
+
protected String getCellCoordinate(int rowIndex, int columnIndex) {
return " [" + rowIndex + ", " + columnIndex + "]";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -79,9 +79,27 @@
*/
protected Set<ColumnIdentifier<?>> noneEditableCols;
+ /**
+ * Creates a new row when moving to next editable cell / row ?
+ *
+ * @since 0.3
+ */
+ protected final boolean createNewRow;
+
+ /**
+ * Creates a first empty row when setting a null or empty list of rows ?
+ *
+ * @since 0.3
+ */
+ protected final boolean createEmptyRowIsEmpty;
+
public abstract R createNewRow();
- protected AbstractTuttiTableModel(TableColumnModel columnModel) {
+ protected AbstractTuttiTableModel(TableColumnModel columnModel,
+ boolean createNewRow,
+ boolean createEmptyRowIsEmpty) {
+ this.createNewRow = createNewRow;
+ this.createEmptyRowIsEmpty = createEmptyRowIsEmpty;
int nbcols = columnModel.getColumnCount();
columns = new TableColumn[nbcols];
columnIdentifiers = Lists.newArrayList();
@@ -97,16 +115,15 @@
}
public final void setRows(List<R> data) {
- setRows(data, true);
- }
- public final void setRows(List<R> data, boolean checkEmpty) {
-
// can't accept a empty data list
Preconditions.checkNotNull(data, "Data list can not be null.");
- if (checkEmpty && data.isEmpty()) {
+ if (createEmptyRowIsEmpty && data.isEmpty()) {
+ if (log.isInfoEnabled()) {
+ log.info("Creates a first empty row on tableModel " + this);
+ }
// add a first edit line
data.add(createNewRow());
}
@@ -118,6 +135,14 @@
fireTableDataChanged();
}
+ public boolean isCreateNewRow() {
+ return createNewRow;
+ }
+
+ public boolean isCreateEmptyRowIsEmpty() {
+ return createEmptyRowIsEmpty;
+ }
+
public final void addNewRow() {
R newValue = createNewRow();
addNewRow(newValue);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -53,7 +53,9 @@
import javax.swing.JComboBox;
import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
import javax.swing.border.LineBorder;
+import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
@@ -105,6 +107,23 @@
protected abstract boolean isRowValid(R row);
/**
+ * Invoke each time the {@link AbstractTuttiBeanUIModel#modify} state on
+ * the current selected row changed.
+ *
+ * @param rowIndex row index of the modified row
+ * @param row modified row
+ * @param propertyName name of the modified property of the row
+ * @param oldValue old value of the modified property
+ * @param newValue new value of the modified property
+ * @since 0.3
+ */
+ protected abstract void onRowModified(int rowIndex,
+ R row,
+ String propertyName,
+ Object oldValue,
+ Object newValue);
+
+ /**
* Given the row monitor and his monitored row, try to save it if required.
* <p/>
* Coming in this method, we are sure that row is not null.
@@ -165,6 +184,11 @@
(Boolean) newValue);
} else if (!propertiesToSkip.contains(propertyName)) {
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] property " +
+ propertyName + " changed from " + oldValue +
+ " to " + newValue);
+ }
onRowModified(rowIndex, row,
propertyName,
oldValue,
@@ -200,34 +224,20 @@
}
protected void onModelRowsChanged(List<R> rows) {
+ if (log.isInfoEnabled()) {
+ log.info("Will set " + (rows == null ? 0 : rows.size()) +
+ " rows on model.");
+ }
if (CollectionUtils.isNotEmpty(rows)) {
+
+ // compute valid state for each row
for (R row : rows) {
- boolean rowIsValid = isRowValid(row);
- row.setValid(rowIsValid);
+ recomputeRowValidState(row);
}
}
getTableModel().setRows(rows);
}
- protected void onRowModified(int rowIndex,
- R row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- if (log.isInfoEnabled()) {
- log.info("row [" + rowIndex + "] property " +
- propertyName + " changed from " + oldValue +
- " to " + newValue);
- }
-
- // recompute row valid state
- boolean valid = isRowValid(row);
-
- // apply it to row
- row.setValid(valid);
- }
-
protected void onRowModifyStateChanged(int rowIndex,
R row,
Boolean oldValue,
@@ -253,6 +263,16 @@
}
}
+ protected void onAfterSelectedRowChanged(int oldRowIndex,
+ R oldRow,
+ int newRowIndex,
+ R newRow) {
+ if (log.isInfoEnabled()) {
+ log.info("Selected row changed from [" + oldRowIndex + "] to [" +
+ newRowIndex + "]");
+ }
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods (init methods) --//
//------------------------------------------------------------------------//
@@ -424,12 +444,48 @@
// create new listener
// save when row chaged and was modified
- tableSelectionListener = new TableRowModificationListener<R>(
- getTableModel(), rowMonitor) {
+ tableSelectionListener = new ListSelectionListener() {
+ /**
+ * Current selected row index.
+ *
+ * @since 0.3
+ */
+ protected int selectedRowIndex;
+
@Override
- protected void saveSelectedRow() {
+ public void valueChanged(ListSelectionEvent e) {
- saveSelectedRowIfNeeded();
+ if (!e.getValueIsAdjusting()) {
+ ListSelectionModel source = (ListSelectionModel) e.getSource();
+
+ int oldRowIndex = selectedRowIndex;
+ R oldRow = rowMonitor.getBean();
+
+ int newRowIndex = source.getLeadSelectionIndex();
+ R newRow;
+
+ if (source.isSelectionEmpty()) {
+
+ newRow = null;
+ } else {
+ newRow = getTableModel().getEntry(newRowIndex);
+ }
+
+ // save selected entry if required
+ saveSelectedRowIfNeeded();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will monitor entry: " + newRow);
+ }
+ rowMonitor.setBean(newRow);
+
+ selectedRowIndex = newRowIndex;
+
+ onAfterSelectedRowChanged(oldRowIndex,
+ oldRow,
+ selectedRowIndex,
+ rowMonitor.getBean());
+ }
}
};
@@ -455,7 +511,7 @@
}
protected void installTableKeyListener(TableColumnModel columnModel,
- JTable table, boolean canCreateRow) {
+ JTable table) {
Preconditions.checkState(
keyAdapter == null,
@@ -464,33 +520,34 @@
AbstractTuttiTableModel<R> model = getTableModel();
final MoveToNextEditableCellAction nextCellAction =
- MoveToNextEditableCellAction.newAction(model, table, canCreateRow);
+ MoveToNextEditableCellAction.newAction(model, table);
final MoveToPreviousEditableCellAction previousCellAction =
MoveToPreviousEditableCellAction.newAction(model, table);
final MoveToNextEditableRowAction nextRowAction =
- MoveToNextEditableRowAction.newAction(model, table, canCreateRow);
+ MoveToNextEditableRowAction.newAction(model, table);
final MoveToPreviousEditableRowAction previousRowAction =
MoveToPreviousEditableRowAction.newAction(model, table);
- // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
- // touches "entrer", "gauche", "droite" de facon personnalisée.
keyAdapter = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER ||
- e.getKeyCode() == KeyEvent.VK_RIGHT ||
- e.getKeyCode() == KeyEvent.VK_TAB) {
+
+ int keyCode = e.getKeyCode();
+ if (keyCode == KeyEvent.VK_LEFT ||
+ (keyCode == KeyEvent.VK_TAB && e.isShiftDown())) {
e.consume();
+ previousCellAction.actionPerformed(null);
+ } else if (//e.getKeyCode() == KeyEvent.VK_ENTER ||
+ keyCode == KeyEvent.VK_RIGHT ||
+ keyCode == KeyEvent.VK_TAB) {
+ e.consume();
nextCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ } else if (keyCode == KeyEvent.VK_UP) {
e.consume();
- previousCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
- e.consume();
previousRowAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ } else if (keyCode == KeyEvent.VK_DOWN) {
e.consume();
nextRowAction.actionPerformed(null);
}
@@ -549,4 +606,12 @@
}
}
+ protected final void recomputeRowValidState(R row) {
+
+ // recompute row valid state
+ boolean valid = isRowValid(row);
+
+ // apply it to row
+ row.setValid(valid);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -56,12 +56,13 @@
}
public void setRows(List<R> rows) {
- Object oldValue = getRows();
if (rows == null) {
rows = Lists.newArrayList();
}
this.rows = rows;
- firePropertyChange(PROPERTY_ROWS, oldValue, rows);
+
+ // always propagates (since empty list will not fire and we want it)
+ firePropertyChange(PROPERTY_ROWS, null, rows);
}
public int getRowCount() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,20 +44,12 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableCellAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table, boolean canCreateRow) {
- return new MoveToNextEditableCellAction<M>(model, table, canCreateRow);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table) {
+ return new MoveToNextEditableCellAction<M>(model, table);
}
- /**
- * Can create new row if reach the end of editable cells ?
- *
- * @since 0.3
- */
- private final boolean canCreateRow;
-
- protected MoveToNextEditableCellAction(M model, JTable table, boolean canCreateRow) {
+ protected MoveToNextEditableCellAction(M model, JTable table) {
super(model, table);
- this.canCreateRow = canCreateRow;
}
@Override
@@ -89,7 +81,8 @@
if (currentRow == rowCount) {
- if (canCreateRow) {
+ if (isCreateNewRow()) {
+
// create a new row in model
addNewRow();
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,20 +44,12 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableRowAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table, boolean canCreateRow) {
- return new MoveToNextEditableRowAction<M>(model, table, canCreateRow);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table) {
+ return new MoveToNextEditableRowAction<M>(model, table);
}
- /**
- * Can create new row if reach the end of editable cells ?
- *
- * @since 0.3
- */
- private final boolean canCreateRow;
-
- protected MoveToNextEditableRowAction(M model, JTable table, boolean canCreateRow) {
+ protected MoveToNextEditableRowAction(M model, JTable table) {
super(model, table);
- this.canCreateRow = canCreateRow;
}
@Override
@@ -77,7 +69,8 @@
if (log.isDebugEnabled()) {
log.debug("No next row");
}
- if (canCreateRow) {
+ if (isCreateNewRow()) {
+
// create a new row in model
addNewRow();
} else {
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,90 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.table;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import java.io.Serializable;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public abstract class TableRowModificationListener<R extends Serializable> implements ListSelectionListener {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TableRowModificationListener.class);
-
- private final AbstractTuttiTableModel<R> tableModel;
-
- private final TuttiBeanMonitor<R> beanMonitor;
-
- protected abstract void saveSelectedRow();
-
- public TableRowModificationListener(AbstractTuttiTableModel<R> tableModel,
- TuttiBeanMonitor<R> beanMonitor) {
- this.tableModel = tableModel;
- this.beanMonitor = beanMonitor;
- }
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- if (!e.getValueIsAdjusting()) {
- ListSelectionModel source = (ListSelectionModel) e.getSource();
- int selectedRow = source.getLeadSelectionIndex();
-
- // save selected entry if required
- saveSelectedRow();
-
- R entry;
-
- if (source.isSelectionEmpty()) {
-
- // no selection
- entry = null;
- if (log.isInfoEnabled()) {
- log.info("Selection is now empty.");
- }
- } else {
- entry = tableModel.getEntry(selectedRow);
-
- if (log.isInfoEnabled()) {
- log.info("New selected row: " + selectedRow);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will monitor entry: " + entry);
- }
- beanMonitor.setBean(entry);
- }
- }
-}
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,50 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="lengthStepCaracteristic">
+
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.speciesFrequency.lengthStepCaracteristic.required
+ </message>
+ </field-validator>
+
+ </field>
+
+ <field name="rows">
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ oneRowValid ]]></param>
+ <message>
+ tutti.validator.error.speciesFrequency.oneRowRequired
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,51 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="species">
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.createSpeciesBatch.species.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="batchWeight">
+
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.createSpeciesBatch.batchWeight.required
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression"><![CDATA[ batchWeight >0 ]]></param>
+ <message>
+ tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,68 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="selectedCategory">
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.splitSpeciesBatch.selectedCategory.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="sampleWeight">
+
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.splitSpeciesBatch.sampleWeight.required
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression"><![CDATA[ sampleWeight > 0 ]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.invalidValue
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ sampleWeight <= batchWeight]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ ( sample || batchWeight == sampleWeight ) ]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.mismatchBatchWeight
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,40 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="sample">
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ !sample ]]></param>
+ <message>
+ tutti.validator.warning.splitSpeciesBatch.sampleBatch
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,14 +24,14 @@
tutti.action.reload.application=Recharger l'application
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
-tutti.action.removeSubBatch=Supprimer les lots
+tutti.action.removeSpeciesSubBatch=Supprimer les lots
tutti.action.reset.fishingOperationValidState=Réinitialiser
tutti.action.save=Enregistrer
tutti.action.selectCampaign=Campagne
tutti.action.selectCampaign.tip=Sélectionner la campagne à utiliser
tutti.action.site=Site
tutti.action.site.tip=Accéder au site du projet Tutti
-tutti.action.splitBatch=Catégoriser un lot
+tutti.action.splitSpeciesBatch=Catégoriser un lot
tutti.application.config=Configuration de l'application Tutti
tutti.application.name=Tutti
tutti.config.category.applications=Application
@@ -71,6 +71,8 @@
tutti.label.catches.speciesTotalUnsortedWeight=Poids total hors vrac
tutti.label.catches.speciesTotalWeight=Poids total
tutti.label.comment=Commentaire
+tutti.label.createSpeciesBatch.batchWeight=Poids du lot
+tutti.label.createSpeciesBatch.species=Espèce du lot
tutti.label.cruise=Campagne
tutti.label.cruise.beginDate=Date de début
tutti.label.cruise.country=Pays
@@ -150,7 +152,7 @@
tutti.legend.catch.total=Capture
tutti.legend.filterSpeciesBatchMode=Filtrer les lots
tutti.legend.frequencyConfiguration=Configuration
-tutti.legend.sampleCategoryConfiguration=Configuration
+tutti.legend.splitSpeciesBatchConfiguration=Configuration
tutti.menu.actions=Actions
tutti.menu.actions.tip=Actions
tutti.menu.file=Fichier
@@ -255,6 +257,9 @@
tutti.to.be.done=< A FAIRE >
tutti.tooltip.attachment.none=Pas de pièce-jointes
tutti.tooltip.comment.none=Pas de commentaire
+tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue=Le poids du lot doit être strictement positif
+tutti.validator.error.createSpeciesBatch.batchWeight.required=Le poids du lot est obligatoire
+tutti.validator.error.createSpeciesBatch.species.required=L'espèce est obligatoire
tutti.validator.error.cruise.beginDate.required=La date de début est obligatoire
tutti.validator.error.cruise.country.required=Le pays est obligatoire
tutti.validator.error.cruise.endDate.required=La date de fin est obligatoire
@@ -271,3 +276,11 @@
tutti.validator.error.program.name.required=Le nom de la série est obligatoire
tutti.validator.error.program.zone.required=La zone de la série est obligatoire
tutti.validator.error.protocol.name.required=Le nom du protocol est obligatoire
+tutti.validator.error.speciesFrequency.lengthStepCaracteristic.required=La classe de taille est obligatoire
+tutti.validator.error.speciesFrequency.oneRowRequired=Au moins une classe de taille doit être observée
+tutti.validator.error.splitSpeciesBatch.sampleWeight.invalidValue=La somme des poids ventilés doit être strictement positive
+tutti.validator.error.splitSpeciesBatch.sampleWeight.mismatchBatchWeight=La somme des poids ventilés doit être égale à celle du lot
+tutti.validator.error.splitSpeciesBatch.sampleWeight.required=Pas de poids ventilé
+tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight=La somme des poids ventilés doit être inférieur ou égale à celle du poids du lot
+tutti.validator.error.splitSpeciesBatch.selectedCategory.required=La catégorie est obligatoire
+tutti.validator.warning.splitSpeciesBatch.sampleBatch=Ce lot est-il vraiment un échantillon du lot parent ?
Copied: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png (from rev 134, trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png)
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
31 Dec '12
Author: tchemit
Date: 2012-12-31 19:59:33 +0100 (Mon, 31 Dec 2012)
New Revision: 134
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/134
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (can save now some splitted batches :))
refs #1806: [Onglet Poisson] Pr?\195?\169filtrage du tableau (add ui, now need to do logic)
Added:
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -73,7 +73,7 @@
}
@Override
- protected AccidentalBatchRowModel createNewRow() {
+ public AccidentalBatchRowModel createNewRow() {
AccidentalBatchRowModel result = new AccidentalBatchRowModel();
// by default empty row is not valid
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -87,7 +87,7 @@
}
@Override
- protected BenthosBatchRowModel createNewRow() {
+ public BenthosBatchRowModel createNewRow() {
BenthosBatchRowModel result = new BenthosBatchRowModel();
// by default empty row is not valid
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -76,7 +76,7 @@
}
@Override
- protected MacroWasteBatchRowModel createNewRow() {
+ public MacroWasteBatchRowModel createNewRow() {
MacroWasteBatchRowModel result = new MacroWasteBatchRowModel();
// by default empty row is not valid
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -80,7 +80,7 @@
}
@Override
- protected PlanktonBatchRowModel createNewRow() {
+ public PlanktonBatchRowModel createNewRow() {
PlanktonBatchRowModel result = new PlanktonBatchRowModel();
// by default empty row is not valid
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
@@ -41,6 +42,36 @@
private static final long serialVersionUID = 1L;
+ public static class SampleColumnIdentifier<R> extends ColumnIdentifier<R> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static <R> SampleColumnIdentifier<R> newId(String propertyName,
+ String weightPropertyName,
+ String headerI18nKey,
+ String headerTipI18nKey) {
+ return new SampleColumnIdentifier<R>(propertyName,
+ weightPropertyName,
+ headerI18nKey,
+ headerTipI18nKey);
+ }
+
+ private final String weightPropertyName;
+
+ protected SampleColumnIdentifier(String propertyName,
+ String weightPropertyName,
+ String headerI18nKey,
+ String headerTipI18nKey
+ ) {
+ super(propertyName, headerI18nKey, headerTipI18nKey);
+ this.weightPropertyName = weightPropertyName;
+ }
+
+ public void setWeightValue(R entry, Object value) {
+ TuttiUIUtil.setProperty(entry, weightPropertyName, value);
+ }
+ }
+
public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SPECIES,
n_("tutti.table.species.batch.header.speciesByCode"),
@@ -51,28 +82,33 @@
n_("tutti.table.species.batch.header.speciesByGenusCode"),
n_("tutti.table.species.batch.header.speciesByGenusCode"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sortedUnsortedCategory"),
n_("tutti.table.species.batch.header.sortedUnsortedCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SIZE_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sizeCategory"),
n_("tutti.table.species.batch.header.sizeCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SEX_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.sexCategory"),
n_("tutti.table.species.batch.header.sexCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_MATURITY_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.maturityCategory"),
n_("tutti.table.species.batch.header.maturityCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_AGE_SAMPLE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
n_("tutti.table.species.batch.header.ageCategory"),
n_("tutti.table.species.batch.header.ageCategory"));
@@ -133,7 +169,7 @@
}
@Override
- protected SpeciesBatchRowModel createNewRow() {
+ public SpeciesBatchRowModel createNewRow() {
SpeciesBatchRowModel result = new SpeciesBatchRowModel();
// by default empty row is not valid
@@ -147,8 +183,13 @@
int columnIndex,
ColumnIdentifier<SpeciesBatchRowModel> propertyName,
SpeciesBatchRowModel entry) {
- super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ if (sampleCols.contains(propertyName)) {
+ ((SampleColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue);
+ } else {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ }
+
if (propertyName == SPECIES_BY_CODE) {
// update also other columns
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-31 18:59:33 UTC (rev 134)
@@ -75,9 +75,56 @@
editable: false;
}
+#tablePopup {
+ label: "tutti.title.batchActions";
+}
+
+#splitBatchMenu {
+ text: "tutti.action.splitBatch";
+ actionIcon: batch-split;
+}
+
+#removeSubBatchMenu {
+ text: "tutti.action.removeSubBatch";
+ actionIcon: batch-delete;
+}
+
#table {
selectionMode: {ListSelectionModel.SINGLE_SELECTION};
selectionBackground: {null};
selectionForeground: {Color.BLACK};
sortable: false;
}
+
+#createSpeciesBatchButton {
+ actionIcon: batch-split;
+ text: "tutti.action.createSpeciesBatch";
+}
+
+#filterTablePane {
+ border: {new TitledBorder(null, _("tutti.legend.filterSpeciesBatchMode"))};
+}
+
+#filterSpeciesBatchAllButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.all";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.all";
+ value: "all";
+ selected: {model.isTableViewModeAll()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchLeafButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.leaf";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.leaf";
+ value: "leaf";
+ selected: {model.isTableViewModeLeaf()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchRootButton {
+ text: "tutti.label.filterSpeciesBatchMode.mode.root";
+ toolTipText: "tutti.label.filterSpeciesBatchMode.mode.root";
+ value: "root";
+ selected: {model.isTableViewModeRoot()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
@@ -87,6 +87,13 @@
<AttachmentEditorUI id='attachmentEditor'/>
+ <JPopupMenu id='tablePopup'
+ onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>
+ <JMenuItem id='splitBatchMenu'
+ onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='removeSubBatchMenu'
+ onActionPerformed='handler.removeBatch()'/>
+ </JPopupMenu>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total / Poids total vrac -->
@@ -122,10 +129,31 @@
<JTextField id='speciesTotalUnsortedWeightField'/>
</cell>
</row>
+
+ <!-- Toolbar / Filter -->
+ <row>
+ <cell columns="4">
+ <JPanel id='tableToolbar' layout='{new BorderLayout()}'>
+ <JButton id='createSpeciesBatchButton' constraints='BorderLayout.WEST'
+ onActionPerformed='handler.createSpeciesBatch()'/>
+ <JPanel id='filterTablePane' constraints='BorderLayout.CENTER'>
+ <JRadioButton id='filterSpeciesBatchAllButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ALL)'/>
+ <JRadioButton id='filterSpeciesBatchLeafButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.LEAF)'/>
+ <JRadioButton id='filterSpeciesBatchRootButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
+ </JPanel>
+
+ </JPanel>
+ </cell>
+ </row>
+
</Table>
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)'/>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)'
+ onMouseClicked='handler.autoSelectRowInTable(event)'/>
</JScrollPane>
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -42,22 +42,33 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
+import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -218,7 +229,6 @@
persistenceService.deleteSpeciesBatch(catchBean.getId());
}
}
-
}
@Override
@@ -357,6 +367,7 @@
ui.getContextValue(EditCatchesUIModel.class);
SpeciesBatchUIModel model = new SpeciesBatchUIModel(catchesUIModel);
+ model.setTableViewMode(TableViewMode.ALL);
ui.setContextValue(model);
PersistenceService service =
@@ -529,6 +540,162 @@
//-- Public methods --//
//------------------------------------------------------------------------//
+ public void autoSelectRowInTable(MouseEvent e) {
+ if (SwingUtilities.isRightMouseButton(e) ||
+ e.isPopupTrigger()) {
+
+ // get the coordinates of the mouse click
+ Point p = e.getPoint();
+
+ JXTable source = (JXTable) e.getSource();
+
+ // get the row index at this point
+ int rowIndex = source.rowAtPoint(p);
+
+ if (log.isInfoEnabled()) {
+ log.info("At point [" + p + "] found Row " + rowIndex);
+ }
+ if (rowIndex != -1) {
+
+ // select new row
+ source.setRowSelectionInterval(rowIndex, rowIndex);
+ }
+
+ ui.getTablePopup().show(source, e.getX(), e.getY());
+ }
+ }
+
+ public void updateTablePopup() {
+
+ int rowIndex = getTable().getSelectedRow();
+ boolean enableSplit = false;
+ boolean enableRemove = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+
+ if (row.isValid()) {
+
+ // must have at least species filled in row
+ // otherwise nothing can be done
+
+ enableSplit = true;
+ }
+ }
+
+ ui.getSplitBatchMenu().setEnabled(enableSplit);
+ ui.getRemoveSubBatchMenu().setEnabled(enableRemove);
+ }
+
+ public void removeBatch() {
+ //TODO
+ }
+
+ public void createSpeciesBatch() {
+
+ }
+ public void splitBatch() {
+
+ JXTable table = getTable();
+
+ // get selected row
+ int rowIndex = table.getSelectedRow();
+ SpeciesBatchRowModel selectedRow = getTableModel().getEntry(rowIndex);
+
+ if (log.isInfoEnabled()) {
+ log.info("Open split batch for row [" + rowIndex + "]");
+ }
+ SplitSampleCategoryUI sampleCategoryEditor = ui.getSampleCategoryEditor();
+ sampleCategoryEditor.getHandler().editBatch(selectedRow);
+
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ // open split batch dialog
+ TuttiUIUtil.openInDialog(sampleCategoryEditor,
+ frame,
+ _("tutti.title.splitBatch"), true, null);
+
+ // at close, synch back batches ?
+ SplitSampleCategoryUIModel splitModel = sampleCategoryEditor.getModel();
+
+ if (splitModel.isValid()) {
+
+ // create batch rows
+
+ SpeciesBatchTableModel batchTableModel = getTableModel();
+
+ int insertRow = rowIndex;
+
+ SampleCategoryType selectedCategory = splitModel.getSelectedCategory();
+
+ // Create rows in batch table model
+
+ List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList();
+ for (SplitSampleCategoryRowModel row : splitModel.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ SpeciesBatchRowModel batchNewRow = batchTableModel.createNewRow();
+ batchNewRow.setSpecies(selectedRow.getSpecies());
+ batchNewRow.setSpeciesToConfirm(selectedRow.getSpeciesToConfirm());
+ if (selectedCategory == SampleCategoryType.sortedUnsorted) {
+ batchNewRow.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSortedUnsortedCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSortedUnsortedCategory(selectedRow.getSortedUnsortedCategory());
+ batchNewRow.setSortedUnsortedCategoryWeight(selectedRow.getSortedUnsortedCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.size) {
+ batchNewRow.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSizeCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSizeCategory(selectedRow.getSizeCategory());
+ batchNewRow.setSizeCategoryWeight(selectedRow.getSizeCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.sex) {
+ batchNewRow.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setSexCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setSexCategory(selectedRow.getSexCategory());
+ batchNewRow.setSexCategoryWeight(selectedRow.getSexCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.maturity) {
+ batchNewRow.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ batchNewRow.setMaturityCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setMaturityCategory(selectedRow.getMaturityCategory());
+ batchNewRow.setMaturityCategoryWeight(selectedRow.getMaturityCategoryWeight());
+ }
+ if (selectedCategory == SampleCategoryType.age) {
+ batchNewRow.setAgeCategory((Float) row.getCategoryValue());
+ batchNewRow.setAgeCategoryWeight(row.getWeight());
+ } else {
+ batchNewRow.setAgeCategory(selectedRow.getAgeCategory());
+ batchNewRow.setAgeCategoryWeight(selectedRow.getAgeCategoryWeight());
+ }
+ batchTableModel.addNewRow(++insertRow, batchNewRow);
+ boolean rowValid = isRowValid(batchNewRow);
+ batchNewRow.setValid(rowValid);
+ saveRow(batchNewRow);
+ }
+ }
+ }
+
+ // reset split ui
+ sampleCategoryEditor.getHandler().editBatch(null);
+
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
+ table.requestFocus();
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -124,5 +124,20 @@
Object oldValue = getTableViewMode();
this.tableViewMode = tableViewMode;
firePropertyChange(PROPERTY_TABLE_VIEW_MODE, oldValue, tableViewMode);
+ firePropertyChange("tableViewModeAll", null, isTableViewModeAll());
+ firePropertyChange("tableViewModeLeaf", null, isTableViewModeLeaf());
+ firePropertyChange("tableViewModeRoot", null, isTableViewModeRoot());
}
+
+ public boolean isTableViewModeAll() {
+ return TableViewMode.ALL.equals(tableViewMode);
+ }
+
+ public boolean isTableViewModeLeaf() {
+ return TableViewMode.LEAF.equals(tableViewMode);
+ }
+
+ public boolean isTableViewModeRoot() {
+ return TableViewMode.ROOT.equals(tableViewMode);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -78,7 +78,7 @@
}
@Override
- protected SpeciesFrequencyRowModel createNewRow() {
+ public SpeciesFrequencyRowModel createNewRow() {
Float defaultStep = null;
int rowCount = getRowCount();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
@@ -73,8 +74,8 @@
category.setCategoryType(categoryType);
}
- public Float getCategoryValue() {
- return category.getCategoryWeight();
+ public Serializable getCategoryValue() {
+ return category.getCategoryValue();
}
public void setCategoryValue(Serializable categoryValue) {
@@ -83,7 +84,18 @@
firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
}
+ public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+ public void setCategoryValue(Float categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
public Float getWeight() {
return category.getCategoryWeight();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -41,11 +41,16 @@
private static final long serialVersionUID = 1L;
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> CATEGORY_VALUE = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SplitSampleCategoryRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
n_("tutti.table.species.sampleCategory.header.category"),
n_("tutti.table.species.sampleCategory.header.category"));
+ public static final ColumnIdentifier<SplitSampleCategoryRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId(
+ SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
+ n_("tutti.table.species.sampleCategory.header.category"),
+ n_("tutti.table.species.sampleCategory.header.category"));
+
public static final ColumnIdentifier<SplitSampleCategoryRowModel> WEIGHT = ColumnIdentifier.newId(
SplitSampleCategoryRowModel.PROPERTY_WEIGHT,
n_("tutti.table.species.sampleCategory.header.weight"),
@@ -53,17 +58,15 @@
private final SplitSampleCategoryUIModel uiModel;
-
public SplitSampleCategoryTableModel(TableColumnModel columnModel,
SplitSampleCategoryUIModel uiModel) {
super(columnModel);
this.uiModel = uiModel;
- setNoneEditableCols();
+ setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
}
@Override
- protected SplitSampleCategoryRowModel createNewRow() {
-
+ public SplitSampleCategoryRowModel createNewRow() {
SplitSampleCategoryRowModel result = new SplitSampleCategoryRowModel();
result.setCategoryType(uiModel.getSelectedCategory());
result.setValid(false);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-31 18:59:33 UTC (rev 134)
@@ -32,7 +32,7 @@
border: {new TitledBorder(null, _("tutti.legend.sampleCategoryConfiguration"))};
}
-#categoryLabelLabel {
+#categoryLabel {
text: "tutti.label.sampleCategoryConfiguration.category";
labelFor: {categoryComboBox};
}
@@ -47,6 +47,36 @@
selected: {model.isSample()};
}
+#speciesLabel {
+ text: "tutti.label.sampleCategoryConfiguration.species";
+ labelFor: {speciesField};
+}
+
+#speciesField {
+ editable: false;
+ text: {handler.decorateSpecies(model.getSpecies())};
+}
+
+#batchWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.batchWeight";
+ labelFor: {batchWeightField};
+}
+
+#batchWeightField {
+ editable: false;
+ text: {getStringValue(model.getBatchWeight())};
+}
+
+#sampleWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.sampleWeight";
+ labelFor: {sampleWeightField};
+}
+
+#sampleWeightField {
+ editable: false;
+ text: {getStringValue(model.getSampleWeight())};
+}
+
#closeButton {
actionIcon: close;
text: "tutti.action.close";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
@@ -69,6 +69,7 @@
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='category' component='categoryComboBox'/>
<field name='sample' component='sampleCheckBox'/>
+ <field name='sampleWeight' component='sampleWeightField'/>
</BeanValidator>
<Table id='configurationPanel' fill='both' constraints='BorderLayout.NORTH'>
@@ -91,6 +92,43 @@
onItemStateChanged='handler.setBoolean(event, "sample")'/>
</cell>
</row>
+
+ <row>
+ <cell columns="2">
+ <JSeparator/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Species -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='speciesLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='speciesField'/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='batchWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='batchWeightField'/>
+ </cell>
+ </row>
+
+ <!-- Sample Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='sampleWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='sampleWeightField'/>
+ </cell>
+ </row>
+
</Table>
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -25,10 +25,9 @@
*/
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
@@ -37,11 +36,11 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
import javax.swing.JDialog;
import java.beans.PropertyChangeEvent;
@@ -74,13 +73,6 @@
*/
private final SplitSampleCategoryUI ui;
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- protected final PersistenceService persistenceService;
-
public SplitSampleCategoryUIHandler(SpeciesBatchUI parentUi,
SplitSampleCategoryUI ui) {
super(parentUi.getHandler().getContext(),
@@ -88,7 +80,6 @@
SplitSampleCategoryRowModel.PROPERTY_WEIGHT);
this.parentUi = parentUi;
this.ui = ui;
- this.persistenceService = getContext().getService(PersistenceService.class);
}
//------------------------------------------------------------------------//
@@ -114,7 +105,16 @@
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
SplitSampleCategoryRowModel row) {
- //TODO
+ if (rowMonitor.wasModified()) {
+
+ if (row.isValid()) {
+ if (log.isInfoEnabled()) {
+ log.info("Change row that was modified and valid");
+ }
+ }
+
+ rowMonitor.clearModified();
+ }
}
@Override
@@ -128,8 +128,8 @@
if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
- // Need to recompute the total weight
- computeComputedWeight(row);
+ // Need to recompute the sample weight
+ computeSampleWeight(row);
}
}
@@ -167,7 +167,14 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- getModel().setSelectedCategory(null);
+ SplitSampleCategoryUIModel source =
+ (SplitSampleCategoryUIModel) evt.getSource();
+
+ // unselect previous selected category
+ source.setSelectedCategory(null);
+
+ // fill comboBox with new list
+ ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
}
});
@@ -176,11 +183,21 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- SampleCategoryEnum newValue = (SampleCategoryEnum) evt.getNewValue();
+ SampleCategoryType newValue =
+ (SampleCategoryType) evt.getNewValue();
generateTableModel(newValue);
}
});
+ // when sample weight changed, revalidate model
+ model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ validateModel();
+ }
+ });
+
generateTableModel(null);
initTable(getTable());
@@ -194,51 +211,72 @@
//-- Public methods --//
//------------------------------------------------------------------------//
- public void editBatch(SpeciesBatchRowModel row) {
+ public String decorateSpecies(Species object) {
+ String result = object == null ? "" : super.decorate(object);
+ return result;
+ }
+ public void editBatch(SpeciesBatchRowModel batch) {
+
// get possible the last used
List<SampleCategoryType> categories =
Lists.newArrayList(SampleCategoryType.values());
- //TODO Use the samplingOrder
- SampleCategory<?> lastCategory = null;
+ Float batchWeight = null;
- if (row.getSortedUnsortedSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sortedUnsorted);
- lastCategory = row.getSortedUnsortedSampleCategory();
- }
+ if (batch != null) {
+ //TODO Use the samplingOrder
+ List<String> samplingOrder =
+ parentUi.getModel().getSamplingOrder();
- if (row.getSizeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.size);
- lastCategory = row.getSizeSampleCategory();
- }
+ SampleCategory<?> lastCategory = null;
- if (row.getSexSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sex);
- lastCategory = row.getSexSampleCategory();
- }
+ if (batch.getSortedUnsortedSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sortedUnsorted);
+ lastCategory = batch.getSortedUnsortedSampleCategory();
+ }
- if (row.getMaturitySampleCategory().isValid()) {
- categories.remove(SampleCategoryType.maturity);
- lastCategory = row.getMaturitySampleCategory();
- }
+ if (batch.getSizeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.size);
+ lastCategory = batch.getSizeSampleCategory();
+ }
- if (row.getAgeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.age);
- lastCategory = row.getAgeSampleCategory();
+ if (batch.getSexSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sex);
+ lastCategory = batch.getSexSampleCategory();
+ }
+
+ if (batch.getMaturitySampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.maturity);
+ lastCategory = batch.getMaturitySampleCategory();
+ }
+
+ if (batch.getAgeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.age);
+ lastCategory = batch.getAgeSampleCategory();
+ }
+
+
+ if (lastCategory == null) {
+
+ // no category, then must only come from the weight
+ batchWeight = batch.getWeight();
+
+ } else {
+
+ // use last category weight
+ batchWeight = lastCategory.getCategoryWeight();
+ }
}
- Float batchWeight = lastCategory == null ? null :
- lastCategory.getCategoryWeight();
-
SplitSampleCategoryUIModel model = getModel();
+ model.setSampleWeight(null);
model.setCategory(categories);
-
model.setBatchWeight(batchWeight);
// keep batch (will be used to push back editing entry)
- model.setBatch(row);
+ model.setBatch(batch);
}
public void close() {
@@ -247,52 +285,62 @@
log.info("Will close UI " + ui);
}
- SplitSampleCategoryUIModel model = getModel();
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
- // transfer rows to editor
- List<SplitSampleCategoryRowModel> safeRows = Lists.newArrayList();
- for (SplitSampleCategoryRowModel row : model.getRows()) {
- if (row.isValid()) {
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
- // can keep this row
- safeRows.add(row);
- }
- }
+ protected void computeSampleWeight(SplitSampleCategoryRowModel row) {
if (log.isInfoEnabled()) {
- log.info("Push back " + safeRows.size() +
- " rows to batch " + model.getBatch());
+ log.info("Will recompute sample weight from row: " + row);
}
- //TODO Create rows in batch table model
- editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ Float result = 0f;
+ List<SplitSampleCategoryRowModel> rows = getTableModel().getRows();
+ for (SplitSampleCategoryRowModel rowModel : rows) {
+ Float weight = rowModel.getWeight();
+ if (weight != null) {
+ result += weight;
+ }
+ }
+ getModel().setSampleWeight(result);
}
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
+ protected void validateModel() {
- protected void computeComputedWeight(SplitSampleCategoryRowModel row) {
+ SplitSampleCategoryUIModel model = getModel();
- if (log.isInfoEnabled()) {
- log.info("Will recompute computed weight for frequency: " + row);
+ int rowCount = model.getRowCount();
+
+ // at least one row
+ boolean valid = rowCount > 0;
+
+ if (valid && !model.isSample()) {
+
+ // sample Weight = batch weight
+ valid = ObjectUtils.equals(model.getBatchWeight(),
+ model.getSampleWeight());
}
+
+ model.setValid(valid);
}
- protected void generateTableModel(SampleCategoryEnum category) {
+ protected void generateTableModel(SampleCategoryType category) {
+ // when generate a new table model, then reset previous rows from model
+ getModel().setRows(null);
+
Caracteristic data = null;
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
+ boolean editableCategoryValue = false;
if (category != null) {
- Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
- getDecorator(CaracteristicQualitativeValue.class, null);
-
switch (category) {
case sortedUnsorted:
@@ -308,18 +356,22 @@
data = persistenceService.getMaturityCaracteristic();
break;
case age:
+ editableCategoryValue = true;
addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.CATEGORY_VALUE,
+ SplitSampleCategoryTableModel.EDITABLE_CATEGORY_VALUE,
TuttiUI.DECIMAL1_PATTERN);
break;
}
if (data != null) {
- addComboDataColumnToModel(columnModel,
- SplitSampleCategoryTableModel.CATEGORY_VALUE,
- caracteristicDecorator,
- data.getQualitativeValue());
+ if (log.isInfoEnabled()) {
+ log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
+ }
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(CaracteristicQualitativeValue.class),
+ SplitSampleCategoryTableModel.READ_ONLY_CATEGORY_VALUE);
}
{ // Weight
@@ -335,21 +387,42 @@
JXTable table = getTable();
+ // remove all listener on tables we could add before
+ uninstallTableSaveOnRowChangedSelectionListener();
+// uninstallTableKeyListener();
+
+ if (log.isInfoEnabled()) {
+ log.info("Install new table model " + tableModel);
+ }
table.setModel(tableModel);
table.setColumnModel(columnModel);
- //TODO Fix this!
-// installTableKeyListener(columnModel, table);
+ // install table listeners
+ installTableSaveOnRowChangedSelectionListener();
+// installTableKeyListener(columnModel, table, editableCategoryValue);
+ // fill datas
+
+ List<SplitSampleCategoryRowModel> rows = Lists.newArrayList();
+
if (data != null) {
// add a row for each qualitive value
for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ if (log.isInfoEnabled()) {
+ log.info("Add QV: " + qualitativeValue);
+ }
SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
newRow.setCategoryValue(qualitativeValue);
- tableModel.addNewRow(newRow);
+ rows.add(newRow);
}
}
+
+ if (log.isInfoEnabled()) {
+ log.info("Will add " + rows.size() + " rows in table model.");
+ }
+
+ getModel().setRows(rows);
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
@@ -42,6 +43,8 @@
public static final String PROPERTY_CATEGORY = "category";
+ public static final String PROPERTY_SPECIES = "species";
+
public static final String PROPERTY_SAMPLE = "sample";
public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory";
@@ -85,7 +88,6 @@
*/
protected Float batchWeight;
-
/**
* Sample weight of split batches.
*
@@ -102,9 +104,15 @@
}
public void setBatch(SpeciesBatchRowModel batch) {
+ Object oldSpecies = getSpecies();
this.batch = batch;
+ firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
}
+ public Species getSpecies() {
+ return batch == null ? null : batch.getSpecies();
+ }
+
public List<SampleCategoryType> getCategory() {
return category;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -55,7 +55,7 @@
}
@Override
- protected EnvironmentRowModel createNewRow() {
+ public EnvironmentRowModel createNewRow() {
EnvironmentRowModel result = new EnvironmentRowModel();
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -55,7 +55,7 @@
}
@Override
- protected GearShootingRowModel createNewRow() {
+ public GearShootingRowModel createNewRow() {
GearShootingRowModel result = new GearShootingRowModel();
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -65,7 +65,7 @@
}
@Override
- protected HydrologyRowModel createNewRow() {
+ public HydrologyRowModel createNewRow() {
HydrologyRowModel result = new HydrologyRowModel();
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -81,7 +81,7 @@
}
@Override
- protected EditProtocolSpeciesRowModel createNewRow() {
+ public EditProtocolSpeciesRowModel createNewRow() {
EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel();
result.setMaturityEnabled(true);
result.setSizeEnabled(true);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
@@ -79,7 +79,7 @@
*/
protected Set<ColumnIdentifier<?>> noneEditableCols;
- protected abstract R createNewRow();
+ public abstract R createNewRow();
protected AbstractTuttiTableModel(TableColumnModel columnModel) {
int nbcols = columnModel.getColumnCount();
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-31 12:31:24 UTC (rev 133)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-31 18:59:33 UTC (rev 134)
@@ -8,6 +8,7 @@
tutti.action.close=Fermer
tutti.action.configuration=Configuration
tutti.action.configuration.tip=Configurer Tutti
+tutti.action.createSpeciesBatch=Créer un lot pour une espèce
tutti.action.edit=Editer
tutti.action.exit=Quitter
tutti.action.exit.tip=Quitter l'application
@@ -23,12 +24,14 @@
tutti.action.reload.application=Recharger l'application
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
+tutti.action.removeSubBatch=Supprimer les lots
tutti.action.reset.fishingOperationValidState=Réinitialiser
tutti.action.save=Enregistrer
tutti.action.selectCampaign=Campagne
tutti.action.selectCampaign.tip=Sélectionner la campagne à utiliser
tutti.action.site=Site
tutti.action.site.tip=Accéder au site du projet Tutti
+tutti.action.splitBatch=Catégoriser un lot
tutti.application.config=Configuration de l'application Tutti
tutti.application.name=Tutti
tutti.config.category.applications=Application
@@ -77,6 +80,9 @@
tutti.label.cruise.program=Série
tutti.label.cruise.surveyPart=Série partielle
tutti.label.cruise.year=Année
+tutti.label.filterSpeciesBatchMode.mode.all=Tout voir
+tutti.label.filterSpeciesBatchMode.mode.leaf=Voir les feuilles
+tutti.label.filterSpeciesBatchMode.mode.root=Voir les parents
tutti.label.fishingOperation.date=Date
tutti.label.fishingOperation.distanceChalutee=Distance chalutée
tutti.label.fishingOperation.duree=Durée
@@ -116,7 +122,11 @@
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
tutti.label.protocol=Protocol de saisie
+tutti.label.sampleCategoryConfiguration.batchWeight=Poids total à catégoriser
+tutti.label.sampleCategoryConfiguration.category=Catégorie
tutti.label.sampleCategoryConfiguration.sample=Echantillon ?
+tutti.label.sampleCategoryConfiguration.sampleWeight=Poids total catégorisé
+tutti.label.sampleCategoryConfiguration.species=Espèce
tutti.label.tab.accidentel=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
@@ -138,6 +148,7 @@
tutti.legend.catch.macroWaste=Macro déchets
tutti.legend.catch.species=Espèces
tutti.legend.catch.total=Capture
+tutti.legend.filterSpeciesBatchMode=Filtrer les lots
tutti.legend.frequencyConfiguration=Configuration
tutti.legend.sampleCategoryConfiguration=Configuration
tutti.menu.actions=Actions
@@ -223,6 +234,7 @@
tutti.table.species.sampleCategory.header.weight=Poids
tutti.timeeditor.H=H
tutti.title.about=À propos de Tutti
+tutti.title.batchActions=Actions possibles
tutti.title.create.cruise=Créer une nouvelle campagne
tutti.title.create.program=Créer une nouvelle série de campagne
tutti.title.create.protocol=Créer un nouveau protocol de saisie
@@ -239,6 +251,7 @@
tutti.title.selectedCruise=Campagne %s
tutti.title.selectedProgram=Série de campagne %s
tutti.title.selectedProtocol=Protocol %s
+tutti.title.splitBatch=Catégoriser un lot
tutti.to.be.done=< A FAIRE >
tutti.tooltip.attachment.none=Pas de pièce-jointes
tutti.tooltip.comment.none=Pas de commentaire
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
1
0
r133 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation content/operation/catches/species/frequency util/table
by tchemit@users.forge.codelutin.com 31 Dec '12
by tchemit@users.forge.codelutin.com 31 Dec '12
31 Dec '12
Author: tchemit
Date: 2012-12-31 13:31:24 +0100 (Mon, 31 Dec 2012)
New Revision: 133
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/133
Log:
- improve navigation action in cells (now not force to create a new row if at end)
- improve listener api (can uninstall them too!)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -114,7 +114,7 @@
TableColumnModel columnModel,
AbstractTuttiTableModel<R> tableModel) {
- installTableKeyListener(columnModel, table);
+ installTableKeyListener(columnModel, table, true);
JTableFilter tableFilter = new JTableFilter(table);
TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -59,6 +59,11 @@
private static final Log log =
LogFactory.getLog(SpeciesFrequencyUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
private final SpeciesFrequencyUI ui;
public SpeciesFrequencyUIHandler(TuttiUIContext context,
@@ -146,7 +151,6 @@
lengthStepCaracterics,
model.getLengthStepCaracteristic());
-
//TODO Should it come from PROTOCOL or config ?
model.setStep(.5f);
@@ -220,7 +224,7 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- installTableKeyListener(columnModel, table);
+ installTableKeyListener(columnModel, table, true);
initTable(table);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -25,6 +25,7 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
@@ -62,7 +63,6 @@
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Enumeration;
@@ -295,79 +295,13 @@
// always scroll to selected row
SwingUtil.scrollToTableSelection(getTable());
+ // always force to uninstall listener
+ uninstallTableSaveOnRowChangedSelectionListener();
+
// save when row chaged and was modified
- ListSelectionListener listener = new TableRowModificationListener<R>(
- getTableModel(), rowMonitor) {
- @Override
- protected void saveSelectedRow() {
-
- saveSelectedRowIfNeeded();
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
+ installTableSaveOnRowChangedSelectionListener();
}
- protected final void saveSelectedRowIfNeeded() {
-
- R row = rowMonitor.getBean();
-
- if (row != null) {
-
- saveSelectedRowIfRequired(rowMonitor, row);
- }
- }
-
- protected KeyListener installTableKeyListener(TableColumnModel columnModel,
- JTable table) {
-
- AbstractTuttiTableModel<R> model = getTableModel();
- final MoveToNextEditableCellAction nextCellAction =
- MoveToNextEditableCellAction.newAction(model, table);
- final MoveToPreviousEditableCellAction previousCellAction =
- MoveToPreviousEditableCellAction.newAction(model, table);
-
- final MoveToNextEditableRowAction nextRowAction =
- MoveToNextEditableRowAction.newAction(model, table);
- final MoveToPreviousEditableRowAction previousRowAction =
- MoveToPreviousEditableRowAction.newAction(model, table);
-
- // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
- // touches "entrer", "gauche", "droite" de facon personnalisée.
- KeyAdapter keyAdapter = new KeyAdapter() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER ||
- e.getKeyCode() == KeyEvent.VK_RIGHT ||
- e.getKeyCode() == KeyEvent.VK_TAB) {
- e.consume();
- nextCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
- e.consume();
- previousCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
- e.consume();
- previousRowAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
- e.consume();
- nextRowAction.actionPerformed(null);
- }
- }
- };
- table.addKeyListener(keyAdapter);
-
- Enumeration<TableColumn> columns = columnModel.getColumns();
- while (columns.hasMoreElements()) {
- TableColumn tableColumn = columns.nextElement();
- TableCellEditor cellEditor = tableColumn.getCellEditor();
- if (cellEditor instanceof NumberCellEditor) {
- NumberCellEditor editor = (NumberCellEditor) cellEditor;
- editor.getNumberEditor().getTextField().addKeyListener(keyAdapter);
- }
- }
- return keyAdapter;
- }
-
protected void addColumnToModel(TableColumnModel model,
TableCellEditor editor,
TableCellRenderer renderer,
@@ -433,11 +367,13 @@
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(newListCellRender(decorator));
+ List<B> dataToList = Lists.newArrayList(data);
+
// add a null value at first position
- if (!data.isEmpty() && data.get(0) != null) {
- data.add(0, null);
+ if (!dataToList.isEmpty() && dataToList.get(0) != null) {
+ dataToList.add(0, null);
}
- SwingUtil.fillComboBox(comboBox, data, null);
+ SwingUtil.fillComboBox(comboBox, dataToList, null);
ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
BeanUIUtil.decorate(comboBox, converter);
@@ -470,4 +406,147 @@
return result;
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods (listener methods) --//
+ //------------------------------------------------------------------------//
+
+ private ListSelectionListener tableSelectionListener;
+
+ private KeyAdapter keyAdapter;
+
+ protected void installTableSaveOnRowChangedSelectionListener() {
+
+ Preconditions.checkState(
+ tableSelectionListener == null,
+ "There is already a tableSelectionListener registred, " +
+ "remove it before invoking this method.");
+
+ // create new listener
+ // save when row chaged and was modified
+
+ tableSelectionListener = new TableRowModificationListener<R>(
+ getTableModel(), rowMonitor) {
+ @Override
+ protected void saveSelectedRow() {
+
+ saveSelectedRowIfNeeded();
+ }
+ };
+
+ if (log.isInfoEnabled()) {
+ log.info("Intall " + tableSelectionListener + " on tableModel " + getTableModel());
+ }
+
+ getTable().getSelectionModel().addListSelectionListener(tableSelectionListener);
+ }
+
+ protected void uninstallTableSaveOnRowChangedSelectionListener() {
+
+ if (tableSelectionListener != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Desintall " + tableSelectionListener);
+ }
+
+ // there was a previous selection listener, remove it
+ getTable().getSelectionModel().removeListSelectionListener(tableSelectionListener);
+ tableSelectionListener = null;
+ }
+ }
+
+ protected void installTableKeyListener(TableColumnModel columnModel,
+ JTable table, boolean canCreateRow) {
+
+ Preconditions.checkState(
+ keyAdapter == null,
+ "There is already a tableSelectionListener registred, " +
+ "remove it before invoking this method.");
+
+ AbstractTuttiTableModel<R> model = getTableModel();
+ final MoveToNextEditableCellAction nextCellAction =
+ MoveToNextEditableCellAction.newAction(model, table, canCreateRow);
+ final MoveToPreviousEditableCellAction previousCellAction =
+ MoveToPreviousEditableCellAction.newAction(model, table);
+
+ final MoveToNextEditableRowAction nextRowAction =
+ MoveToNextEditableRowAction.newAction(model, table, canCreateRow);
+ final MoveToPreviousEditableRowAction previousRowAction =
+ MoveToPreviousEditableRowAction.newAction(model, table);
+
+ // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
+ // touches "entrer", "gauche", "droite" de facon personnalisée.
+ keyAdapter = new KeyAdapter() {
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER ||
+ e.getKeyCode() == KeyEvent.VK_RIGHT ||
+ e.getKeyCode() == KeyEvent.VK_TAB) {
+ e.consume();
+ nextCellAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ e.consume();
+ previousCellAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_UP) {
+ e.consume();
+ previousRowAction.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ e.consume();
+ nextRowAction.actionPerformed(null);
+ }
+ }
+ };
+
+ if (log.isInfoEnabled()) {
+ log.info("Intall " + keyAdapter);
+ }
+
+ table.addKeyListener(keyAdapter);
+
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ TableCellEditor cellEditor = tableColumn.getCellEditor();
+ if (cellEditor instanceof NumberCellEditor) {
+ NumberCellEditor editor = (NumberCellEditor) cellEditor;
+ editor.getNumberEditor().getTextField().addKeyListener(keyAdapter);
+ }
+ }
+ }
+
+ protected void uninstallTableKeyListener() {
+
+
+ if (keyAdapter != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Desintall " + keyAdapter);
+ }
+
+ getTable().removeKeyListener(keyAdapter);
+
+ TableColumnModel columnModel = getTable().getColumnModel();
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ TableCellEditor cellEditor = tableColumn.getCellEditor();
+ if (cellEditor instanceof NumberCellEditor) {
+ NumberCellEditor editor = (NumberCellEditor) cellEditor;
+ editor.getNumberEditor().getTextField().removeKeyListener(keyAdapter);
+ }
+ }
+ keyAdapter = null;
+ }
+ }
+
+ protected final void saveSelectedRowIfNeeded() {
+
+ R row = rowMonitor.getBean();
+
+ if (row != null) {
+
+ saveSelectedRowIfRequired(rowMonitor, row);
+ }
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2012-12-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -44,12 +44,20 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableCellAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table) {
- return new MoveToNextEditableCellAction<M>(model, table);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table, boolean canCreateRow) {
+ return new MoveToNextEditableCellAction<M>(model, table, canCreateRow);
}
- protected MoveToNextEditableCellAction(M model, JTable table) {
+ /**
+ * Can create new row if reach the end of editable cells ?
+ *
+ * @since 0.3
+ */
+ private final boolean canCreateRow;
+
+ protected MoveToNextEditableCellAction(M model, JTable table, boolean canCreateRow) {
super(model, table);
+ this.canCreateRow = canCreateRow;
}
@Override
@@ -81,8 +89,14 @@
if (currentRow == rowCount) {
- // create a new row in model
- addNewRow();
+ if (canCreateRow) {
+ // create a new row in model
+ addNewRow();
+ } else {
+
+ // can not create new row, so do nothing
+ break;
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2012-12-30 19:39:00 UTC (rev 132)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2012-12-31 12:31:24 UTC (rev 133)
@@ -44,12 +44,20 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableRowAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table) {
- return new MoveToNextEditableRowAction<M>(model, table);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table, boolean canCreateRow) {
+ return new MoveToNextEditableRowAction<M>(model, table, canCreateRow);
}
- protected MoveToNextEditableRowAction(M model, JTable table) {
+ /**
+ * Can create new row if reach the end of editable cells ?
+ *
+ * @since 0.3
+ */
+ private final boolean canCreateRow;
+
+ protected MoveToNextEditableRowAction(M model, JTable table, boolean canCreateRow) {
super(model, table);
+ this.canCreateRow = canCreateRow;
}
@Override
@@ -64,17 +72,23 @@
}
currentRow++;
+ boolean canSelect = true;
if (currentRow >= getRowCount()) {
if (log.isDebugEnabled()) {
log.debug("No next row");
}
+ if (canCreateRow) {
+ // create a new row in model
+ addNewRow();
+ } else {
+ canSelect = false;
+ }
+ }
- // create a new row in model
- addNewRow();
+ if (canSelect) {
+ doSelectCell(currentRow, currentColumn);
}
- doSelectCell(currentRow, currentColumn);
-
} else {
if (log.isDebugEnabled()) {
log.debug("Cell not editable at " +
1
0
30 Dec '12
Author: tchemit
Date: 2012-12-30 20:39:00 +0100 (Sun, 30 Dec 2012)
New Revision: 132
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/132
Log:
- use jaxx last features
- clean css
- improve table api
- improve edit protocol design (at last do not save not valid data :()
- try and stop to improve design of pmfm in fishing stuff (need to improve this point!)
- start of config
- improve start and run of application (sammoa was not a good example to follow...)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,7 +28,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.IdAware;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -48,7 +47,6 @@
import javax.swing.JList;
import javax.swing.ListCellRenderer;
-import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
@@ -58,8 +56,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -168,7 +164,7 @@
Preconditions.checkNotNull(comboBox, "No comboBox!");
- Class<E> beanType = (Class<E>) comboBox.getHandler().getTargetClass();
+ Class<E> beanType = comboBox.getBeanType();
Preconditions.checkNotNull(beanType, "No beanType on the combobox!");
@@ -195,8 +191,8 @@
* pour un service de persistance donné.
*
* @param list le component graphique à initialiser
- * @param data
- * @param selectedData
+ * @param data la liste des données à mettre dans la liste de gauche
+ * @param selectedData la liste des données à mettre dans la liste de droite
*/
protected <E extends IdAware> void initBeanList(
BeanDoubleList<E> list,
@@ -260,36 +256,6 @@
picker.getEditor().setEditable(false);
}
- protected <B extends IdAware> void updateIndices(JList jlist,
- List<B> list) {
-
- List<String> ids = TuttiEntities.toIds(list);
-
- List<Integer> indices = new ArrayList<Integer>();
-
- if (list != null && !list.isEmpty()) {
-
- ListModel model = jlist.getModel();
-
- for (int i = 0, max = model.getSize(); i < max; i++) {
- B s = (B) model.getElementAt(i);
- if (ids.contains(s.getId())) {
- indices.add(i);
- }
- }
- }
- int[] result = new int[indices.size()];
- int i = 0;
- for (Integer indice : indices) {
- result[i++] = indice;
- }
- indices.clear();
- if (log.isDebugEnabled()) {
- log.debug("Selected indices : " + Arrays.toString(result));
- }
- jlist.setSelectedIndices(result);
- }
-
protected <O> Decorator<O> getDecorator(Class<O> type, String name) {
DecoratorService decoratorService =
context.getService(DecoratorService.class);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -23,103 +23,103 @@
*/
#mainFrame {
- title: "tutti.application.name";
- defaultCloseOperation: {JFrame.DO_NOTHING_ON_CLOSE};
+ title: "tutti.application.name";
+ defaultCloseOperation: {JFrame.DO_NOTHING_ON_CLOSE};
}
#menuFile {
- text: "tutti.menu.file";
- toolTipText: "tutti.menu.file.tip";
- mnemonic: F;
+ text: "tutti.menu.file";
+ toolTipText: "tutti.menu.file.tip";
+ mnemonic: F;
}
#menuFileConfiguration {
- text: "tutti.action.configuration";
- toolTipText: "tutti.action.configuration.tip";
- actionIcon: "config";
- mnemonic: C;
+ text: "tutti.action.configuration";
+ toolTipText: "tutti.action.configuration.tip";
+ actionIcon: config;
+ mnemonic: C;
}
#menuFileExit {
- text: "tutti.action.exit";
- toolTipText: "tutti.action.exit.tip";
- actionIcon: "exit";
+ text: "tutti.action.exit";
+ toolTipText: "tutti.action.exit.tip";
+ actionIcon: exit;
}
#menuActions {
- text: "tutti.menu.actions";
- toolTipText: "tutti.menu.actions.tip";
- mnemonic: A;
+ text: "tutti.menu.actions";
+ toolTipText: "tutti.menu.actions.tip";
+ mnemonic: A;
}
#menuActionManageProtocol {
- text: "tutti.action.manageProtocol";
- toolTipText: "tutti.action.manageProtocol.tip";
- mnemonic: P;
- enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
- /*actionIcon: "protocol";*/
+ text: "tutti.action.manageProtocol";
+ toolTipText: "tutti.action.manageProtocol.tip";
+ mnemonic: P;
+ enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
+ /*actionIcon: "protocol";*/
}
#menuActionSelectCampaign {
- text: "tutti.action.selectCampaign";
- toolTipText: "tutti.action.selectCampaign.tip";
- mnemonic: S;
- enabled: {model.getScreen() != TuttiScreen.SELECT_CRUISE};
- /*actionIcon: "cruise";*/
+ text: "tutti.action.selectCampaign";
+ toolTipText: "tutti.action.selectCampaign.tip";
+ mnemonic: S;
+ enabled: {model.getScreen() != TuttiScreen.SELECT_CRUISE};
+ /*actionIcon: "cruise";*/
}
#menuActionFillCatches {
- text: "tutti.action.fillCatches";
- toolTipText: "tutti.action.fillCatches.tip";
- mnemonic: C;
- enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()};
- /*actionIcon: "catches";*/
+ text: "tutti.action.fillCatches";
+ toolTipText: "tutti.action.fillCatches.tip";
+ mnemonic: C;
+ enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()};
+ /*actionIcon: "catches";*/
}
#menuSynchronisations {
- text: "tutti.menu.synchronisations";
- toolTipText: "tutti.menu.synchronisations.tip";
- mnemonic: S;
+ text: "tutti.menu.synchronisations";
+ toolTipText: "tutti.menu.synchronisations.tip";
+ mnemonic: S;
}
#menuSynchronisationImport {
- text: "tutti.menu.synchronisationImport";
- toolTipText: "tutti.menu.synchronisationImport.tip";
- mnemonic: I;
- enabled: false;
+ text: "tutti.menu.synchronisationImport";
+ toolTipText: "tutti.menu.synchronisationImport.tip";
+ mnemonic: I;
+ enabled: false;
}
#menuSynchronisationExport {
- text: "tutti.menu.synchronisationExport";
- toolTipText: "tutti.menu.synchronisationExport.tip";
- mnemonic: E;
- enabled: false;
+ text: "tutti.menu.synchronisationExport";
+ toolTipText: "tutti.menu.synchronisationExport.tip";
+ mnemonic: E;
+ enabled: false;
}
#menuSynchronisationAllegro {
- text: "tutti.menu.synchronisationAllegro";
- toolTipText: "tutti.menu.synchronisationAllegro.tip";
- mnemonic: A;
- enabled: false;
+ text: "tutti.menu.synchronisationAllegro";
+ toolTipText: "tutti.menu.synchronisationAllegro.tip";
+ mnemonic: A;
+ enabled: false;
}
#menuHelp {
- text: "tutti.menu.help";
- toolTipText: "tutti.menu.help.tip";
- mnemonic: E;
+ text: "tutti.menu.help";
+ toolTipText: "tutti.menu.help.tip";
+ mnemonic: E;
}
#menuHelpSite {
- text: "tutti.action.site";
- toolTipText: "tutti.action.site.tip";
- actionIcon: "site";
- mnemonic: S;
+ text: "tutti.action.site";
+ toolTipText: "tutti.action.site.tip";
+ actionIcon: site;
+ mnemonic: S;
}
#menuHelpAbout {
- text: "tutti.action.about";
- toolTipText: "tutti.action.about.tip";
- actionIcon: "about";
- mnemonic: A;
+ text: "tutti.action.about";
+ toolTipText: "tutti.action.about.tip";
+ actionIcon: about;
+ mnemonic: A;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -72,13 +72,13 @@
<JMenu id='menuSynchronisations'>
- <JMenuItem id='menuSynchronisationImport'
- onActionPerformed="getHandler().showImportScreen()"/>
- <JMenuItem id='menuSynchronisationExport'
- onActionPerformed="getHandler().showExportScreen()"/>
- <JMenuItem id='menuSynchronisationAllegro'
- onActionPerformed="getHandler().showAllegroScreen()"/>
- </JMenu>
+ <JMenuItem id='menuSynchronisationImport'
+ onActionPerformed="getHandler().showImportScreen()"/>
+ <JMenuItem id='menuSynchronisationExport'
+ onActionPerformed="getHandler().showExportScreen()"/>
+ <JMenuItem id='menuSynchronisationAllegro'
+ onActionPerformed="getHandler().showAllegroScreen()"/>
+ </JMenu>
<JMenu id='menuHelp'>
<JMenuItem id='menuHelpSite'
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,19 +28,16 @@
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
-import fr.ifremer.tutti.ui.swing.config.TuttiConfigOption;
+import fr.ifremer.tutti.ui.swing.config.TuttiConfigUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.editor.config.ConfigUIHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ApplicationConfig;
@@ -54,7 +51,6 @@
import java.util.Calendar;
import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -78,6 +74,10 @@
context.addMessageNotifier(this);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void beforeInitUI() {
context.addPropertyChangeListener(new PropertyChangeListener() {
@@ -129,7 +129,7 @@
@Override
public void onCloseUI() {
- closeCurrentBody();
+// closeCurrentBody();
context.close();
}
@@ -139,94 +139,43 @@
return ui.getModel();
}
- public void showConfig() {
- TuttiConfig config = context.getConfig();
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
- ConfigUIHelper helper = new ConfigUIHelper(config.getApplicationConfig());
+ public void closeTutti() {
+ RunTutti.closeTutti(ui, true);
+ }
- helper.registerCallBack(
- "ui", n_("tutti.action.reload.ui"),
- SwingUtil.createActionIcon("reload-ui"),
- new Runnable() {
+ public void reloadTutti() {
- @Override
- public void run() {
- reloadTutti();
- }
- }
- ).registerCallBack(
- "home", n_("tutti.action.reload.home"),
- SwingUtil.createActionIcon("config"),
- new Runnable() {
+ // Close the application
+ RunTutti.closeTutti(ui, false);
- @Override
- public void run() {
- if (TuttiScreen.SELECT_CRUISE == context.getScreen()) {
- // Reselect home cruise
-// SelectCampaignUI homeUI = (SelectCampaignUI) currentBody;
-// homeUI.getHandler().selectCampaign();
- }
- }
- }
- ).registerCallBack(
- "actions", n_("tutti.action.reload.actions"),
- SwingUtil.createActionIcon("config"),
- new Runnable() {
+ // Re-open the context
+// try {
+// context.open();
+// } catch (Exception ex) {
+// ErrorDialogUI.showError(ex);
+// }
- @Override
- public void run() {
+ RunTutti.startTutti(context);
+ }
- //TODO Reload actions shortcuts
- }
- }
- );
+ public void reloadApplication() {
+ //TODO
+ }
- // APPLICATION
+ public void reloadShortcuts() {
+ //TODO
+ }
- helper.addCategory(n_("tutti.config.category.applications"),
- n_("tutti.config.category.applications.description"))
- .addOption(TuttiServiceConfigOption.DATA_DIRECTORY)
- .setOptionCallBack("ui");
-// .addOption(TuttiConfigOption.AUTO_COMMIT_DELAY) // milliseconds
-// .setOptionCallBack("ui");
+ public void showConfig() {
- // SHORTCUT
-
-// helper.addCategory(n_("tutti.config.category.shortcuts"),
-// n_("tutti.config.category.shortcuts.description"), "actions")
-// .addOption(TuttiConfigOption.KEY_START)
-// .addOption(TuttiConfigOption.KEY_STOP)
-// .addOption(TuttiConfigOption.KEY_BEGIN)
-// .addOption(TuttiConfigOption.KEY_END)
-// .addOption(TuttiConfigOption.KEY_NEXT)
-// .addOption(TuttiConfigOption.KEY_ADD)
-// .addOption(TuttiConfigOption.KEY_LEFT_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_CENTER_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_RIGHT_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_CIRCLE_BACK)
-// .addOption(TuttiConfigOption.KEY_VALID_FLIGHT)
-// .addOption(TuttiConfigOption.KEY_VALID_TRANSECT)
-// .addOption(TuttiConfigOption.KEY_VALID_OBSERVATION)
-// .addOption(TuttiConfigOption.KEY_VALID_ROUTE);
-
- // OTHER
-
- helper.addCategory(n_("tutti.config.category.other"),
- n_("tutti.config.category.other.description"))
- .addOption(TuttiServiceConfigOption.SITE_URL)
- .addOption(TuttiConfigOption.UI_CONFIG_FILE)
- .setOptionCallBack("ui");
-
-
- helper.buildUI(ui, "tutti.config.category.applications");
-
- helper.displayUI(ui, false);
+ TuttiConfigUI configUI = new TuttiConfigUI(ui);
+ configUI.createUI();
}
- public void closeTutti() {
- closeTutti(true);
- }
-
public void showManageProtocol() {
context.setScreen(TuttiScreen.EDIT_PROTOCOL);
}
@@ -314,6 +263,10 @@
ui.getStatus().setStatus(message);
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
protected void setScreen(TuttiScreen screen) {
try {
@@ -321,70 +274,80 @@
// busy ui
TuttiUIUtil.updateBusyState(ui, true);
- // remove any screen
-// ui.setScreen(null);
+ // close current body (if any)
+ if (currentBody != null) {
+ TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
+ body.getHandler().onCloseUI();
- closeCurrentBody();
+ context.getSwingSession().save();
- String programId = context.getProgramId();
- String cruiseId = context.getCruiseId();
- String protocolId = context.getProtocolId();
+ ui.getBody().remove(currentBody);
- JComponent screenUI;
- String screenTitle;
+ currentBody = null;
+ }
- switch (screen) {
- default:
- case SELECT_CRUISE:
+ if (screen != null) {
- screenUI = new SelectCruiseUI(context);
- screenTitle = _("tutti.title.home");
- break;
+ String programId = context.getProgramId();
+ String cruiseId = context.getCruiseId();
+ String protocolId = context.getProtocolId();
- case EDIT_PROGRAM:
+ JComponent screenUI;
+ String screenTitle;
- if (programId == null) {
- screenTitle = _("tutti.title.create.program");
- } else {
- screenTitle = _("tutti.title.edit.program");
- }
+ switch (screen) {
+ default:
+ case SELECT_CRUISE:
- screenUI = new EditProgramUI(context);
- break;
+ screenUI = new SelectCruiseUI(context);
+ screenTitle = _("tutti.title.home");
+ break;
- case EDIT_CRUISE:
+ case EDIT_PROGRAM:
- if (cruiseId == null) {
- screenTitle = _("tutti.title.create.cruise");
- } else {
- screenTitle = _("tutti.title.edit.cruise");
- }
+ if (programId == null) {
+ screenTitle = _("tutti.title.create.program");
+ } else {
+ screenTitle = _("tutti.title.edit.program");
+ }
- screenUI = new EditCruiseUI(context);
- break;
+ screenUI = new EditProgramUI(context);
+ break;
- case EDIT_PROTOCOL:
+ case EDIT_CRUISE:
- if (protocolId == null) {
- screenTitle = _("tutti.title.create.protocol");
- } else {
- screenTitle = _("tutti.title.edit.protocol");
- }
+ if (cruiseId == null) {
+ screenTitle = _("tutti.title.create.cruise");
+ } else {
+ screenTitle = _("tutti.title.edit.cruise");
+ }
- screenUI = new EditProtocolUI(context);
- break;
+ screenUI = new EditCruiseUI(context);
+ break;
- case EDIT_FISHING_OPERATION:
+ case EDIT_PROTOCOL:
- screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle());
- screenUI = new FishingOperationsUI(context);
- break;
- }
+ if (protocolId == null) {
+ screenTitle = _("tutti.title.create.protocol");
+ } else {
+ screenTitle = _("tutti.title.edit.protocol");
+ }
- changeScreen(screenUI, screenTitle);
+ screenUI = new EditProtocolUI(context);
+ break;
- // set new screen only if everything is ok
-// ui.setScreen(screen);
+ case EDIT_FISHING_OPERATION:
+
+ screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle());
+ screenUI = new FishingOperationsUI(context);
+ break;
+ }
+
+ this.currentBody = screenUI;
+ context.getSwingSession().add(currentBody);
+ ui.getBody().setTitle(screenTitle);
+ ui.getBody().add(currentBody);
+ }
} catch (Exception e) {
ErrorDialogUI.showError(e);
@@ -398,56 +361,20 @@
}
}
- protected void reloadTutti() {
+// protected void closeTutti(boolean exit) {
+//
+// context.getSwingSession().save();
+//
+// ui.setVisible(false);
+// ui.dispose();
+//
+// onCloseUI();
+//
+// if (exit) {
+// System.exit(0);
+// }
+// }
- // Close the application
- closeTutti(false);
-
- // Re-open the context
- try {
- context.open();
- } catch (Exception ex) {
- ErrorDialogUI.showError(ex);
- }
-
- MainUI mainUI = new MainUI(context);
- mainUI.setVisible(true);
- }
-
- protected void closeCurrentBody() {
- if (currentBody != null) {
- TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
- body.getHandler().onCloseUI();
-
- context.getSwingSession().save();
-
- ui.getBody().remove(currentBody);
-
- currentBody = null;
- }
- }
-
- protected void changeScreen(JComponent newBody, String title) {
- currentBody = newBody;
- context.getSwingSession().add(currentBody);
- ui.getBody().setTitle(title);
- ui.getBody().add(currentBody);
- }
-
- protected void closeTutti(boolean exit) {
-
- context.getSwingSession().save();
-
- ui.setVisible(false);
- ui.dispose();
-
- onCloseUI();
-
- if (exit) {
- System.exit(0);
- }
- }
-
protected void changeTitle() {
String title = getSelectedCruiseTitle();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -67,8 +67,6 @@
}
}));
- context.open();
-
// Initialize i18n
I18n.init(new DefaultI18nInitializer("tutti-ui-swing"), Locale.UK);
@@ -86,9 +84,29 @@
new BorderUIResource.LineBorderUIResource(Color.BLACK));
UIManager.put("BlockingLayerUI.blockingColor", new Color(50, 50, 50));
+ startTutti(context);
+ }
+
+ public static void startTutti(TuttiUIContext context) {
+
+ context.open();
+
MainUI mainUI = new MainUI(context);
mainUI.setVisible(true);
+ }
+ public static void closeTutti(MainUI ui, boolean exit) {
+
+ ui.getHandler().getContext().getSwingSession().save();
+
+ ui.getHandler().onCloseUI();
+
+ ui.setVisible(false);
+ ui.dispose();
+
+ if (exit) {
+ System.exit(0);
+ }
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -348,6 +348,8 @@
cruiseId = null;
protocolId = null;
+ setScreen(null);
+
IOUtils.closeQuietly(serviceContext);
// remove listeners
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,6 +35,7 @@
import org.nuiton.util.Version;
import javax.swing.KeyStroke;
+import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -133,7 +134,18 @@
return applicationConfig.getOption(TuttiConfigOption.PROTOCOL_ID.getKey());
}
+ public Color getColorRowInvalid() {
+ return applicationConfig.getOptionAsColor(TuttiConfigOption.COLOR_ROW_INVALID.getKey());
+ }
+ public Color getColorRowReadOnly() {
+ return applicationConfig.getOptionAsColor(TuttiConfigOption.COLOR_ROW_READ_ONLY.getKey());
+ }
+
+ public KeyStroke getShortcutClosePopup() {
+ return applicationConfig.getOptionAsKeyStroke(TuttiConfigOption.SHORTCUT_CLOSE_POPUP.getKey());
+ }
+
public KeyStroke getShortCut(String actionName) {
KeyStroke result = applicationConfig.getOptionAsKeyStroke(
"tutti.ui." + actionName);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,6 +26,8 @@
import org.nuiton.util.ApplicationConfig;
+import javax.swing.KeyStroke;
+import java.awt.Color;
import java.io.File;
import static org.nuiton.i18n.I18n.n_;
@@ -38,40 +40,66 @@
*/
public enum TuttiConfigOption implements ApplicationConfig.OptionDef {
- UI_CONFIG_FILE("tutti.ui.config",
- n_("tutti.config.ui.config"),
- "${tutti.data.directory}/tuttiUI.xml",
- File.class
+ UI_CONFIG_FILE(
+ "tutti.ui.config",
+ n_("tutti.config.ui.config"),
+ "${tutti.data.directory}/tuttiUI.xml",
+ File.class
),
- PROGRAM_ID("tutti.programId",
- n_("tutti.config.programId"),
- null,
- String.class
+
+ PROGRAM_ID(
+ "tutti.programId",
+ n_("tutti.config.programId"),
+ null,
+ String.class
),
- CRUISE_ID("tutti.cruiseId",
- n_("tutti.config.cruiseId"),
- null,
- String.class
+
+ CRUISE_ID(
+ "tutti.cruiseId",
+ n_("tutti.config.cruiseId"),
+ null,
+ String.class
),
- PROTOCOL_ID("tutti.protocolId",
- n_("tutti.config.protocolId"),
- null,
- String.class
+
+ PROTOCOL_ID(
+ "tutti.protocolId",
+ n_("tutti.config.protocolId"),
+ null,
+ String.class
),
- // UI CONFIG (should be moved to ui module)
- AUTO_POPUP_NUMBER_EDITOR("tutti.ui.autoPopupNumberEditor",
- n_("tutti.config.ui.autoPopupNumberEditor"),
- String.valueOf(false),
- Boolean.class
+ AUTO_POPUP_NUMBER_EDITOR(
+ "tutti.ui.autoPopupNumberEditor",
+ n_("tutti.config.ui.autoPopupNumberEditor"),
+ String.valueOf(false),
+ Boolean.class
),
- SHOW_NUMBER_EDITOR_BUTTON("tutti.ui.showNumberEditorButton",
- n_("tutti.config.ui.showNumberEditorButton"),
- String.valueOf(true),
- Boolean.class
- );
+ SHOW_NUMBER_EDITOR_BUTTON(
+ "tutti.ui.showNumberEditorButton",
+ n_("tutti.config.ui.showNumberEditorButton"),
+ String.valueOf(true),
+ Boolean.class
+ ),
+ COLOR_ROW_READ_ONLY(
+ "tutti.ui.color.rowReadOnly",
+ n_("tutti.config.ui.color.rowReadOnly"),
+ new Color(192, 192, 192).toString(),
+ Color.class
+ ),
+ COLOR_ROW_INVALID(
+ "tutti.ui.color.rowInvalid",
+ n_("tutti.config.ui.color.rowInvalid"),
+ new Color(255, 128, 128).toString(),
+ Color.class),
+
+ SHORTCUT_CLOSE_POPUP(
+ "tutti.ui.shortcut.closePopup",
+ n_("tutti.config.ui.shortcut.closePopup"),
+ "alt pressed F",
+ KeyStroke.class);
+
/** Configuration key. */
private final String key;
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -0,0 +1,135 @@
+package fr.ifremer.tutti.ui.swing.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
+import fr.ifremer.tutti.ui.swing.MainUI;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.config.ConfigUIHelper;
+import jaxx.runtime.swing.editor.config.model.MainCallBackFinalizer;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * To launch the config UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class TuttiConfigUI {
+
+ public static final String CALLBACK_APPLICATION = "application";
+
+ public static final String CALLBACK_UI = "ui";
+
+ public static final String CALLBACK_SHORTCUT = "shortcut";
+
+ protected final MainUI mainUI;
+
+ public TuttiConfigUI(MainUI mainUI) {
+ this.mainUI = mainUI;
+ }
+
+ public void createUI() {
+
+ TuttiConfig config = mainUI.getHandler().getContext().getConfig();
+
+ ConfigUIHelper helper = new ConfigUIHelper(config.getApplicationConfig());
+
+ helper.registerCallBack(
+ CALLBACK_UI, n_("tutti.action.reload.ui"),
+ SwingUtil.createActionIcon("reload-ui"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+ reloadUI();
+ }
+ }
+ ).registerCallBack(
+ CALLBACK_APPLICATION, n_("tutti.action.reload.application"),
+ SwingUtil.createActionIcon("reload-application"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+ reloadApplication();
+ }
+ }
+ ).registerCallBack(
+ CALLBACK_SHORTCUT, n_("tutti.action.reload.actions"),
+ SwingUtil.createActionIcon("reload-shortcut"),
+ new Runnable() {
+
+ @Override
+ public void run() {
+
+ reloadShortcuts();
+ }
+ }
+ );
+
+ // APPLICATION
+
+ helper.addCategory(n_("tutti.config.category.applications"),
+ n_("tutti.config.category.applications.description"),
+ CALLBACK_APPLICATION)
+ .addOption(TuttiServiceConfigOption.DATA_DIRECTORY)
+ .addOption(TuttiServiceConfigOption.SITE_URL)
+ .addOption(TuttiConfigOption.UI_CONFIG_FILE);
+
+ // COLOR
+ helper.addCategory(n_("tutti.config.category.colors"),
+ n_("tutti.config.category.colors.description"),
+ CALLBACK_UI)
+ .addOption(TuttiConfigOption.COLOR_ROW_INVALID)
+ .addOption(TuttiConfigOption.COLOR_ROW_READ_ONLY);
+
+ // SHORTCUT
+
+ helper.addCategory(n_("tutti.config.category.shortcuts"),
+ n_("tutti.config.category.shortcuts.description"),
+ CALLBACK_SHORTCUT)
+ .addOption(TuttiConfigOption.SHORTCUT_CLOSE_POPUP);
+
+ helper.setFinalizer(new MainCallBackFinalizer(CALLBACK_APPLICATION));
+
+ helper.buildUI(mainUI, "tutti.config.category.applications");
+
+ helper.displayUI(mainUI, false);
+ }
+
+ protected void reloadApplication() {
+ mainUI.getHandler().reloadApplication();
+ }
+
+ protected void reloadUI() {
+ mainUI.getHandler().reloadTutti();
+ }
+
+ protected void reloadShortcuts() {
+ mainUI.getHandler().reloadShortcuts();
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -65,7 +65,7 @@
}
#yearField {
- property: "year";
+ property: year;
model: {model.getYear()};
useFloat: false;
numberPattern: {INT_4_DIGITS_PATTERN};
@@ -86,7 +86,7 @@
}
#countryComboBox {
- property: "country";
+ property: country;
selectedItem: {model.getCountry()};
}
@@ -96,7 +96,7 @@
}
#surveyComboBox {
- property: "program";
+ property: program;
selectedItem: {model.getProgram()};
}
@@ -126,33 +126,29 @@
}
#pocheField {
- property: "poche";
+ property: poche;
model: {model.getPoche()};
useFloat: false;
numberPattern: {INT_1_DIGITS_PATTERN};
}
#vesselList {
- beanType: {Vessel.class};
- property: "vessel";
+ property: vessel;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.vessel"))};
}
#gearList {
- beanType: {Gear.class};
- property: "gear";
+ property: gear;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.gear"))};
}
#headOfMissionList {
- beanType: {Person.class};
property: "headOfMission";
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfMission"))};
}
#headOfSortRoomList {
- beanType: {Person.class};
- property: "headOfSortRoom";
+ property: headOfSortRoom;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfSortRoom"))};
}
@@ -166,18 +162,18 @@
}
#saveButton {
- actionIcon: "save";
+ actionIcon: save;
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
}
#cancelButton {
- actionIcon: "cancel";
+ actionIcon: cancel;
text: "tutti.action.cancel";
}
#generateNameButton {
- actionIcon: "generate";
+ actionIcon: generate;
text: "tutti.action.generateCampaignName";
enabled: {model.isCanGenerateName()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -65,10 +65,10 @@
]]></script>
<EditCruiseUIHandler id='handler'
- initializer='getContextValue(EditCruiseUIHandler.class)'/>
+ initializer='getContextValue(EditCruiseUIHandler.class)'/>
<EditCruiseUIModel id='model'
- initializer='getContextValue(EditCruiseUIModel.class)'/>
+ initializer='getContextValue(EditCruiseUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
@@ -189,7 +189,7 @@
onFocusGained='commentField.requestFocus()'>
<JTextArea id='commentField'
onKeyReleased='handler.setText(event, "comment")'/>
- </JScrollPane>
+ </JScrollPane>
</cell>
</row>
@@ -206,7 +206,7 @@
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,8 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.referential.Country;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,19 +33,20 @@
}
#programCombobox {
- property: "program";
+ property: program;
+ beanType: {Program.class};
selectedItem: {model.getProgram()};
}
#editProgramButton {
enabled: {model.isProgramFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newProgramButton {
text: "tutti.action.new";
- actionIcon: "add";
+ actionIcon: add;
}
#cruiseLabel {
@@ -54,7 +55,7 @@
}
#cruiseCombobox {
- property: "cruise";
+ property: cruise;
enabled: {model.isProgramFound()};
selectedItem: {model.getCruise()};
}
@@ -62,11 +63,11 @@
#editCruiseButton {
enabled: {model.isProgramFound() && model.isCruiseFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newCruiseButton {
- actionIcon: "add";
+ actionIcon: add;
enabled: {model.isProgramFound()};
text: "tutti.action.new";
}
@@ -77,18 +78,18 @@
}
#protocolCombobox {
- property: "protocol";
+ property: protocol;
selectedItem: {model.getProtocol()};
}
#editProtocolButton {
enabled: {model.isProtocolFound()};
text: "tutti.action.edit";
- actionIcon: "edit";
+ actionIcon: edit;
}
#newProtocolButton {
- actionIcon: "add";
+ actionIcon: add;
enabled: true;
text: "tutti.action.new";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -53,10 +53,10 @@
]]></script>
<SelectCruiseUIHandler id='handler'
- initializer='getContextValue(SelectCruiseUIHandler.class)'/>
+ initializer='getContextValue(SelectCruiseUIHandler.class)'/>
<SelectCruiseUIModel id='model'
- initializer='getContextValue(SelectCruiseUIModel.class)'/>
+ initializer='getContextValue(SelectCruiseUIModel.class)'/>
<Table fill='both' constraints='BorderLayout.CENTER'>
<row>
@@ -64,8 +64,8 @@
<JLabel id='programLabel'/>
</cell>
<cell weightx='1.0'>
- <BeanComboBox id='programCombobox' constructorParams='this'
- genericType='Program'/>
+ <BeanComboBox id='programCombobox' constructorParams='this'
+ genericType='Program'/>
</cell>
<cell>
<JPanel layout='{new GridLayout(1,0)}'>
@@ -81,8 +81,8 @@
<JLabel id='cruiseLabel'/>
</cell>
<cell>
- <BeanComboBox id='cruiseCombobox' constructorParams='this'
- genericType='Cruise'/>
+ <BeanComboBox id='cruiseCombobox' constructorParams='this'
+ genericType='Cruise'/>
</cell>
<cell>
<JPanel layout='{new GridLayout(1,0)}'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -142,6 +142,30 @@
model.getPrograms(),
model.getProgram());
+// ui.getProgramCombobox().setAutoComplete(false);
+// ui.getProgramCombobox().setEditable(true);
+//
+// JComboBox combobox = ui.getProgramCombobox().getCombobox();
+// ComboBoxSearchable comboBoxSearchable = new ComboBoxSearchable(combobox) {
+//
+// final Decorator<Program> decorator = getDecorator(Program.class, null);
+//
+// @Override
+// protected String convertElementToString(Object object) {
+// return decorator.toString(object);
+// }
+// };
+//
+// comboBoxSearchable.setRefreshPopupDuringSearching(true);
+// comboBoxSearchable.setShowPopupDuringSearching(true);
+// comboBoxSearchable.setFromStart(false);
+// comboBoxSearchable.setHideSearchPopupOnEvent(false);
+// comboBoxSearchable.setHeavyweightComponentEnabled(true);
+// comboBoxSearchable.setForeground(Color.GREEN);
+//
+// AutoCompletion i= new AutoCompletion(combobox, comboBoxSearchable);
+
+
initBeanComboBox(ui.getCruiseCombobox(),
model.getCruises(),
model.getCruise());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,23 +33,16 @@
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.sort.TableSortController;
-import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
-import java.awt.Color;
import java.awt.Component;
import java.awt.event.FocusEvent;
import java.util.Collection;
@@ -66,25 +59,11 @@
private static final Log log =
LogFactory.getLog(AbstractTuttiBatchTableUIHandler.class);
- protected abstract void saveSelectedRowIfRequired();
-
- protected abstract void saveRow(R row);
-
- protected abstract FishingOperation getFishingOperation();
-
public abstract void selectFishingOperation(FishingOperation bean);
- /**
- * Persistence service.
- *
- * @since 0.2
- */
- protected final PersistenceService persistenceService;
-
protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi,
String... properties) {
super(parentUi.getHandler().getContext(), properties);
- this.persistenceService = context.getService(PersistenceService.class);
}
public final void saveSelectedRowIfRequired(FocusEvent event) {
@@ -103,8 +82,9 @@
if (parentContainer == null) {
// out of the table can save
- if (getFishingOperation() != null) {
- saveSelectedRowIfRequired();
+ if (getModel().getFishingOperation() != null) {
+
+ saveSelectedRowIfNeeded();
}
}
}
@@ -135,7 +115,6 @@
AbstractTuttiTableModel<R> tableModel) {
installTableKeyListener(columnModel, table);
- table.getTableHeader().setReorderingAllowed(false);
JTableFilter tableFilter = new JTableFilter(table);
TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply();
@@ -161,44 +140,8 @@
TableSortController<TableModel> sorter = new TableSortController<TableModel>(tableModel);
sorter.setSortable(false);
-
table.setRowSorter(sorter);
- Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
-
- table.addHighlighter(readOnlyHighlighter);
- Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
-
- boolean result = false;
- if (adapter.isEditable()) {
- int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- R row = getTableModel().getEntry(rowIndex);
- result = !row.isValid();
- }
- return result;
- }
- }), Color.RED);
- table.addHighlighter(validHighlighter);
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- // save when row chaged and was modified
- ListSelectionListener listener = new TableRowModificationListener<R>(
- tableModel, getRowMonitor()) {
- @Override
- protected void saveSelectedRow() {
- saveSelectedRowIfRequired();
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(table);
+ initTable(table);
}
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -67,7 +67,7 @@
}
#fishingOperationNumberField {
- property: "fishingOperationNumber";
+ property: fishingOperationNumber;
model: {model.getFishingOperationNumber()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -89,7 +89,7 @@
}
#strataComboBox {
- property: "strata";
+ property: strata;
selectedItem: {model.getStrata()};
}
@@ -99,7 +99,7 @@
}
#subStrataComboBox {
- property: "subStrata";
+ property: subStrata;
selectedItem: {model.getSubStrata()};
}
@@ -109,7 +109,7 @@
}
#locationComboBox {
- property: "location";
+ property: location;
selectedItem: {model.getLocation()};
}
@@ -151,7 +151,7 @@
}
#gearShootingStartTimeField {
- property: "gearShootingStartDate";
+ property: gearShootingStartDate;
date: {model.getGearShootingStartDate()};
}
@@ -169,7 +169,7 @@
}
#gearShootingEndTimeField {
- property: "gearShootingEndDate";
+ property: gearShootingEndDate;
date: {model.getGearShootingEndDate()};
}
@@ -180,7 +180,7 @@
}
#resetValidStateButton {
- actionIcon: "reset";
+ actionIcon: reset;
text: "tutti.action.reset.fishingOperationValidState";
}
@@ -211,7 +211,7 @@
}
#distanceChaluteeField {
- property: "distanceChalutee";
+ property: distanceChalutee;
model: {model.getDistanceChalutee()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -229,8 +229,7 @@
}
#saisisseurList {
- beanType: {Person.class};
- property: "saisisseur";
+ property: saisisseur;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.saisisseur"))};
}
@@ -253,19 +252,18 @@
}
#saveButton {
- actionIcon: "save";
+ actionIcon: save;
text: "tutti.action.save";
enabled: {model.isValid()};
}
#cancelButton {
- actionIcon: "cancel";
+ actionIcon: cancel;
text: "tutti.action.cancel";
- /*enabled: {model.isModify()};*/
}
#importCasinoButton {
- actionIcon: "casino-import";
+ actionIcon: casino-import;
text: "tutti.action.casino-import";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -30,11 +30,11 @@
#newFishingOperationButton {
text: "tutti.action.new";
- actionIcon: "add";
+ actionIcon: add;
}
#fishingOperationComboBox {
- property: "selectedFishingOperation";
+ property: selectedFishingOperation;
selectedItem: {model.getSelectedFishingOperation()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -70,7 +70,8 @@
<JTabbedPane id='tabPane' constraints='BorderLayout.CENTER'>
<tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'>
- <EditFishingOperationUI id='fishingOperationTabContent' constructorParams='this'/>
+ <EditFishingOperationUI id='fishingOperationTabContent'
+ constructorParams='this'/>
</tab>
<tab id='catchesTab' title='tutti.label.tab.catches'>
<EditCatchesUI id='catchesTabContent' constructorParams='this'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -31,15 +31,17 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import java.util.List;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
import static org.nuiton.i18n.I18n._;
-import org.nuiton.util.decorator.Decorator;
/**
* Handler of UI {@link FishingOperationsUI}.
@@ -198,7 +200,7 @@
}
public void saveFishingOperation(FishingOperation toSave) {
-
+
// persist the fishingOperation
boolean create = toSave.getId() == null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,11 +26,12 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
+import java.util.List;
+
/**
* Model fo UI {@link FishingOperationsUI}.
*
@@ -40,7 +41,7 @@
public class FishingOperationsUIModel extends AbstractSerializableBean {
private static final Log log = LogFactory.getLog(FishingOperationsUIModel.class);
-
+
private static final long serialVersionUID = 1L;
public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -39,7 +39,7 @@
}
#catchTotalWeightField {
- property: "catchTotalWeight";
+ property: catchTotalWeight;
model: {model.getCatchTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -51,7 +51,7 @@
}
#catchTotalSortedTremisWeightField {
- property: "catchTotalSortedTremisWeight";
+ property: catchTotalSortedTremisWeight;
model: {model.getCatchTotalSortedTremisWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -63,7 +63,7 @@
}
#catchTotalSortedCarousselWeightField {
- property: "catchTotalSortedCarousselWeight";
+ property: catchTotalSortedCarousselWeight;
model: {model.getCatchTotalSortedCarousselWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -75,7 +75,7 @@
}
#catchTotalRejectedWeightField {
- property: "catchTotalRejectedWeight";
+ property: catchTotalRejectedWeight;
model: {model.getCatchTotalRejectedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -101,7 +101,7 @@
}
#speciesTotalWeightField {
- property: "speciesTotalWeight";
+ property: speciesTotalWeight;
model: {model.getSpeciesTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -113,7 +113,7 @@
}
#speciesTotalSortedWeightField {
- property: "speciesTotalSortedWeight";
+ property: speciesTotalSortedWeight;
model: {model.getSpeciesTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -125,7 +125,7 @@
}
#speciesTotalSampleSortedWeightField {
- property: "speciesTotalSampleSortedWeight";
+ property: speciesTotalSampleSortedWeight;
model: {model.getSpeciesTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -151,7 +151,7 @@
}
#benthosTotalWeightField {
- property: "benthosTotalWeight";
+ property: benthosTotalWeight;
model: {model.getBenthosTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -163,7 +163,7 @@
}
#benthosTotalSortedWeightField {
- property: "benthosTotalSortedWeight";
+ property: benthosTotalSortedWeight;
model: {model.getBenthosTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -175,7 +175,7 @@
}
#benthosTotalSampleSortedWeightField {
- property: "benthosTotalSampleSortedWeight";
+ property: benthosTotalSampleSortedWeight;
model: {model.getBenthosTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -201,19 +201,17 @@
}
#macroWasteTotalWeightField {
- property: "macroWasteTotalWeight";
+ property: macroWasteTotalWeight;
model: {model.getMacroWasteTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
}
#importPupitriButton {
- actionIcon: "pupitri-import";
+ actionIcon: pupitri-import;
text: "tutti.action.pupitri-import";
}
#observationIndividuelTab {
enabled: {false};
}
-
-//#catchesCaracteristicsTabScrollPane { }
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -79,6 +79,10 @@
EditCatchesUIModel.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void beforeInitUI() {
@@ -110,6 +114,10 @@
return ui.getModel();
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
public void selectFishingOperation(FishingOperation bean,
String fishingOperationText) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,169 +74,92 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected AccidentalBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected AccidentalBatchTableModel getTableModel() {
- return (AccidentalBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ AccidentalBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<AccidentalBatchRowModel> rows;
+ if (empty) {
+ rows = null;
+ } else {
- @Override
- protected void onRowModified(AccidentalBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("Get accidental batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean wasValid = row.isValid();
-
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<AccidentalBatch> catches =
+ persistenceService.getAllAccidentalBatch(bean.getId());
+ for (AccidentalBatch aBatch : catches) {
+ AccidentalBatchRowModel entry =
+ new AccidentalBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(AccidentalBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(AccidentalBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected AccidentalBatchTableModel getTableModel() {
+ return (AccidentalBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<AccidentalBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (AccidentalBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor = getRowMonitor();
-
- AccidentalBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- AccidentalBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteAccidentalBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(AccidentalBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(AccidentalBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor,
+ AccidentalBatchRowModel row) {
- AccidentalBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createAccidentalBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.saveAccidentalBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ AccidentalBatch catchBean = row.toBean();
- AccidentalBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<AccidentalBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get accidental batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deleteAccidentalBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<AccidentalBatch> catches =
- persistenceService.getAllAccidentalBatch(bean.getId());
- for (AccidentalBatch aBatch : catches) {
- AccidentalBatchRowModel entry =
- new AccidentalBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
-
}
- model.setRows(rows);
}
//------------------------------------------------------------------------//
@@ -244,6 +167,11 @@
//------------------------------------------------------------------------//
@Override
+ protected AccidentalBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -347,4 +275,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(AccidentalBatchRowModel row) {
+
+ AccidentalBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createAccidentalBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveAccidentalBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import javax.swing.table.TableColumnModel;
-import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#benthosTotalWeightField {
- property: "benthosTotalWeight";
+ property: benthosTotalWeight;
model: {model.getBenthosTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#benthosTotalSortedWeightField {
- property: "benthosTotalSortedWeight";
+ property: benthosTotalSortedWeight;
model: {model.getBenthosTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -59,7 +59,7 @@
}
#benthosTotalSampleSortedWeightField {
- property: "benthosTotalSampleSortedWeight";
+ property: benthosTotalSampleSortedWeight;
model: {model.getBenthosTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,180 +74,107 @@
BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
BenthosBatchRowModel.PROPERTY_COMMENT);
this.ui = ui;
-
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected BenthosBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected BenthosBatchTableModel getTableModel() {
- return (BenthosBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ BenthosBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<BenthosBatchRowModel> rows;
- @Override
- protected void onRowModified(BenthosBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
+ if (log.isInfoEnabled()) {
+ log.info("Get benthos batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<BenthosBatch> catches =
+ persistenceService.getAllBenthosBatch(bean.getId());
+ for (BenthosBatch aBatch : catches) {
+ BenthosBatchRowModel entry =
+ new BenthosBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected BenthosBatchTableModel getTableModel() {
+ return (BenthosBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<BenthosBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (BenthosBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor = getRowMonitor();
-
- BenthosBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- BenthosBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteBenthosBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(BenthosBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(BenthosBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor,
+ BenthosBatchRowModel row) {
- BenthosBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createBenthosBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.saveBenthosBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ BenthosBatch catchBean = row.toBean();
- BenthosBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<BenthosBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get benthos batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deleteBenthosBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<BenthosBatch> catches =
- persistenceService.getAllBenthosBatch(bean.getId());
- for (BenthosBatch aBatch : catches) {
- BenthosBatchRowModel entry =
- new BenthosBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
}
-
- model.setRows(rows);
}
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected BenthosBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -259,8 +186,6 @@
BenthosBatchUIModel model = new BenthosBatchUIModel(catchesUIModel);
ui.setContextValue(model);
-
-// fishingOperationMonitor.setBean(model);
}
@Override
@@ -375,4 +300,23 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(BenthosBatchRowModel row) {
+
+ BenthosBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createBenthosBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveBenthosBatch(catchBean);
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchRowModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -49,7 +49,7 @@
public static final String PROPERTY_WEIGHT = "weight";
- public static final String PROPERTY_NUMBER= "number";
+ public static final String PROPERTY_NUMBER = "number";
public static final String PROPERTY_COMMENT = "comment";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#macroWasteTotalWeightField {
- property: "macroWasteTotalWeight";
+ property: macroWasteTotalWeight;
model: {model.getMacroWasteTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,92 +74,80 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected MacroWasteBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected MacroWasteBatchTableModel getTableModel() {
- return (MacroWasteBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ MacroWasteBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<MacroWasteBatchRowModel> rows;
- @Override
- protected void onRowModified(MacroWasteBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
+ if (log.isInfoEnabled()) {
+ log.info("Get macroWaste batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- boolean valid = isRowValid(row);
-
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<MacroWasteBatch> catches =
+ persistenceService.getAllMacroWasteBatch(bean.getId());
+ for (MacroWasteBatch aBatch : catches) {
+ MacroWasteBatchRowModel entry =
+ new MacroWasteBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(MacroWasteBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
+ @Override
+ protected MacroWasteBatchTableModel getTableModel() {
+ return (MacroWasteBatchTableModel) getTable().getModel();
}
@Override
- protected void onRowModifyStateChanged(MacroWasteBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void onModelRowsChanged(List<MacroWasteBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (MacroWasteBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected boolean isRowValid(MacroWasteBatchRowModel row) {
+ boolean result = row.getMacroWasteCategory() != null &&
+ row.getMacroWasteSizeCategory() != null &&
+ row.getWeight() != null;
+ return result;
}
@Override
- protected void saveSelectedRowIfRequired() {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor,
+ MacroWasteBatchRowModel row) {
- TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor = getRowMonitor();
+ if (row != null) {
- MacroWasteBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
+ if (row.isValid()) {
// there is a valid bean attached to the monitor
if (rowMonitor.wasModified()) {
// monitored bean was modified, save it
if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
+ log.info("Row " + row + " was modified, will save it");
}
- saveRow(bean);
+ saveRow(row);
// clear modified flag on the monitor
rowMonitor.clearModified();
@@ -168,7 +156,7 @@
// row is not valid can not save it
- MacroWasteBatch catchBean = bean.toBean();
+ MacroWasteBatch catchBean = row.toBean();
if (!TuttiEntities.isNew(catchBean)) {
@@ -179,72 +167,16 @@
}
}
- @Override
- protected boolean isRowValid(MacroWasteBatchRowModel row) {
- boolean result = row.getMacroWasteCategory() != null &&
- row.getMacroWasteSizeCategory() != null &&
- row.getWeight() != null;
- return result;
- }
-
- @Override
- protected void saveRow(MacroWasteBatchRowModel row) {
-
- MacroWasteBatch catchBean = row.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
-
- if (TuttiEntities.isNew(catchBean)) {
-
- catchBean = persistenceService.createMacroWasteBatch(catchBean);
- row.setId(catchBean.getId());
- } else {
- persistenceService.saveMacroWasteBatch(catchBean);
- }
- }
-
- @Override
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- MacroWasteBatchUIModel model = getModel();
-
- List<MacroWasteBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get macroWaste batch for fishingOperation: " +
- bean.getId());
- }
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<MacroWasteBatch> catches =
- persistenceService.getAllMacroWasteBatch(bean.getId());
- for (MacroWasteBatch aBatch : catches) {
- MacroWasteBatchRowModel entry =
- new MacroWasteBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
- }
-
- model.setRows(rows);
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected MacroWasteBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -352,4 +284,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(MacroWasteBatchRowModel row) {
+
+ MacroWasteBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createMacroWasteBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveMacroWasteBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#planktonTotalWeightField {
- property: "planktonTotalWeight";
+ property: planktonTotalWeight;
model: {model.getPlanktonTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#planktonTotalSampleWeightField {
- property: "planktonTotalSampleWeight";
+ property: planktonTotalSampleWeight;
model: {model.getPlanktonTotalSampleWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -74,169 +74,93 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected PlanktonBatchUIModel getModel() {
- return ui.getModel();
- }
+ public void selectFishingOperation(FishingOperation bean) {
- @Override
- protected PlanktonBatchTableModel getTableModel() {
- return (PlanktonBatchTableModel) getTable().getModel();
- }
+ boolean empty = bean == null;
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
+ PlanktonBatchUIModel model = getModel();
- @Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
- }
+ List<PlanktonBatchRowModel> rows;
- @Override
- protected void onRowModified(PlanktonBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ if (empty) {
+ rows = null;
+ } else {
- boolean wasValid = row.isValid();
- boolean valid = isRowValid(row);
+ if (log.isInfoEnabled()) {
+ log.info("Get plankton batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
- if (log.isInfoEnabled()) {
- log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ if (!TuttiEntities.isNew(bean)) {
+ List<PlanktonBatch> catches =
+ persistenceService.getAllPlanktonBatch(bean.getId());
+ for (PlanktonBatch aBatch : catches) {
+ PlanktonBatchRowModel entry =
+ new PlanktonBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
}
- row.setValid(valid);
+ model.setRows(rows);
}
- @Override
- protected void onRowValidStateChanged(PlanktonBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
@Override
- protected void onRowModifyStateChanged(PlanktonBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected PlanktonBatchTableModel getTableModel() {
+ return (PlanktonBatchTableModel) getTable().getModel();
}
@Override
- protected void onModelRowsChanged(List<PlanktonBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // set valid flag
- for (PlanktonBatchRowModel row : rows) {
- boolean valid = isRowValid(row);
- row.setValid(valid);
- }
+ protected JXTable getTable() {
+ return ui.getTable();
}
@Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor = getRowMonitor();
-
- PlanktonBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- PlanktonBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deletePlanktonBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
protected boolean isRowValid(PlanktonBatchRowModel row) {
boolean result = row.getSpecies() != null && row.getWeight() != null;
return result;
}
@Override
- protected void saveRow(PlanktonBatchRowModel row) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor,
+ PlanktonBatchRowModel row) {
- PlanktonBatch catchBean = row.toBean();
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
+ if (rowMonitor.wasModified()) {
- if (TuttiEntities.isNew(catchBean)) {
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- catchBean = persistenceService.createPlanktonBatch(catchBean);
- row.setId(catchBean.getId());
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
} else {
- persistenceService.savePlanktonBatch(catchBean);
- }
- }
- @Override
- public void selectFishingOperation(FishingOperation bean) {
+ // row is not valid can not save it
- boolean empty = bean == null;
+ PlanktonBatch catchBean = row.toBean();
- PlanktonBatchUIModel model = getModel();
+ if (!TuttiEntities.isNew(catchBean)) {
- List<PlanktonBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
-
- if (log.isInfoEnabled()) {
- log.info("Get plankton batch for fishingOperation: " +
- bean.getId());
+ // remove this
+ persistenceService.deletePlanktonBatch(catchBean.getId());
}
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<PlanktonBatch> catches =
- persistenceService.getAllPlanktonBatch(bean.getId());
- for (PlanktonBatch aBatch : catches) {
- PlanktonBatchRowModel entry =
- new PlanktonBatchRowModel(aBatch);
- rows.add(entry);
- }
- }
}
-
- model.setRows(rows);
}
//------------------------------------------------------------------------//
@@ -244,6 +168,11 @@
//------------------------------------------------------------------------//
@Override
+ protected PlanktonBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -358,4 +287,22 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(PlanktonBatchRowModel row) {
+
+ PlanktonBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createPlanktonBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.savePlanktonBatch(catchBean);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,7 +35,7 @@
}
#speciesTotalWeightField {
- property: "speciesTotalWeight";
+ property: speciesTotalWeight;
model: {model.getSpeciesTotalWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -47,7 +47,7 @@
}
#speciesTotalSortedWeightField {
- property: "speciesTotalSortedWeight";
+ property: speciesTotalSortedWeight;
model: {model.getSpeciesTotalSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
@@ -59,7 +59,7 @@
}
#speciesTotalSampleSortedWeightField {
- property: "speciesTotalSampleSortedWeight";
+ property: speciesTotalSampleSortedWeight;
model: {model.getSpeciesTotalSampleSortedWeight()};
useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -113,14 +113,47 @@
}
//------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
+ //-- AbstractTuttiBatchTableUIHandler methods --//
//------------------------------------------------------------------------//
@Override
- protected SpeciesBatchUIModel getModel() {
- return ui.getModel();
+ public void selectFishingOperation(FishingOperation bean) {
+
+ boolean empty = bean == null;
+
+ SpeciesBatchUIModel model = getModel();
+
+ List<SpeciesBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " +
+ bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<SpeciesBatch> catches =
+ persistenceService.getAllSpeciesBatch(bean.getId());
+ for (SpeciesBatch aBatch : catches) {
+ List<SpeciesBatchFrequency> frequencies =
+ persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
+ SpeciesBatchRowModel entry =
+ new SpeciesBatchRowModel(aBatch, frequencies);
+ rows.add(entry);
+ }
+ }
+ }
+ model.setRows(rows);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
protected SpeciesBatchTableModel getTableModel() {
return (SpeciesBatchTableModel) getTable().getModel();
@@ -132,32 +165,79 @@
}
@Override
- protected FishingOperation getFishingOperation() {
- return getModel().getFishingOperation();
+ protected boolean isRowValid(SpeciesBatchRowModel row) {
+ boolean result = row.getSpecies() != null;
+ if (result) {
+ result = row.getWeight() != null;
+
+ if (!result) {
+
+ // No weight filled, so at least one sample category must be valid
+ result = row.getSortedUnsortedSampleCategory().isValid() ||
+ row.getSizeSampleCategory().isValid() ||
+ row.getSexSampleCategory().isValid() ||
+ row.getMaturitySampleCategory().isValid() ||
+ row.getAgeSampleCategory().isValid();
+ }
+ }
+ return result;
}
@Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
+ SpeciesBatchRowModel row) {
+
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
+
+ showInformationMessage(
+ "[ Captures - Espèces ] " +
+ "Sauvegarde des modifications de " + row + ".");
+
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ SpeciesBatch catchBean = row.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteSpeciesBatch(catchBean.getId());
+ }
+ }
+
+ }
+
+ @Override
protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
super.onModelRowsChanged(rows);
- // compute row valid
- for (SpeciesBatchRowModel row : rows) {
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
- }
// build the new sampling tree from the new rows to edit
// getModel().getSamplingTreeModel().populate(rows);
}
@Override
- protected void onRowModified(SpeciesBatchRowModel row,
+ protected void onRowModified(int rowIndex,
+ SpeciesBatchRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- if (log.isInfoEnabled()) {
- log.info("Property " + propertyName + " has changed on row.");
- }
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+
if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
// Need to recompute totalHorsVracWeight
@@ -254,163 +334,19 @@
// }
}
- @Override
- protected void onRowValidStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
-
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor();
-
- SpeciesBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
- }
-
- showInformationMessage(
- "[ Captures - Espèces ] " +
- "Sauvegarde des modifications de " + bean +
- ".");
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- SpeciesBatch catchBean = bean.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteSpeciesBatch(catchBean.getId());
- }
- }
- }
- }
-
- @Override
- protected boolean isRowValid(SpeciesBatchRowModel row) {
- boolean result = row.getSpecies() != null;
- if (result) {
- result = row.getWeight() != null;
-
- if (!result) {
-
- // No weight filled, so at least one sample category must be valid
- result = row.getSortedUnsortedSampleCategory().isValid() ||
- row.getSizeSampleCategory().isValid() ||
- row.getSexSampleCategory().isValid() ||
- row.getMaturitySampleCategory().isValid() ||
- row.getAgeSampleCategory().isValid();
- }
- }
- return result;
- }
-
- @Override
- protected void saveRow(SpeciesBatchRowModel row) {
-
- SpeciesBatch catchBean = row.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(fishingOperation);
-
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
-
- if (TuttiEntities.isNew(catchBean)) {
-
- catchBean = persistenceService.createSpeciesBatch(catchBean);
- row.setId(catchBean.getId());
- } else {
- persistenceService.saveSpeciesBatch(catchBean);
- }
-
- List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<SpeciesBatchFrequency> frequency =
- SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveSpeciesBatchFrequency(
- catchBean.getId(), frequency);
-
- // push it back to row model
- frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
- row.setFrequency(frequencyRows);
- }
-
- @Override
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- SpeciesBatchUIModel model = getModel();
-
- List<SpeciesBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get species batch for fishingOperation: " +
- bean.getId());
- }
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<SpeciesBatch> catches =
- persistenceService.getAllSpeciesBatch(bean.getId());
- for (SpeciesBatch aBatch : catches) {
- List<SpeciesBatchFrequency> frequencies =
- persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
- SpeciesBatchRowModel entry =
- new SpeciesBatchRowModel(aBatch, frequencies);
- rows.add(entry);
- }
- }
- }
- model.setRows(rows);
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
- public static final String SPECIES_FREQUENCY_LENGHTS = "SPECIES_FREQUENCY_LENGHTS";
+ public static final String SPECIES_FREQUENCY_LENGHTS =
+ "SPECIES_FREQUENCY_LENGHTS";
@Override
+ protected SpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
if (log.isInfoEnabled()) {
@@ -597,6 +533,42 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRow(SpeciesBatchRowModel row) {
+
+ SpeciesBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(fishingOperation);
+
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createSpeciesBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveSpeciesBatch(catchBean);
+ }
+
+ List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<SpeciesBatchFrequency> frequency =
+ SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveSpeciesBatchFrequency(
+ catchBean.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
+ row.setFrequency(frequencyRows);
+ }
+
// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
// SpeciesBatchTreeNode node) {
//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -39,7 +39,7 @@
}
#stepField {
- property: "step";
+ property: step;
model: {model.getStep()};
useFloat: true;
numberPattern: {DECIMAL1_PATTERN};
@@ -52,7 +52,7 @@
}
#lenghtStepCaracteristicComboBox {
- property: "lengthStepCaracteristic";
+ property: lengthStepCaracteristic;
selectedItem: {model.getLengthStepCaracteristic()};
}
@@ -62,7 +62,7 @@
}
#minStepField {
- property: "minStep";
+ property: minStep;
model: {model.getMinStep()};
useFloat: true;
showReset: true;
@@ -76,7 +76,7 @@
}
#maxStepField {
- property: "maxStep";
+ property: maxStep;
model: {model.getMaxStep()};
useFloat: true;
showReset: true;
@@ -97,7 +97,7 @@
}
#generateButton {
- actionIcon: "generate";
+ actionIcon: generate;
text: "tutti.action.generate";
enabled: {model.isCanGenerate()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -31,18 +31,16 @@
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import javax.swing.JDialog;
-import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
@@ -78,11 +76,6 @@
//------------------------------------------------------------------------//
@Override
- protected SpeciesFrequencyUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
protected SpeciesFrequencyTableModel getTableModel() {
return (SpeciesFrequencyTableModel) getTable().getModel();
}
@@ -93,10 +86,24 @@
}
@Override
- protected void onRowModified(SpeciesFrequencyRowModel row,
+ protected boolean isRowValid(SpeciesFrequencyRowModel row) {
+ //TODO
+ return row.getLengthStep() != null && row.getWeight() != null;
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesFrequencyRowModel> rowMonitor,
+ SpeciesFrequencyRowModel row) {
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ SpeciesFrequencyRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+
if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
// Need to recompute the computedWeight
@@ -104,29 +111,16 @@
}
}
- @Override
- protected void onRowValidStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected boolean isRowValid(SpeciesFrequencyRowModel row) {
- //TODO
- return true;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected SpeciesFrequencyUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel();
@@ -152,8 +146,40 @@
lengthStepCaracterics,
model.getLengthStepCaracteristic());
- JXTable table = getTable();
+ //TODO Should it come from PROTOCOL or config ?
+ model.setStep(.5f);
+
+ model.setMinStep(10f);
+ model.setMaxStep(20f);
+
+ //TODO Configure this ?
+ model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
+
+ ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ e.consume();
+ Float step = (Float) ui.getRafaleStepField().getModel();
+
+ applyRafaleStep(step);
+ }
+ }
+ });
+
+ // when lengthStepCaracteristic changed, let's updates all row with the new value
+ model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Caracteristic newValue = (Caracteristic) evt.getNewValue();
+ for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
+ rowModel.setLengthStepCaracteristic(newValue);
+ }
+ }
+ });
+
// create table column model
DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
@@ -189,54 +215,14 @@
SpeciesFrequencyTableModel tableModel =
new SpeciesFrequencyTableModel(columnModel, model);
+ JXTable table = getTable();
+
table.setModel(tableModel);
table.setColumnModel(columnModel);
installTableKeyListener(columnModel, table);
- table.getTableHeader().setReorderingAllowed(false);
-
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- //TODO Should it come from PROTOCOL or config ?
- model.setStep(.5f);
-
- model.setMinStep(10f);
- model.setMaxStep(20f);
-
- //TODO Configure this ?
- model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
-
- ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER) {
- e.consume();
- Float step = (Float) ui.getRafaleStepField().getModel();
-
- applyRafaleStep(step);
- }
- }
- });
-
- // when lengthStepCaracteristic changed, let's updates all row with the new value
- model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- Caracteristic newValue = (Caracteristic) evt.getNewValue();
- for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
- rowModel.setLengthStepCaracteristic(newValue);
- }
- }
- });
+ initTable(table);
}
@Override
@@ -326,7 +312,6 @@
frequency = row.getFrequency();
}
-
List<SpeciesFrequencyRowModel> editFrequency;
if (CollectionUtils.isEmpty(frequency)) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -38,7 +38,7 @@
}
#categoryComboBox {
- property: "selectedCategory";
+ property: selectedCategory;
selectedItem: {model.getSelectedCategory()};
}
@@ -48,7 +48,7 @@
}
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
enabled: {model.isValid()};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -58,10 +58,10 @@
]]></script>
<SplitSampleCategoryUIHandler id='handler'
- initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
+ initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
<SplitSampleCategoryUIModel id='model'
- initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
+ initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -34,19 +34,16 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
import javax.swing.JDialog;
-import javax.swing.table.DefaultTableModel;
-import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
@@ -99,11 +96,6 @@
//------------------------------------------------------------------------//
@Override
- protected SplitSampleCategoryUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
protected SplitSampleCategoryTableModel getTableModel() {
return (SplitSampleCategoryTableModel) getTable().getModel();
}
@@ -114,10 +106,26 @@
}
@Override
- protected void onRowModified(SplitSampleCategoryRowModel row,
+ protected boolean isRowValid(SplitSampleCategoryRowModel row) {
+ //TODO
+ return row.getCategoryValue() != null && row.getWeight() != null;
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
+ SplitSampleCategoryRowModel row) {
+ //TODO
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ SplitSampleCategoryRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
+
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+
if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
// Need to recompute the total weight
@@ -125,29 +133,16 @@
}
}
- @Override
- protected void onRowValidStateChanged(SplitSampleCategoryRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void onRowModifyStateChanged(SplitSampleCategoryRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected boolean isRowValid(SplitSampleCategoryRowModel row) {
- //TODO
- return true;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@Override
+ protected SplitSampleCategoryUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
public void beforeInitUI() {
SplitSampleCategoryUIModel model = new SplitSampleCategoryUIModel();
@@ -167,19 +162,6 @@
Lists.<SampleCategoryType>newArrayList(),
model.getSelectedCategory());
- JXTable table = getTable();
-
- table.getTableHeader().setReorderingAllowed(false);
-
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
-
// when category changed, remove selected category
model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
@Override
@@ -198,6 +180,10 @@
generateTableModel(newValue);
}
});
+
+ generateTableModel(null);
+
+ initTable(getTable());
}
@Override
@@ -295,21 +281,18 @@
}
}
-
protected void generateTableModel(SampleCategoryEnum category) {
- if (category == null) {
+ Caracteristic data = null;
- getTable().setModel(new DefaultTableModel());
- } else {
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+ if (category != null) {
+
Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
getDecorator(CaracteristicQualitativeValue.class, null);
- Caracteristic data = null;
-
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
switch (category) {
case sortedUnsorted:
@@ -344,30 +327,29 @@
SplitSampleCategoryTableModel.WEIGHT,
TuttiUI.DECIMAL3_PATTERN);
}
+ }
- // create table model
- SplitSampleCategoryTableModel tableModel =
- new SplitSampleCategoryTableModel(columnModel, getModel());
+ // create table model
+ SplitSampleCategoryTableModel tableModel =
+ new SplitSampleCategoryTableModel(columnModel, getModel());
- JXTable table = getTable();
+ JXTable table = getTable();
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
- //TODO Fix this!
+ //TODO Fix this!
// installTableKeyListener(columnModel, table);
- if (data != null) {
+ if (data != null) {
- // add a row for each qualitive value
- for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
- SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
- newRow.setCategoryValue(qualitativeValue);
- tableModel.addNewRow(newRow);
- }
+ // add a row for each qualitive value
+ for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
+ newRow.setCategoryValue(qualitativeValue);
+ tableModel.addNewRow(newRow);
}
}
-
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#environmentTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,14 +33,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.event.ListSelectionListener;
import java.util.Collection;
import java.util.List;
@@ -50,8 +48,14 @@
*/
public class EnvironmentTabUIHandler extends AbstractTuttiTableUIHandler<EnvironmentRowModel, EnvironmentTabUIModel> {
- private final static Log log = LogFactory.getLog(EnvironmentTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(EnvironmentTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final EnvironmentTabUI ui;
public EnvironmentTabUIHandler(EditFishingOperationUI parentUi,
@@ -61,10 +65,9 @@
this.ui = ui;
}
- @Override
- protected JXTable getTable() {
- return ui.getEnvironmentTable();
- }
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
@Override
protected EnvironmentTableModel getTableModel() {
@@ -72,28 +75,29 @@
}
@Override
- protected void onRowModified(EnvironmentRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ protected JXTable getTable() {
+ return ui.getEnvironmentTable();
}
@Override
- protected void onRowValidStateChanged(EnvironmentRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(EnvironmentRowModel row) {
+ //TODO
+ return row.getValue() != null;
}
@Override
- protected void onRowModifyStateChanged(EnvironmentRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EnvironmentRowModel> rowMonitor,
+ EnvironmentRowModel row) {
+// getModel().setCaracteristic(row.getKey(), row.getValue());
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(EnvironmentRowModel row) {
- //TODO
- return true;
+ protected EnvironmentTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -106,6 +110,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -133,35 +140,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<CaracteristicRow>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<EnvironmentRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<EnvironmentRowModel> monitor = getRowMonitor();
- EnvironmentRowModel row = monitor.getBean();
- if (row != null) {
- getModel().setCaracteristic(row.getKey(), row.getValue());
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected EnvironmentTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -171,7 +159,7 @@
EnvironmentRowModel row = getTableModel().createNewRow();
row.setKey(caracteristic);
getTableModel().addNewRow(row);
- getModel().setCaracteristic(caracteristic, null);
+// getModel().setCaracteristic(caracteristic, null);
keyCombo.removeItem(selectedItem);
selectFirstInCombo(keyCombo);
@@ -197,7 +185,7 @@
rows.add(newRow);
}
- tableModel.setRows(rows, false);
+ model.setRows(rows);
List<CaracteristicRow> caracteristicList = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
@@ -82,11 +81,4 @@
public void setAvailableCaracteristics(List<Caracteristic> caracteristics) {
availableCaracteristics = caracteristics;
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#gearShootingTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -33,14 +33,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.event.ListSelectionListener;
import java.util.Collection;
import java.util.List;
@@ -50,19 +48,26 @@
*/
public class GearShootingTabUIHandler extends AbstractTuttiTableUIHandler<GearShootingRowModel, GearShootingTabUIModel> {
- private final static Log log = LogFactory.getLog(GearShootingTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(GearShootingTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final GearShootingTabUI ui;
- public GearShootingTabUIHandler(EditFishingOperationUI parentUi, GearShootingTabUI ui) {
- super(parentUi.getHandler().getContext(), GearShootingRowModel.PROPERTY_VALUE);
+ public GearShootingTabUIHandler(EditFishingOperationUI parentUi,
+ GearShootingTabUI ui) {
+ super(parentUi.getHandler().getContext(),
+ GearShootingRowModel.PROPERTY_VALUE);
this.ui = ui;
}
- @Override
- protected JXTable getTable() {
- return ui.getGearShootingTable();
- }
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
@Override
protected GearShootingTableModel getTableModel() {
@@ -70,28 +75,31 @@
}
@Override
- protected void onRowModified(GearShootingRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
+ protected JXTable getTable() {
+ return ui.getGearShootingTable();
}
@Override
- protected void onRowValidStateChanged(GearShootingRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(GearShootingRowModel row) {
+ //TODO
+ return row.getValue() != null;
}
@Override
- protected void onRowModifyStateChanged(GearShootingRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<GearShootingRowModel> rowMonitor,
+ GearShootingRowModel row) {
+
+ //TODO Check row was modified and is valid ?
+ getModel().setCaracteristic(row.getKey(), row.getValue());
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(GearShootingRowModel row) {
- //TODO
- return true;
+ protected GearShootingTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -104,6 +112,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<CaracteristicRow>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -133,34 +144,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<CaracteristicRow>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<GearShootingRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<GearShootingRowModel> monitor = getRowMonitor();
- GearShootingRowModel row = monitor.getBean();
- if (row != null) {
- getModel().setCaracteristic(row.getKey(), row.getValue());
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected GearShootingTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -195,7 +188,7 @@
rows.add(newRow);
}
- tableModel.setRows(rows, false);
+ model.setRows(rows);
List<CaracteristicRow> caracteristicList = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -30,7 +30,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
@@ -84,10 +83,4 @@
public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) {
this.availableCaracteristics = availableCaracteristics;
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(CaracteristicRow selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
#newRowKey {
@@ -34,8 +33,8 @@
}
#addRow {
- actionIcon: "add";
- enabled: {!newRowKey.isEmpty() && newRowKey.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {newRowKey.getSelectedItem() != null};
}
#hydrologyTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -21,11 +21,12 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'>
-
+<Table
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'>
+
<import>
fr.ifremer.tutti.persistence.entities.referential.Caracteristic
-
+
fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI
jaxx.runtime.swing.editor.bean.BeanComboBox
@@ -35,13 +36,13 @@
javax.swing.ListSelectionModel
java.awt.Color
</import>
-
+
<HydrologyTabUIHandler id='handler'
initializer='getContextValue(HydrologyTabUIHandler.class)'/>
<HydrologyTabUIModel id='model'
initializer='getContextValue(HydrologyTabUIModel.class)'/>
-
+
<row fill='both'>
<cell fill='both' weightx='1'>
<BeanComboBox id='newRowKey' constructorParams='this'
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -35,15 +35,12 @@
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.tutti.ui.swing.util.table.CaracteristicRow;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.event.ListSelectionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
@@ -58,8 +55,14 @@
*/
public class HydrologyTabUIHandler extends AbstractTuttiTableUIHandler<HydrologyRowModel, HydrologyTabUIModel> {
- private final static Log log = LogFactory.getLog(HydrologyTabUIHandler.class);
+ private final static Log log =
+ LogFactory.getLog(HydrologyTabUIHandler.class);
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
protected final HydrologyTabUI ui;
protected Map<Caracteristic, Map<Type, Caracteristic>> availableCaracteristics;
@@ -74,6 +77,10 @@
this.ui = ui;
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
protected JXTable getTable() {
return ui.getHydrologyTable();
@@ -85,28 +92,44 @@
}
@Override
- protected void onRowModified(HydrologyRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
- }
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<HydrologyRowModel> rowMonitor,
+ HydrologyRowModel row) {
- @Override
- protected void onRowValidStateChanged(HydrologyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ Map<Type, Caracteristic> caracteristics =
+ availableCaracteristics.get(row.getKey());
+ CaracteristicMap map = new CaracteristicMap();
+ for (Type type : caracteristics.keySet()) {
+ Serializable value = null;
+ switch (type) {
+ case START:
+ value = row.getGearShootingStartValue();
+ break;
+ case END:
+ value = row.getGearShootingEndValue();
+ break;
+ case AVERAGE:
+ value = row.getAverageValue();
+ }
+ map.put(caracteristics.get(type), value);
+ }
+ getModel().addCaracteristics(map);
}
@Override
- protected void onRowModifyStateChanged(HydrologyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
+ protected boolean isRowValid(HydrologyRowModel row) {
+ //TODO
+ return row.getGearShootingStartValue() != null ||
+ row.getGearShootingEndValue() != null ||
+ row.getAverageValue() != null;
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(HydrologyRowModel row) {
- //TODO
- return true;
+ protected HydrologyTabUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -140,6 +163,9 @@
public void afterInitUI() {
initUI(ui);
+ initBeanComboBox(ui.getNewRowKey(),
+ Lists.<Caracteristic>newArrayList(), null);
+
JXTable table = getTable();
// create table column model
@@ -184,52 +210,16 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
-
- initBeanComboBox(ui.getNewRowKey(),
- Lists.<Caracteristic>newArrayList(), null);
-
- // modify the model when the user enters a value
- ListSelectionListener listener = new TableRowModificationListener<HydrologyRowModel>(
- tableModel, getRowMonitor()) {
-
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<HydrologyRowModel> monitor = getRowMonitor();
- HydrologyRowModel row = monitor.getBean();
- if (row != null) {
- Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(row.getKey());
- CaracteristicMap map = new CaracteristicMap();
- for (Type type : caracteristics.keySet()) {
- Serializable value = null;
- switch (type) {
- case START:
- value = row.getGearShootingStartValue();
- break;
- case END:
- value = row.getGearShootingEndValue();
- break;
- case AVERAGE:
- value = row.getAverageValue();
- }
- map.put(caracteristics.get(type), value);
- }
- getModel().addCaracteristics(map);
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
- table.getTableHeader().setReorderingAllowed(false);
-
+ initTable(table);
}
@Override
public void onCloseUI() {
}
- @Override
- protected HydrologyTabUIModel getModel() {
- return ui.getModel();
- }
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
/** Adds a row with the parameter selected in the combo box */
public void addRow() {
@@ -285,7 +275,8 @@
}
}
- tableModel.setRows(rows, false);
+ getModel().setRows(rows);
+
ui.getNewRowKey().setData(caracteristicList);
selectFirstInCombo(ui.getNewRowKey());
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -86,10 +86,4 @@
this.availableCaracteristics = availableCaracteristics;
firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics);
}
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedCaracteristic(Caracteristic selectedCaracteristic) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -41,7 +41,7 @@
#nameLabel {
text: "tutti.label.program.name";
- labelFor: {nameField};
+ labelFor: {nameField};
}
#nameField {
@@ -49,8 +49,8 @@
}
#commentPane {
- columnHeaderView: {new JLabel(_("tutti.label.comment"))};
- minimumSize: {new Dimension(10,50)};
+ columnHeaderView: {new JLabel(_("tutti.label.comment"))};
+ minimumSize: {new Dimension(10,50)};
}
#commentField {
@@ -63,19 +63,19 @@
}
#zoneComboBox {
- property: "zone";
+ property: zone;
selectedItem: {model.getZone()};
}
#saveButton {
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
- actionIcon: "save";
+ actionIcon: save;
}
#cancelButton {
text: "tutti.action.cancel";
- actionIcon: "cancel";
+ actionIcon: cancel;
}
#messagePanel {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -100,7 +100,7 @@
onFocusGained='commentField.requestFocus()'>
<JTextArea id='commentField'
onKeyReleased='handler.setText(event, "comment")'/>
- </JScrollPane>
+ </JScrollPane>
</cell>
</row>
@@ -118,7 +118,7 @@
<!-- validation messages -->
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,8 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -24,7 +24,6 @@
BeanComboBox {
i18nPrefix: "tutti.property.";
- bean: {model};
}
BeanDoubleList {
@@ -44,7 +43,7 @@
#nameLabel {
text: "tutti.label.program.name";
- labelFor: {nameField};
+ labelFor: {nameField};
}
#nameField {
@@ -52,8 +51,8 @@
}
#commentPane {
- columnHeaderView: {new JLabel(_("tutti.label.comment"))};
- minimumSize: {new Dimension(10,50)};
+ columnHeaderView: {new JLabel(_("tutti.label.comment"))};
+ minimumSize: {new Dimension(10,50)};
}
#commentField {
@@ -63,12 +62,12 @@
#saveButton {
text: "tutti.action.save";
enabled: {model.isModify() && model.isValid()};
- actionIcon: "save";
+ actionIcon: save;
}
#cancelButton {
text: "tutti.action.cancel";
- actionIcon: "cancel";
+ actionIcon: cancel;
}
#messagePanel {
@@ -88,13 +87,12 @@
#speciesComboBox {
showReset: false;
- property: selectedSpecies;
enabled: {!speciesComboBox.isEmpty()};
}
#addRow {
- actionIcon: "add";
- enabled: {!speciesComboBox.isEmpty() && speciesComboBox.getSelectedItem() != null};
+ actionIcon: add;
+ enabled: {speciesComboBox.getSelectedItem() != null};
}
#speciesTable {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -36,11 +36,11 @@
java.awt.Dimension
java.awt.Color
-
+
javax.swing.ListSelectionModel
-
+
org.jdesktop.swingx.JXTable
-
+
static org.nuiton.i18n.I18n._
static jaxx.runtime.SwingUtil.getStringValue
@@ -60,10 +60,10 @@
]]></script>
<EditProtocolUIHandler id='handler'
- initializer='getContextValue(EditProtocolUIHandler.class)'/>
+ initializer='getContextValue(EditProtocolUIHandler.class)'/>
<EditProtocolUIModel id='model'
- initializer='getContextValue(EditProtocolUIModel.class)'/>
+ initializer='getContextValue(EditProtocolUIModel.class)'/>
<SwingValidatorMessageTableModel id='errorTableModel'/>
@@ -103,7 +103,7 @@
</row>
</Table>
</tab>
-
+
<tab title='tutti.label.tab.protocol.species'>
<Table fill='both'>
<row fill='both'>
@@ -124,7 +124,7 @@
</row>
</Table>
</tab>
-
+
<tab title='tutti.label.tab.protocol.pmfm'>
<Table fill='both' weightx='1'>
<row fill='both' weighty='1'>
@@ -134,7 +134,8 @@
</row>
<row fill='both' weighty='1'>
<cell fill='both'>
- <BeanDoubleList id='environmentList' genericType='Caracteristic'/>
+ <BeanDoubleList id='environmentList'
+ genericType='Caracteristic'/>
</cell>
</row>
<row fill='both' weighty='1'>
@@ -150,11 +151,11 @@
<JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
<JButton id='saveButton' onActionPerformed='handler.save()'/>
</JPanel>
-
+
</JPanel>
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' />
+ <JTable id='errorTable'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,9 +26,7 @@
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
-import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
@@ -36,18 +34,16 @@
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -55,7 +51,6 @@
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableColumn;
@@ -84,13 +79,6 @@
*/
private final EditProtocolUI ui;
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- private final PersistenceService persistenceService;
-
protected Map<String, Species> allSpecies;
protected Map<String, Caracteristic> allLengthStepPmfm;
@@ -108,7 +96,6 @@
public EditProtocolUIHandler(TuttiUIContext context, EditProtocolUI ui) {
super(context);
this.ui = ui;
- persistenceService = context.getService(PersistenceService.class);
columToSampleCategory = HashBiMap.create(SampleCategoryEnum.values().length);
columToSampleCategory.put(EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED, SampleCategoryEnum.sortedUnsorted);
columToSampleCategory.put(EditProtocolSpeciesTableModel.SIZE_ENABLED, SampleCategoryEnum.size);
@@ -117,9 +104,13 @@
columToSampleCategory.put(EditProtocolSpeciesTableModel.AGE_ENABLED, SampleCategoryEnum.age);
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected EditProtocolUIModel getModel() {
- return ui.getModel();
+ protected EditProtocolSpeciesTableModel getTableModel() {
+ return (EditProtocolSpeciesTableModel) getTable().getModel();
}
@Override
@@ -128,46 +119,43 @@
}
@Override
- protected EditProtocolSpeciesTableModel getTableModel() {
- return (EditProtocolSpeciesTableModel) getTable().getModel();
+ protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
+ boolean result = row.getLengthStepPmfm() != null;
+ return result;
}
@Override
- protected void onRowModified(EditProtocolSpeciesRowModel row,
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
+ EditProtocolSpeciesRowModel row) {
+
+ // nothing to save when row changes, model is marked to be save
+ // when a row has changed and is valid or other protocol properties are modified
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ EditProtocolSpeciesRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- if (log.isInfoEnabled()) {
- log.info("onRowModified property: " + propertyName +
- ", newvalue: " + newValue);
- }
- boolean rowIsValid = isRowValid(row);
- row.setValid(rowIsValid);
- getModel().setModify(true);
- }
+ super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
- @Override
- protected void onRowValidStateChanged(EditProtocolSpeciesRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- if (log.isInfoEnabled()) {
- log.info("onRowValidStateChanged, newValidstate: " + newValue);
- }
- }
+ if (row.isValid()) {
- @Override
- protected void onRowModifyStateChanged(EditProtocolSpeciesRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- if (log.isInfoEnabled()) {
- log.info("onRowModifyStateChanged, newModifiedState: " + newValue);
+ // row was modified and is valid, we can save protocol
+ // even if after the row becomes again not valid, this is not a
+ // problem since we will only save valid data!
+ getModel().setModify(true);
}
}
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
@Override
- protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
- boolean result = row.getLengthStepPmfm() != null;
- return result;
+ protected EditProtocolUIModel getModel() {
+ return ui.getModel();
}
@Override
@@ -175,45 +163,22 @@
EditProtocolUIModel model = new EditProtocolUIModel();
- String protocolId = context.getProtocolId();
- if (protocolId == null) {
+ // can't load directly model fro database here, since we want to
+ // fill only the model with rows (transformed from speciesProtocol)
+ // As we still don't have the table model at this point, wait the
+ // afterUI method to fill model
- // create new protocol
-
- if (log.isDebugEnabled()) {
- log.debug("Will create a new protocol");
- }
- } else {
-
- // load existing program
- TuttiProtocol protocol =
- persistenceService.getProtocol(protocolId);
-
- model.fromBean(protocol);
- if (log.isDebugEnabled()) {
- log.debug("Will edit protocol: " + protocolId);
- }
- }
-
listModelIsModify(model);
ui.setContextValue(model);
- List<Species> species = persistenceService.getAllSpecies();
- allSpecies = Maps.newHashMap();
- for (Species s : species) {
- allSpecies.put(s.getId(), s);
- }
+ allSpecies = TuttiEntities.splitById(
+ persistenceService.getAllSpecies());
- List<Caracteristic> lengthStepCaracteristics =
- persistenceService.getAllSpeciesLengthStepCaracteristic();
- allLengthStepPmfm = Maps.newHashMap();
- for (Caracteristic c : lengthStepCaracteristics) {
- allLengthStepPmfm.put(c.getId(), c);
- }
+ allLengthStepPmfm = TuttiEntities.splitById(
+ persistenceService.getAllSpeciesLengthStepCaracteristic());
- List<Caracteristic> hydrologyPmfm = persistenceService.getAllFishingOperationHydrologicCaracteristic();
- hydroCaracteristics = HashMultimap.create();
- for (Caracteristic caracteristic : hydrologyPmfm) {
+ for (Caracteristic caracteristic :
+ persistenceService.getAllFishingOperationHydrologicCaracteristic()) {
String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
hydroCaracteristics.put(name, caracteristic.getId());
}
@@ -231,8 +196,6 @@
listenValidatorValid(ui.getValidator(), model);
- List<Species> speciesList = Lists.newArrayList(allSpecies.values());
-
// create table model
JXTable table = getTable();
@@ -278,77 +241,74 @@
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
- // fill table model
+ initTable(table);
- List<SpeciesProtocol> speciesProtocol = model.getSpecies();
- if (speciesProtocol == null) {
- speciesProtocol = Lists.newArrayList();
+ // Authorize to change column orders
+ table.getTableHeader().setReorderingAllowed(true);
+
+ List<Species> speciesList = Lists.newArrayList(allSpecies.values());
+
+ // load protocol if existing
+
+ String protocolId = context.getProtocolId();
+ if (protocolId == null) {
+
+ // create new protocol
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will create a new protocol");
+ }
+ } else {
+
+ // load existing protocol
+ TuttiProtocol protocol = persistenceService.getProtocol(protocolId);
+
+ model.fromBean(protocol);
+
+ // build speciesProtocol rows
+ List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
+
+ List<SpeciesProtocol> speciesProtocols = protocol.getSpecies();
+ if (CollectionUtils.isNotEmpty(speciesProtocols)) {
+ for (SpeciesProtocol speciesProtocol : speciesProtocols) {
+ Species species = allSpecies.get(speciesProtocol.getSpeciesId());
+ speciesList.remove(species);
+ EditProtocolSpeciesRowModel row = tableModel.createNewRow();
+ row.setSpecies(species);
+ row.setLengthStepPmfm(allLengthStepPmfm.get(speciesProtocol.getLengthStepPmfmId()));
+ row.fromBean(speciesProtocol);
+ rows.add(row);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Will edit protocol: " + protocolId + " with " +
+ rows.size() + " species declared.");
+ }
+
+ // set to model ( will propagate to tableModel)
+ model.setRows(rows);
}
- List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
- for (SpeciesProtocol protocol : speciesProtocol) {
- Species species = allSpecies.get(protocol.getSpeciesId());
- speciesList.remove(species);
- EditProtocolSpeciesRowModel row = tableModel.createNewRow();
- row.setSpecies(species);
- row.setLengthStepPmfm(allLengthStepPmfm.get(protocol.getLengthStepPmfmId()));
- row.fromBean(protocol);
- rows.add(row);
- }
- tableModel.setRows(rows, false);
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
// init species combo box
initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
selectFirstInCombo(ui.getSpeciesComboBox());
-// // Species
-// final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
-// speciesCombo.setRenderer(newListCellRender(Species.class));
-// speciesCombo.setModel(new DefaultComboBoxModel());
-// for (Species species : allSpecies.values()) {
-// speciesCombo.addItem(species);
-// }
-// speciesCombo.getModel().addListDataListener(new ListDataListener() {
-//
-// public void intervalAdded(ListDataEvent e) {
-// speciesCombo.setEnabled(true);
-// ui.getAddRow().setEnabled(true);
-// }
-//
-// public void intervalRemoved(ListDataEvent e) {
-// if (speciesCombo.getItemCount() == 0) {
-// speciesCombo.setEnabled(false);
-// ui.getAddRow().setEnabled(false);
-// }
-// }
-//
-// public void contentsChanged(ListDataEvent e) {
-// speciesCombo.setEnabled(true);
-// ui.getAddRow().setEnabled(true);
-// }
-// });
- ListSelectionListener listener = new TableRowModificationListener<EditProtocolSpeciesRowModel>(
- tableModel, getRowMonitor()) {
+ // init gear pmfm double list
+ List<Caracteristic> gearPmfm =
+ persistenceService.getAllFishingOperationGearCaracteristic();
+ initDoubleList(ui.getGearList(), gearPmfm, model.getGearPmfmId());
- @Override
- protected void saveSelectedRow() {
- TuttiBeanMonitor<EditProtocolSpeciesRowModel> monitor = getRowMonitor();
- EditProtocolSpeciesRowModel row = monitor.getBean();
- if (row != null && monitor.wasModified()) {
- getModel().setModify(true);
- }
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
+ // init environement pmfm double list
+ List<Caracteristic> environmentPmfm =
+ persistenceService.getAllFishingOperationEnvironmentCaracteristic();
+ initDoubleList(ui.getEnvironmentList(),
+ environmentPmfm,
+ model.getEnvironmentPmfmId());
- // PMFM
- List<Caracteristic> gearPmfm = persistenceService.getAllFishingOperationGearCaracteristic();
- initDoubleList(ui.getGearList(), gearPmfm, model.getGearPmfmId());
- List<Caracteristic> environmentPmfm = persistenceService.getAllFishingOperationEnvironmentCaracteristic();
- initDoubleList(ui.getEnvironmentList(), environmentPmfm, model.getEnvironmentPmfmId());
- //hydro
+ // init hydro pmfm double list
List<Caracteristic> selection = Lists.newArrayList();
Collection<String> availableCaracteristicNames = hydroCaracteristics.keySet();
List<Caracteristic> availableCaracteristics = Lists.newArrayList();
@@ -369,31 +329,20 @@
}
}
}
-
initBeanList(ui.getHydrologyList(), availableCaracteristics, selection);
// if new protocol can already cancel his creation
model.setModify(model.isCreate());
}
- protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
- List<Caracteristic> availableCaracteristics,
- List<String> selectedCaracteristics) {
- List<Caracteristic> selection = Lists.newArrayList();
- if (selectedCaracteristics != null) {
- for (Caracteristic caracteristic : availableCaracteristics) {
- if (selectedCaracteristics.contains(caracteristic.getId())) {
- selection.add(caracteristic);
- }
- }
- }
- initBeanList(widget, availableCaracteristics, selection);
- }
-
@Override
public void onCloseUI() {
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
public void cancel() {
context.setScreen(TuttiScreen.SELECT_CRUISE);
@@ -407,11 +356,12 @@
// get the species protocols from the table
List<SpeciesProtocol> protocols = Lists.newArrayList();
- List<EditProtocolSpeciesRowModel> rows =
- ((AbstractTuttiTableModel<EditProtocolSpeciesRowModel>) ui.getSpeciesTable().getModel()).getRows();
- for (EditProtocolSpeciesRowModel row : rows) {
- SpeciesProtocol protocol = row.toBean();
- protocols.add(protocol);
+
+ for (EditProtocolSpeciesRowModel row : getTableModel().getRows()) {
+ if (row.isValid()) {
+ SpeciesProtocol protocol = row.toBean();
+ protocols.add(protocol);
+ }
}
bean.setSpecies(protocols);
@@ -459,4 +409,22 @@
selectFirstInCombo(ui.getSpeciesComboBox());
// getModel().setModify(true);
}
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
+ List<Caracteristic> availableCaracteristics,
+ List<String> selectedCaracteristics) {
+ List<Caracteristic> selection = Lists.newArrayList();
+ if (selectedCaracteristics != null) {
+ for (Caracteristic caracteristic : availableCaracteristics) {
+ if (selectedCaracteristics.contains(caracteristic.getId())) {
+ selection.add(caracteristic);
+ }
+ }
+ }
+ initBeanList(widget, availableCaracteristics, selection);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -162,16 +161,16 @@
setHydrologyPmfmId(ids);
}
- public List<SpeciesProtocol> getSpecies() {
- return species;
- }
+// public List<SpeciesProtocol> getSpecies() {
+// return species;
+// }
+//
+// public void setSpecies(List<SpeciesProtocol> species) {
+// Object oldValue = getSpecies();
+// this.species = species;
+// firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+// }
- public void setSpecies(List<SpeciesProtocol> species) {
- Object oldValue = getSpecies();
- this.species = species;
- firePropertyChange(PROPERTY_SPECIES, oldValue, species);
- }
-
public List<SampleCategoryEnum> getSampleCategoryOrder() {
return sampleCategoryOrder;
}
@@ -181,11 +180,4 @@
this.sampleCategoryOrder = sampleCategoryOrder;
firePropertyChange(PROPERTY_SAMPLE_CATEGORY_ORDER, oldValue, sampleCategoryOrder);
}
-
-
- //>>>--- Warning Added only to be able to use a BeanComboBox editor! ---//
-
- public void setSelectedSpecies(Species selectedSpecies) {
- }
- //<<<--- Warning Added only to be able to use a BeanComboBox editor! ---//
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -28,8 +28,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
/**
- *
* @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
*/
public class HydrologicCaracteristicUtil {
@@ -38,14 +38,14 @@
END,
AVERAGE
}
-
+
public static String getGlobalName(String name) {
if (name.charAt(name.length() - 2) == '_') {
name = name.substring(0, name.length() - 2);
}
return name;
}
-
+
public static Caracteristic createGlobalCaracteristic(String name, Caracteristic toClone) {
Caracteristic caracteristic = new Caracteristic();
caracteristic.setName(name);
@@ -61,7 +61,7 @@
}
return caracteristic;
}
-
+
public static Type getTypeOfCaracteristic(Caracteristic caracteristic) {
String name = caracteristic.getName();
Type result = null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -37,11 +37,11 @@
}
#addButton {
- actionIcon: "add";
+ actionIcon: add;
}
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2012-12-30 19:39:00 UTC (rev 132)
@@ -22,13 +22,13 @@
#L%
-->
<Table id='mainPanel'>
-
+
<import>
fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel
fr.ifremer.tutti.persistence.entities.data.Attachment
jaxx.runtime.swing.editor.FileEditor
</import>
-
+
<!-- bean property linked state -->
<String id='property' javaBean='""'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -36,11 +36,9 @@
import javax.swing.JButton;
import javax.swing.JDialog;
-import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Cursor;
-import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -186,7 +184,7 @@
}
protected void resetFields() {
- ui.getFile().setSelectedFile((File)null);
+ ui.getFile().setSelectedFile((File) null);
ui.getFileName().setText("");
ui.getFileComment().setText("");
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,14 +29,6 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import java.awt.Color;
-import java.awt.Component;
-import java.util.List;
-import javax.swing.AbstractCellEditor;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.TableCellEditor;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
@@ -46,32 +38,43 @@
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.AbstractCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.List;
+
/**
* Editor for the values of the caracteristics of the fishing operations.
* The editor depends on the caracteristic value type.
- *
+ *
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
public class CaracteristicValueEditor extends AbstractCellEditor implements TableCellEditor {
+ private static final long serialVersionUID = 1L;
+
protected int caracteristicColumn;
-
+
protected TableCellEditor editor;
-
+
protected Decorator<CaracteristicQualitativeValue> decorator;
-
+
public CaracteristicValueEditor(TuttiUIContext context) {
this(0, context);
}
-
+
public CaracteristicValueEditor(int caracteristicColumn, TuttiUIContext context) {
super();
this.caracteristicColumn = caracteristicColumn;
DecoratorService decoratorService = context.getService(DecoratorService.class);
decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
}
-
+
@Override
public Object getCellEditorValue() {
return editor.getCellEditorValue();
@@ -80,37 +83,36 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
editor = table.getDefaultEditor(Object.class);
-
+
Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
- if (caracteristic != null) {
+ if (caracteristic != null) {
if (caracteristic.isBooleanType()) {
editor = table.getDefaultEditor(Boolean.class);
-
+
} else if (caracteristic.isNumberType()) {
NumberCellEditor<Float> editor =
- JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+ JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
editor.getNumberEditor().setSelectAllTextOnError(true);
editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
this.editor = editor;
-
+
} else if (caracteristic.isQualitativeType()) {
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(new DecoratorListCellRenderer(decorator));
-
+
List<CaracteristicQualitativeValue> data = caracteristic.getQualitativeValue();
// add a null value at first position
if (!data.isEmpty() && data.get(0) != null) {
data.add(0, null);
}
SwingUtil.fillComboBox(comboBox, data, null);
-
ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
BeanUIUtil.decorate(comboBox, converter);
editor = new ComboBoxCellEditor(comboBox);
}
}
-
+
Component result = editor.getTableCellEditorComponent(table, value, isSelected, row, column);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -29,48 +29,44 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import java.awt.Component;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
-import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+
/**
* Renderer for the values of the caracteristics of the fishing operations.
* The renderer depends on the caracteristic value type.
- *
+ *
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
public class CaracteristicValueRenderer implements TableCellRenderer {
protected int caracteristicColumn;
-
+
protected Decorator<CaracteristicQualitativeValue> decorator;
-
+
public CaracteristicValueRenderer(TuttiUIContext context) {
this(0, context);
}
-
+
public CaracteristicValueRenderer(int caracteristicColumn, TuttiUIContext context) {
super();
this.caracteristicColumn = caracteristicColumn;
DecoratorService decoratorService = context.getService(DecoratorService.class);
decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
}
-
+
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
TableCellRenderer renderer = table.getDefaultRenderer(Object.class);
Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
- if (caracteristic != null) {
+ if (caracteristic != null) {
if (caracteristic.isBooleanType()) {
renderer = table.getDefaultRenderer(Boolean.class);
-
+
} else if (caracteristic.isQualitativeType()) {
renderer = new DecoratorTableCellRenderer(decorator);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -32,7 +32,6 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import java.awt.event.FocusEvent;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import org.apache.commons.lang3.StringUtils;
@@ -50,7 +49,6 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;
-import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -158,7 +156,7 @@
ComponentMover cm = new ComponentMover();
cm.setDragInsets(cr.getDragInsets());
cm.registerComponent(editor);
-
+
editor.addWindowListener(new WindowAdapter() {
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -22,7 +22,7 @@
* #L%
*/
#closeButton {
- actionIcon: "close";
+ actionIcon: close;
text: "tutti.action.close";
mnemonic: F;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/SimpleTimeEditor.css 2012-12-30 19:39:00 UTC (rev 132)
@@ -23,23 +23,22 @@
*/
#hour {
- value:{model.getTimeModel() / 60};
- enabled:{isEnabled()};
- model:{new SpinnerNumberModel(0, 0, 23, 1)};
+ value: {model.getTimeModel() / 60};
+ enabled: {isEnabled()};
+ model: {new SpinnerNumberModel(0, 0, 23, 1)};
}
#labelH {
- text:"tutti.timeeditor.H";
- horizontalAlignment:center;
+ text: "tutti.timeeditor.H";
+ horizontalAlignment: center;
}
#minuteModel {
- calendarField:{java.util.Calendar.MINUTE};
- value:{handler.setMinuteModel(model.getDate())};
+ calendarField: {java.util.Calendar.MINUTE};
+ value: {handler.setMinuteModel(model.getDate())};
}
#minute {
- enabled:{isEnabled()};
- model:{minuteModel};
+ enabled: {isEnabled()};
+ model: {minuteModel};
}
-
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -26,32 +26,40 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.TableColumnExt;
import org.nuiton.util.decorator.Decorator;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.border.LineBorder;
+import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.Color;
+import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -76,39 +84,57 @@
LogFactory.getLog(AbstractTuttiTableUIHandler.class);
/**
- * Monitor the selected row (save it only if something has changed).
- *
+ * @return the table model handled byt the main table.
* @since 0.2
*/
- private final TuttiBeanMonitor<R> rowMonitor;
+ protected abstract AbstractTuttiTableModel<R> getTableModel();
+ /**
+ * @return the main table of the ui.
+ * @since 0.2
+ */
protected abstract JXTable getTable();
- protected abstract AbstractTuttiTableModel<R> getTableModel();
+ /**
+ * Validates the given row.
+ *
+ * @param row row to validate
+ * @return {@code true} if row is valid, {@code false} otherwise.
+ * @since 0.2
+ */
+ protected abstract boolean isRowValid(R row);
- protected abstract void onRowModified(R row,
- String propertyName,
- Object oldValue,
- Object newValue);
+ /**
+ * Given the row monitor and his monitored row, try to save it if required.
+ * <p/>
+ * Coming in this method, we are sure that row is not null.
+ *
+ * @param rowMonitor the row monitor (see {@link #rowMonitor})
+ * @param row the row to save if necessary
+ * @since 0.3
+ */
+ protected abstract void saveSelectedRowIfRequired(TuttiBeanMonitor<R> rowMonitor, R row);
- protected abstract void onRowValidStateChanged(R row,
- Boolean oldValue,
- Boolean newValue);
+ /**
+ * Monitor the selected row (save it only if something has changed).
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<R> rowMonitor;
- protected abstract void onRowModifyStateChanged(R row,
- Boolean oldValue,
- Boolean newValue);
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ protected final PersistenceService persistenceService;
- protected abstract boolean isRowValid(R row);
-
- protected String[] getRowPropertiesToIgnore() {
- return ArrayUtils.EMPTY_STRING_ARRAY;
- }
-
protected AbstractTuttiTableUIHandler(TuttiUIContext context,
String... properties) {
super(context);
+ this.persistenceService = context.getService(PersistenceService.class);
+
rowMonitor = new TuttiBeanMonitor<R>(properties);
// listen when bean is changed
@@ -127,17 +153,19 @@
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
+ int rowIndex = getTableModel().getRowIndex(row);
+
if (AbstractTuttiBeanUIModel.PROPERTY_VALID.equals(propertyName)) {
- onRowValidStateChanged(row,
+ onRowValidStateChanged(rowIndex, row,
(Boolean) oldValue,
(Boolean) newValue);
} else if (AbstractTuttiBeanUIModel.PROPERTY_MODIFY.equals(propertyName)) {
- onRowModifyStateChanged(row,
+ onRowModifyStateChanged(rowIndex, row,
(Boolean) oldValue,
(Boolean) newValue);
} else if (!propertiesToSkip.contains(propertyName)) {
- onRowModified(row,
+ onRowModified(rowIndex, row,
propertyName,
oldValue,
newValue);
@@ -163,6 +191,132 @@
});
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods (row methods) --//
+ //------------------------------------------------------------------------//
+
+ protected String[] getRowPropertiesToIgnore() {
+ return ArrayUtils.EMPTY_STRING_ARRAY;
+ }
+
+ protected void onModelRowsChanged(List<R> rows) {
+ if (CollectionUtils.isNotEmpty(rows)) {
+ for (R row : rows) {
+ boolean rowIsValid = isRowValid(row);
+ row.setValid(rowIsValid);
+ }
+ }
+ getTableModel().setRows(rows);
+ }
+
+ protected void onRowModified(int rowIndex,
+ R row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] property " +
+ propertyName + " changed from " + oldValue +
+ " to " + newValue);
+ }
+
+ // recompute row valid state
+ boolean valid = isRowValid(row);
+
+ // apply it to row
+ row.setValid(valid);
+ }
+
+ protected void onRowModifyStateChanged(int rowIndex,
+ R row,
+ Boolean oldValue,
+ Boolean newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] modify state changed from " +
+ oldValue + " to " + newValue);
+ }
+ }
+
+ protected void onRowValidStateChanged(int rowIndex,
+ R row,
+ Boolean oldValue,
+ Boolean newValue) {
+
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] valid state changed from " +
+ oldValue + " to " + newValue);
+ }
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods (init methods) --//
+ //------------------------------------------------------------------------//
+
+ protected void initTable(JXTable table) {
+
+ // by default do not authorize to change column orders
+ table.getTableHeader().setReorderingAllowed(false);
+
+ // paint in a special color read only cells
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
+ table.addHighlighter(readOnlyHighlighter);
+
+ // paint in a special color inValid rows
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ R row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), getConfig().getColorRowInvalid());
+ table.addHighlighter(validHighlighter);
+
+ // when model data change let's propagate it table model
+ getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ onModelRowsChanged((List<R>) evt.getNewValue());
+ }
+ });
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<R>(
+ getTableModel(), rowMonitor) {
+ @Override
+ protected void saveSelectedRow() {
+
+ saveSelectedRowIfNeeded();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+ }
+
+ protected final void saveSelectedRowIfNeeded() {
+
+ R row = rowMonitor.getBean();
+
+ if (row != null) {
+
+ saveSelectedRowIfRequired(rowMonitor, row);
+ }
+ }
+
protected KeyListener installTableKeyListener(TableColumnModel columnModel,
JTable table) {
@@ -262,7 +416,6 @@
addColumnToModel(model, editor, null, identifier);
}
-
protected void addBooleanColumnToModel(TableColumnModel model,
ColumnIdentifier<R> identifier,
JTable table) {
@@ -296,19 +449,6 @@
identifier);
}
- protected void listenRowsFromModel() {
- getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- onModelRowsChanged((List<R>) evt.getNewValue());
- }
- });
- }
-
- protected void onModelRowsChanged(List<R> rows) {
- getTableModel().setRows(rows);
- }
-
protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
return newTableCellRender(type, null);
@@ -330,8 +470,4 @@
return result;
}
- protected TuttiBeanMonitor<R> getRowMonitor() {
- return rowMonitor;
- }
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2012-12-30 19:39:00 UTC (rev 132)
@@ -51,8 +51,8 @@
}
protected ColumnIdentifier(String propertyName,
- String headerI18nKey,
- String headerTipI18nKey) {
+ String headerI18nKey,
+ String headerTipI18nKey) {
this.propertyName = propertyName;
this.headerI18nKey = headerI18nKey;
this.headerTipI18nKey = headerTipI18nKey;
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-30 19:35:31 UTC (rev 131)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-30 19:39:00 UTC (rev 132)
@@ -20,6 +20,7 @@
tutti.action.new=Nouveau
tutti.action.pupitri-import=Import PUPITRI
tutti.action.reload.actions=Recharger les actions
+tutti.action.reload.application=Recharger l'application
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
tutti.action.reset.fishingOperationValidState=Réinitialiser
@@ -32,6 +33,8 @@
tutti.application.name=Tutti
tutti.config.category.applications=Application
tutti.config.category.applications.description=Application
+tutti.config.category.colors=Couleurs
+tutti.config.category.colors.description=Couleurs utilisées dans les interfaces graphiques
tutti.config.category.other=Autres
tutti.config.category.other.description=Autres options
tutti.config.category.shortcuts=Raccourcis
@@ -40,7 +43,10 @@
tutti.config.programId=Identifiant de la dernière série de campagne utilisée
tutti.config.protocolId=Identifiant du dernier protocole utilisé
tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pavé numérique lors de l'édition d'un nombre
+tutti.config.ui.color.rowInvalid=Ligne invalide
+tutti.config.ui.color.rowReadOnly=Cellule non éditable
tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques
+tutti.config.ui.shortcut.closePopup=Fermer une popup
tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-application.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-reload-shortcut.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0