branch feature/7017 updated (67b1d74 -> 9959d33)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7017 in repository observe. See http://git.codelutin.com/observe.git from 67b1d74 revue des écrans de type list (refs #7017) new 9959d33 debut de revue des ecrans de type tableau (refs #7017) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 9959d33664f3b3c1a87dbbeafb8ccba2a8693ff7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat May 2 17:15:18 2015 +0200 debut de revue des ecrans de type tableau (refs #7017) Summary of changes: .../ird/observe/ui/content/ContentUIHandler.java | 8 ++++ .../ui/content/table/ContentTableUIHandler.java | 27 +++++------ .../impl/longline/BaitsCompositionUIHandler.java | 2 +- .../longline/BranchlinesCompositionUIHandler.java | 3 +- .../impl/longline/CatchLonglineUIHandler.java | 20 +++----- .../table/impl/longline/EncounterUIHandler.java | 2 +- .../longline/FloatlinesCompositionUIHandler.java | 2 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 3 +- .../impl/longline/HooksCompositionUIHandler.java | 2 +- .../table/impl/longline/SensorUsedUIHandler.java | 2 +- .../content/table/impl/longline/TdrUIHandler.java | 11 ++--- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 38 +++++++-------- .../table/impl/seine/NonTargetCatchUIHandler.java | 55 +++------------------- .../table/impl/seine/NonTargetSampleUIHandler.java | 46 +++++++----------- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 7 ++- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 12 ++--- .../table/impl/seine/SchoolEstimateUIHandler.java | 15 ++---- .../table/impl/seine/TargetCatchUIHandler.java | 6 +-- .../impl/seine/TargetDiscardCatchUIHandler.java | 19 ++++---- .../table/impl/seine/TargetSampleUIHandler.java | 45 ++++++------------ 20 files changed, 123 insertions(+), 202 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7017 in repository observe. See http://git.codelutin.com/observe.git commit 9959d33664f3b3c1a87dbbeafb8ccba2a8693ff7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat May 2 17:15:18 2015 +0200 debut de revue des ecrans de type tableau (refs #7017) --- .../ird/observe/ui/content/ContentUIHandler.java | 8 ++++ .../ui/content/table/ContentTableUIHandler.java | 27 +++++------ .../impl/longline/BaitsCompositionUIHandler.java | 2 +- .../longline/BranchlinesCompositionUIHandler.java | 3 +- .../impl/longline/CatchLonglineUIHandler.java | 20 +++----- .../table/impl/longline/EncounterUIHandler.java | 2 +- .../longline/FloatlinesCompositionUIHandler.java | 2 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 3 +- .../impl/longline/HooksCompositionUIHandler.java | 2 +- .../table/impl/longline/SensorUsedUIHandler.java | 2 +- .../content/table/impl/longline/TdrUIHandler.java | 11 ++--- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 38 +++++++-------- .../table/impl/seine/NonTargetCatchUIHandler.java | 55 +++------------------- .../table/impl/seine/NonTargetSampleUIHandler.java | 46 +++++++----------- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 7 ++- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 12 ++--- .../table/impl/seine/SchoolEstimateUIHandler.java | 15 ++---- .../table/impl/seine/TargetCatchUIHandler.java | 6 +-- .../impl/seine/TargetDiscardCatchUIHandler.java | 19 ++++---- .../table/impl/seine/TargetSampleUIHandler.java | 45 ++++++------------ 20 files changed, 123 insertions(+), 202 deletions(-) diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index 1ef2472..97a049e 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -66,6 +66,7 @@ import javax.swing.UIManager; import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; import java.awt.Component; +import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; @@ -767,6 +768,13 @@ public abstract class ContentUIHandler<E extends TopiaEntity> { editor.setQuadrant(quadrant); } + protected void reloadPropertyChangeListener(TopiaEntity bean, String propertyName, PropertyChangeListener listener) { + + bean.removePropertyChangeListener(propertyName, listener); + bean.addPropertyChangeListener(propertyName, listener); + + } + protected void reloadTableModelListener(TableModel tableModel, TableModelListener listener) { tableModel.removeTableModelListener(listener); tableModel.addTableModelListener(listener); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index 1242dfc..f72ccdf 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -87,11 +87,11 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top /** * Pour charger le bean d'édition dans la méthode {@link #openUI()}. * - * Cette méthode est appelée à chaque affichage de l'écran. + * Cette méthode est appelée à chaque ouverture de l'écran. * * @param mode le mode de l'écran */ - protected abstract void loadEditBean(ContentMode mode); + protected abstract void onOpenUI(ContentMode mode); /** * Pour enregistre l'objet en cours d'édition. @@ -119,6 +119,7 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top // mode mise a jour return ContentMode.UPDATE; + } // mode lecture @@ -134,6 +135,7 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top } return ContentMode.READ; + } @Override @@ -154,11 +156,16 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top return getModel().getTableEditBean(); } + protected ContentTableUIInitializer createInitializer() { + ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>> uiInitializer = + new ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>>(getUi()); + return uiInitializer; + } + @Override public void initUI() throws Exception { - ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>> uiInitializer = - new ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>>(getUi()); + ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>> uiInitializer = createInitializer(); uiInitializer.initUI(ObserveContext.get().getServices()); } @@ -179,11 +186,8 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top // récupération du mode de l'écran ContentMode mode = computeContentMode(); - // chargement du bean d'édition - loadEditBean(mode); - // chargement de l'écran d'édition - loadTableEditBeanForm(mode); + onOpenUI(mode); // enregistrement du mode de l'écran getModel().setMode(mode); @@ -191,7 +195,7 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top // initialisation du modèle du tableau tableModel.attachModel(); - boolean canEdit = mode == ContentMode.UPDATE; + boolean canEdit = ContentMode.UPDATE == mode; if (canEdit) { // on lance le mode edition @@ -225,11 +229,6 @@ public abstract class ContentTableUIHandler<E extends TopiaEntity, D extends Top } - protected void loadTableEditBeanForm(ContentMode mode) { - // par defaut, rien à faire - } - - @Override public void startEditUI(String... binding) { diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java index af75db0..f25ad5d 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java @@ -63,7 +63,7 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java index 001bb49..8911e36 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java @@ -107,7 +107,7 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); @@ -127,7 +127,6 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo } - @Override public void afterSave(boolean refresh) { super.afterSave(refresh); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java index 710b8ad..030c1fe 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java @@ -148,7 +148,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLongline, C } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); @@ -374,14 +374,9 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLongline, C } - bean.removePropertyChangeListener(CatchLongline.PROPERTY_CATCH_FATE_LONGLINE, catchFateChanged); - bean.addPropertyChangeListener(CatchLongline.PROPERTY_CATCH_FATE_LONGLINE, catchFateChanged); - - bean.removePropertyChangeListener(CatchLongline.PROPERTY_BRANCHLINE, branchlineChanged); - bean.addPropertyChangeListener(CatchLongline.PROPERTY_BRANCHLINE, branchlineChanged); - - bean.removePropertyChangeListener(CatchLongline.PROPERTY_DEPREDATED, depredatedChanged); - bean.addPropertyChangeListener(CatchLongline.PROPERTY_DEPREDATED, depredatedChanged); + reloadPropertyChangeListener(bean, CatchLongline.PROPERTY_CATCH_FATE_LONGLINE, catchFateChanged); + reloadPropertyChangeListener(bean, CatchLongline.PROPERTY_BRANCHLINE, branchlineChanged); + reloadPropertyChangeListener(bean, CatchLongline.PROPERTY_DEPREDATED, depredatedChanged); LonglinePositionHelper<CatchLongline> positionHelper = POSITION_HELPER_ENTRY.getContextValue(ui); positionHelper.resetPosition(bean); @@ -560,12 +555,11 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLongline, C LonglinePositionHelper<CatchLongline> positionHelper = POSITION_HELPER_ENTRY.getContextValue(getUi()); getUi().getSection().setData(positionHelper.getSectionUniverse()); - // To be sure always remove listener (could prevent some leaks) - getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); + // listen messages to see if required to add - getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener); + reloadTableModelListener(errorTableModel, computeTabValidStateListener); - SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); computeTabValidState(errorTableModel); } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java index a00e5c0..7d335cb 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java @@ -62,7 +62,7 @@ public class EncounterUIHandler extends ContentTableUIHandler<ActivityLongline, } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String activityLonglineId = getDataContext().getSelectedActivityId(); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java index 89bd006..48926bd 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java @@ -62,7 +62,7 @@ public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLon } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java index 98b64bf..89cde36 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java @@ -116,7 +116,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String activityLonglineId = getDataContext().getSelectedTripLonglineId(); @@ -154,7 +154,6 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip } - GearUseFeaturesLonglineService service = getService(GearUseFeaturesLonglineService.class); service.save(editBean); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java index 765f2c5..ca49581 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java @@ -63,7 +63,7 @@ public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLongline } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java index cbdf74d..dd46581 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java @@ -80,7 +80,7 @@ public class SensorUsedUIHandler extends ContentTableUIHandler<ActivityLongline, } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String activityLonglineId = getDataContext().getSelectedActivityId(); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java index 973161c..ac05514 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java @@ -29,7 +29,6 @@ import fr.ird.observe.BinderService; import fr.ird.observe.ObserveConfig; import fr.ird.observe.ObserveContext; import fr.ird.observe.ObserveTechnicalException; -import fr.ird.observe.db.DataSourceException; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.entities.longline.Section; import fr.ird.observe.entities.longline.SetLongline; @@ -122,7 +121,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLongline, Tdr> { } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setLonglineId = getDataContext().getSelectedSetId(); @@ -132,7 +131,6 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLongline, Tdr> { copy(SetLongline.class, BinderService.EDIT_TDR, loaded, getBean()); - //FIXME Move this somewhere else ? // load sections (and baskets and branchlines) SetLonglineService setLonglineService = getService(SetLonglineService.class); List<Section> sections = setLonglineService.getSections(setLonglineId); @@ -264,12 +262,11 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLongline, Tdr> { LonglinePositionHelper<Tdr> positionHelper = POSITION_HELPER_ENTRY.getContextValue(getUi()); getUi().getSection().setData(positionHelper.getSectionUniverse()); - // To be sure always remove listener (could prevent some leaks) - getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); + // listen messages to see if required to add - getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener); + reloadTableModelListener(errorTableModel, computeTabValidStateListener); - SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); computeTabValidState(errorTableModel); } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java index c030953..ad6c5b1 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java @@ -285,35 +285,34 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei } @Override - protected void loadEditBean(ContentMode mode) { + public void openUI() throws Exception { - String tripSeineId = getDataContext().getSelectedTripSeineId(); + if (log.isInfoEnabled()) { + log.info("OpenUI: " + getModel()); + } - TripSeine tripSeine = getService(GearUseFeaturesSeineService.class).loadForEdit(tripSeineId); + super.openUI(); - copy(TripSeine.class, BinderService.EDIT_GEAR_USE_FEATURES_SEINE, tripSeine, getBean()); + SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); - // reset measurements - getModel().getMeasurementsTableModel().clear(); + // listen messages to see to compute tab valid states + reloadTableModelListener(errorTableModel, computeTabValidStateListener); + + computeTabValidState(errorTableModel); } @Override - public void openUI() throws Exception { + protected void onOpenUI(ContentMode mode) { - if (log.isInfoEnabled()) { - log.info("OpenUI: " + getModel()); - } + String tripSeineId = getDataContext().getSelectedTripSeineId(); - super.openUI(); + TripSeine tripSeine = getService(GearUseFeaturesSeineService.class).loadForEdit(tripSeineId); - // To be sure always remove listener (could prevent some leaks) - getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); - // listen messages to see if required to add - getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener); + copy(TripSeine.class, BinderService.EDIT_GEAR_USE_FEATURES_SEINE, tripSeine, getBean()); - SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); - computeTabValidState(errorTableModel); + // reset measurements + getModel().getMeasurementsTableModel().clear(); } @@ -393,12 +392,13 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei List<GearUseFeaturesMeasurementSeine> measurements = measurementsTableModel.getCacheForRowNotEmpty(row); gearUseFeaturesSeine.clearGearUseFeaturesMeasurement(); - gearUseFeaturesSeine.addAllGearUseFeaturesMeasurement(measurements); } - getService(GearUseFeaturesSeineService.class).save(editBean); + GearUseFeaturesSeineService service = getService(GearUseFeaturesSeineService.class); + service.save(editBean); + } @Override diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java index 8e59f98..482db1f 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java @@ -193,11 +193,11 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Non } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { List<Species> speciesList; - if (mode == ContentMode.UPDATE) { + if (ContentMode.UPDATE == mode) { // get current ocean Ocean ocean = getService(TripService.class).getTripOcean(getDataContext().getSelectedTripId()); @@ -233,42 +233,6 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Non } @Override - protected void loadTableEditBeanForm(ContentMode mode) { - - List<Species> speciesList; - - String tripId = getDataContext().getSelectedTripId(); - - if (mode == ContentMode.UPDATE) { - - // get current ocean - Ocean ocean = getService(TripService.class).getTripOcean(tripId); - - ObserveConfig config = getUi().getContextValue(ObserveConfig.class); - String speciesListId = config.getSpeciesListSeineNonTargetCatchId(); - - // get all species - List<Species> allSpecies = getService(ReferentialService.class).loadDecoratedSpecies(speciesListId); - - // filtre par status actif - ReferenceEntities.filterReferentielListByStatus(allSpecies); - - // filtre par ocean - speciesList = Species2.filterByOcean(allSpecies, ocean); - - } else { - - speciesList = new ArrayList<Species>(); - } - - ALL_ESPECES_ENTRY.setContextValue(getUi(), speciesList); - if (log.isDebugEnabled()) { - log.debug("speciesList = " + speciesList.size()); - } - - } - - @Override protected void onSelectedRowChanged(int editingRow, NonTargetCatch bean, boolean create) { NonTargetCatchUI ui = getUi(); @@ -301,17 +265,10 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Non requestFocus.requestFocus(); NonTargetCatch tableEditBean = getTableEditBean(); - tableEditBean.removePropertyChangeListener(NonTargetCatch.PROPERTY_TOTAL_COUNT, totalCountChanged); - tableEditBean.addPropertyChangeListener(NonTargetCatch.PROPERTY_TOTAL_COUNT, totalCountChanged); - - tableEditBean.removePropertyChangeListener(NonTargetCatch.PROPERTY_CATCH_WEIGHT, catchWeightChanged); - tableEditBean.addPropertyChangeListener(NonTargetCatch.PROPERTY_CATCH_WEIGHT, catchWeightChanged); - - tableEditBean.removePropertyChangeListener(NonTargetCatch.PROPERTY_MEAN_WEIGHT, meanWeightChanged); - tableEditBean.addPropertyChangeListener(NonTargetCatch.PROPERTY_MEAN_WEIGHT, meanWeightChanged); - - tableEditBean.removePropertyChangeListener(NonTargetCatch.PROPERTY_MEAN_LENGTH, meanLengthChanged); - tableEditBean.addPropertyChangeListener(NonTargetCatch.PROPERTY_MEAN_LENGTH, meanLengthChanged); + reloadPropertyChangeListener(tableEditBean, NonTargetCatch.PROPERTY_TOTAL_COUNT, totalCountChanged); + reloadPropertyChangeListener(tableEditBean, NonTargetCatch.PROPERTY_CATCH_WEIGHT, catchWeightChanged); + reloadPropertyChangeListener(tableEditBean, NonTargetCatch.PROPERTY_MEAN_WEIGHT, meanWeightChanged); + reloadPropertyChangeListener(tableEditBean, NonTargetCatch.PROPERTY_MEAN_LENGTH, meanLengthChanged); } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java index 88bc806..58f949c 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java @@ -62,7 +62,7 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam /** Logger */ static private Log log = LogFactory.getLog(NonTargetSampleUIHandler.class); - protected final JAXXContextEntryDef<List<Species>> ALL_ESPECES_ENTRY = + protected final JAXXContextEntryDef<List<Species>> ALL_SPECIES_ENTRY = UIHelper.newListContextEntryDef("NonTargetSampleUI-all-speciess"); /** @@ -136,18 +136,8 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam } - public void resetWeightSource() { - getTableEditBean().setWeightSource(false); - getUi().getWeight().grabFocus(); - } - - public void resetLengthSource() { - getTableEditBean().setLengthSource(false); - getUi().getLength().grabFocus(); - } - @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setId = getDataContext().getSelectedSetId(); @@ -155,29 +145,16 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam copy(NonTargetSample.class, BinderService.EDIT_NON_TARGET_LENGTH, nonTargetSample, getBean()); - } - - @Override - protected void loadTableEditBeanForm(ContentMode mode) { - List<Species> speciesList; - if (mode == ContentMode.UPDATE) { - - String setId = getDataContext().getSelectedSetId(); + if (ContentMode.UPDATE == mode) { NonTargetSampleService service = getService(NonTargetSampleService.class); speciesList = service.getAvailableSpeciesForNonTargetSample(setId); - ALL_ESPECES_ENTRY.setContextValue(getUi(), speciesList); + ALL_SPECIES_ENTRY.setContextValue(getUi(), speciesList); } - getModel().setMode(mode); - - - // initialisation du modèle du tableau - getUi().getTableModel().attachModel(); - } @Override @@ -194,12 +171,13 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam log.info("Remove obsolete nonTargetSample " + editBean.getTopiaId() + " from Set: " + setId); } + //FIXME Non, la sauvegarde doit être faite par un seul appel au service (sinon fait dans 2 transactions) service.delete(setId, editBean); } else { + //FIXME Non, la sauvegarde doit être faite par un seul appel au service (sinon fait dans 2 transactions) String savedId = service.save(setId, editBean); - editBean.setTopiaId(savedId); getService(NonTargetLengthService.class).save(editBean); @@ -207,6 +185,16 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam } } + public void resetWeightSource() { + getTableEditBean().setWeightSource(false); + getUi().getWeight().grabFocus(); + } + + public void resetLengthSource() { + getTableEditBean().setLengthSource(false); + getUi().getLength().grabFocus(); + } + @Override protected void onSelectedRowChanged(int editingRow, NonTargetLength bean, boolean create) { @@ -233,7 +221,7 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam ui.getAcquisitionModeGroup().setSelectedValue(ModeSaisieEchantillonEnum.byEffectif); } - availableEspeces = new ArrayList<Species>(ALL_ESPECES_ENTRY.getContextValue(ui)); + availableEspeces = new ArrayList<Species>(ALL_SPECIES_ENTRY.getContextValue(ui)); requestFocus = ui.getSpecies(); } else { diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java index 1db6bda..b1369e3 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java @@ -59,7 +59,7 @@ public class ObjectObservedSpeciesUIHandler extends ContentTableUIHandler<Floati } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String floatingObjectId = getDataContext().getSelectedFloatingObjectId(); @@ -112,7 +112,10 @@ public class ObjectObservedSpeciesUIHandler extends ContentTableUIHandler<Floati @Override protected void doPersist(FloatingObject editBean) { - getService(ObjectObservedSpeciesService.class).save(editBean); + + ObjectObservedSpeciesService service = getService(ObjectObservedSpeciesService.class); + service.save(editBean); + } } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java index 2245c1e..8c6b3b8 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java @@ -59,7 +59,7 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String floatingObjectId = getDataContext().getSelectedFloatingObjectId(); @@ -81,11 +81,6 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin } } -// @Override -// protected String getEditBeanIdToLoad(DataContext dataContext, DataService dataService, DataSource dataSource) { -// return dataContext.getSelectedFloatingObjectId(); -// } - @Override protected void initTableUI(DefaultTableCellRenderer renderer) { JTable table = getUi().getTable(); @@ -114,7 +109,10 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin @Override protected void doPersist(FloatingObject editBean) { - getService(ObjectSchoolEstimateService.class).save(editBean); + + ObjectSchoolEstimateService service = getService(ObjectSchoolEstimateService.class); + service.save(editBean); + } } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java index ec3d09b..663544d 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java @@ -59,7 +59,7 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeine, Sch /** Logger */ static private Log log = LogFactory.getLog(SchoolEstimateUIHandler.class); - JAXXContextEntryDef<List<Species>> ALL_ESPECES_ENTRY = + JAXXContextEntryDef<List<Species>> ALL_SPECIES_ENTRY = UIHelper.newListContextEntryDef("SchoolEstimateUI-all-speciess"); public SchoolEstimateUIHandler(SchoolEstimateUI ui) { @@ -72,7 +72,7 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeine, Sch } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setSeineId = getDataContext().getSelectedSetId(); @@ -82,14 +82,9 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeine, Sch copy(SetSeine.class, BinderService.EDIT_SCHOOL_ESTIMATE, loaded, getBean()); - } - - @Override - protected void loadTableEditBeanForm(ContentMode mode) { - List<Species> speciesList; - if (mode == ContentMode.UPDATE) { + if (ContentMode.UPDATE == mode) { // get current ocean Ocean ocean = getService(TripService.class).getTripOcean(getDataContext().getSelectedTripId()); @@ -111,7 +106,7 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeine, Sch speciesList = new ArrayList<Species>(); } - ALL_ESPECES_ENTRY.setContextValue(getUi(), speciesList); + ALL_SPECIES_ENTRY.setContextValue(getUi(), speciesList); if (log.isDebugEnabled()) { log.debug("speciesList = " + speciesList.size()); } @@ -135,7 +130,7 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeine, Sch if (create) { availableEspeces = new ArrayList<Species>( - ALL_ESPECES_ENTRY.getContextValue(ui)); + ALL_SPECIES_ENTRY.getContextValue(ui)); List<Species> list = model.getColumnValues(0); availableEspeces.removeAll(list); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index 3967c6a..39a8e98 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -117,7 +117,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Target // en mode creation , on doit recalculer la liste des categories Species species = (Species) evt.getNewValue(); - onEspeceChanged(species); + onSpeciesChanged(species); } } @@ -156,7 +156,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Target } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { List<Species> speciesList; List<WeightCategory> categorieList; @@ -354,7 +354,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeine, Target } @SuppressWarnings("unchecked") - protected void onEspeceChanged(Species species) { + protected void onSpeciesChanged(Species species) { List<WeightCategory> availableCategories; diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index b640cda..739fcc5 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -125,7 +125,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, // en mode creation , on doit recalculer la liste des categories Species species = (Species) evt.getNewValue(); - onEspeceChanged(bean, species); + onSpeciesChanged(bean, species); } } @@ -150,7 +150,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, // en mode creation , on doit recalculer la liste des raison rejet WeightCategory weightCategory = (WeightCategory) evt.getNewValue(); - onCategorieChanged(bean, weightCategory); + onWeightCategoryChanged(bean, weightCategory); } @@ -193,7 +193,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, } @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { List<WeightCategory> categorieList; List<ReasonForDiscard> reasonForDiscardList; @@ -373,7 +373,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, } // on recalcule la liste des speciess disponibles - List<Species> availableEspeces = buildEspeceList(beanEspece, beanWeightCategory); + List<Species> availableEspeces = buildSpeciesList(beanEspece, beanWeightCategory); speciesComboBox.setData(availableEspeces); // on reinitilise toujours la liste des espèces (pour reinitialiser la liste des categories) @@ -409,7 +409,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, requestFocus.requestFocus(); } - protected void onEspeceChanged(TargetCatch bean, Species species) { + protected void onSpeciesChanged(TargetCatch bean, Species species) { WeightCategory weightCategory = null; @@ -447,7 +447,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, } - protected void onCategorieChanged(TargetCatch bean, WeightCategory weightCategory) { + protected void onWeightCategoryChanged(TargetCatch bean, WeightCategory weightCategory) { TargetDiscardCatchUI ui = getUi(); @@ -465,7 +465,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, // un categorie est selectionne, on met a jour la liste des raisons // rejet disponible pour cette categorie - List<ReasonForDiscard> reasonForDiscardList = buildReasonFordiscardList( + List<ReasonForDiscard> reasonForDiscardList = buildReasonForDiscardList( weightCategory); if (log.isDebugEnabled()) { @@ -493,7 +493,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, } - protected List<Species> buildEspeceList(Species species, WeightCategory weightCategory) { + protected List<Species> buildSpeciesList(Species species, WeightCategory weightCategory) { List<WeightCategory> weightCategoryList = getAllCategories(getUi()); @@ -537,7 +537,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, } - protected List<ReasonForDiscard> buildReasonFordiscardList(WeightCategory weightCategory) { + protected List<ReasonForDiscard> buildReasonForDiscardList(WeightCategory weightCategory) { ContentTableModel<SetSeine, TargetCatch> model = getTableModel(); List<ReasonForDiscard> reasonForDiscardList = @@ -604,4 +604,5 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeine, return set; } + } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java index 5a90ee1..0cfa053 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java @@ -24,6 +24,7 @@ package fr.ird.observe.ui.content.table.impl.seine; import fr.ird.observe.BinderService; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.constants.DataContextType; +import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.referentiel.Species; import fr.ird.observe.entities.seine.SetSeine; import fr.ird.observe.entities.seine.TargetLength; @@ -117,20 +118,8 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSample, T getUi().getLength().grabFocus(); } -// @Override -// protected String getEditBeanIdToLoad(DataContext dataContext, -// DataService dataService, -// DataSource dataSource) throws DataSourceException { -// String setId = dataContext.getSelectedSetId(); -// // on doit récupérer l'unique échantillonThon de la calée -// -// TargetSample targetSample = getService(TargetSampleService.class).getTargetSample(setId, discarded); -// String id = targetSample == null ? null : targetSample.getTopiaId(); -// return id; -// } - @Override - protected void loadEditBean(ContentMode mode) { + protected void onOpenUI(ContentMode mode) { String setId = getDataContext().getSelectedSetId(); @@ -138,19 +127,13 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSample, T copy(TargetSample.class, BinderService.EDIT_TARGET_LENGTH, targetSample, getBean()); - } - - @Override - protected void loadTableEditBeanForm(ContentMode mode) { - - if (mode == ContentMode.UPDATE) { - - String setId = getDataContext().getSelectedSetId(); + if (ContentMode.UPDATE == mode) { // on ne charge les speciess uniquement si on est en mode édition List<Species> speciesList = getService(TargetSampleService.class).getAvailableSpeciesForTargetSample(setId, discarded); getUi().getSpecies().setData(speciesList); + } getModel().setMode(mode); @@ -166,23 +149,25 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSample, T String setId = getDataContext().getSelectedSetId(); - if (editBean.getTopiaId() != null && editBean.isTargetLengthEmpty()) { + TargetSampleService service = getService(TargetSampleService.class); + + if (!Entities.isNew(editBean) && editBean.isTargetLengthEmpty()) { // remove orphan target sample if (log.isInfoEnabled()) { log.info("Remove obsolete targetSample " + editBean.getTopiaId() + " from Set: " + setId); } - - getService(TargetSampleService.class).delete(setId, editBean); + //FIXME Non, la sauvegarde doit être faite par un seul appel au service (sinon fait dans 2 transactions) + service.delete(setId, editBean); } else { - String savedId = getService(TargetSampleService.class).save(setId, editBean); - + String savedId = service.save(setId, editBean); editBean.setTopiaId(savedId); - + //FIXME Non, la sauvegarde doit être faite par un seul appel au service (sinon fait dans 2 transactions) getService(TargetLengthService.class).save(editBean); + } } @@ -245,11 +230,9 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSample, T requestFocus.requestFocus(); TargetLength tableEditBean = getTableEditBean(); - tableEditBean.removePropertyChangeListener(TargetLength.PROPERTY_WEIGHT, weightChanged); - tableEditBean.addPropertyChangeListener(TargetLength.PROPERTY_WEIGHT, weightChanged); + reloadPropertyChangeListener(tableEditBean, TargetLength.PROPERTY_WEIGHT, weightChanged); + reloadPropertyChangeListener(tableEditBean, TargetLength.PROPERTY_LENGTH, lengthChanged); - tableEditBean.removePropertyChangeListener(TargetLength.PROPERTY_LENGTH, lengthChanged); - tableEditBean.addPropertyChangeListener(TargetLength.PROPERTY_LENGTH, lengthChanged); } @Override -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm