Author: kmorin Date: 2013-01-21 11:58:40 +0100 (Mon, 21 Jan 2013) New Revision: 237 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/237 Log: prevent from reloading the fishing operation after saving it 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/catches/EditCatchesUIHandler.java 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-20 17:41:41 UTC (rev 236) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-01-21 10:58:40 UTC (rev 237) @@ -45,12 +45,9 @@ import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI; import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler; -import fr.ifremer.tutti.ui.swing.util.CustomTab; -import fr.ifremer.tutti.ui.swing.util.TabHandler; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -340,67 +337,69 @@ boolean empty = bean == null; EditFishingOperationUIModel model = getModel(); + + if (empty || !bean.equals(model.getFishingOperation()) || fishingOperationMonitor.wasModified()) { + if (empty) { + bean = new FishingOperation(); + } - if (empty) { - bean = new FishingOperation(); - } + FishingOperationLocation strata = bean.getStrata(); + FishingOperationLocation subStrata = bean.getSubStrata(); + FishingOperationLocation location = bean.getLocation(); - FishingOperationLocation strata = bean.getStrata(); - FishingOperationLocation subStrata = bean.getSubStrata(); - FishingOperationLocation location = bean.getLocation(); + Cruise cruise = bean.getCruise(); + if (cruise != null) { + // update gear universe + ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear())); - Cruise cruise = bean.getCruise(); - if (cruise != null) { - // update gear universe - ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear())); + // update vessel universe + ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel())); + } - // update vessel universe - ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel())); - } + model.fromBean(bean); - model.fromBean(bean); + // to be sure combo list will be reloaded + model.setStrata(null); + model.setSubStrata(null); + model.setLocation(null); + model.convertGearShootingCoordinatesDDToDMS(); - // to be sure combo list will be reloaded - model.setStrata(null); - model.setSubStrata(null); - model.setLocation(null); - model.convertGearShootingCoordinatesDDToDMS(); + if (strata != null) { + ui.getStrataComboBox().setSelectedItem(strata); + } - if (strata != null) { - ui.getStrataComboBox().setSelectedItem(strata); - } + if (subStrata != null) { + ui.getSubStrataComboBox().setSelectedItem(subStrata); + } - if (subStrata != null) { - ui.getSubStrataComboBox().setSelectedItem(subStrata); - } + if (location != null) { + ui.getLocationComboBox().setSelectedItem(location); + } - if (location != null) { - ui.getLocationComboBox().setSelectedItem(location); - } + model.setFishingOperation(bean); - model.setFishingOperation(bean); + // update saisissuer selection + List<Person> saisisseur = model.getSaisisseur(); + ui.getSaisisseurList().getModel().setSelected(saisisseur); - // update saisissuer selection - List<Person> saisisseur = model.getSaisisseur(); - ui.getSaisisseurList().getModel().setSelected(saisisseur); + // update model empty property + model.setEmpty(empty); - // update model empty property - model.setEmpty(empty); + //reset gear shooting + GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent(); + gearShootingTab.getHandler().reset(bean); - //reset gear shooting - GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent(); - gearShootingTab.getHandler().reset(bean); + //reset environment + EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent(); + environmentTab.getHandler().reset(bean); - //reset environment - EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent(); - environmentTab.getHandler().reset(bean); + //reset hydrology + HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent(); + hydrologyTab.getHandler().reset(bean); - //reset hydrology - HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent(); - hydrologyTab.getHandler().reset(bean); - - model.setModify(false); - fishingOperationMonitor.clearModified(); + model.setModify(false); + fishingOperationMonitor.clearModified(); + } } public void cancel() { 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-20 17:41:41 UTC (rev 236) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-01-21 10:58:40 UTC (rev 237) @@ -27,8 +27,6 @@ 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.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler; import fr.ifremer.tutti.ui.swing.util.TabHandler; @@ -176,42 +174,44 @@ EditCatchesUIModel model = getModel(); - if (empty) { - bean = new FishingOperation(); - model.setFishingOperation(null); - } else { + if (empty || !bean.equals(model.getFishingOperation()) || fishingOperationMonitor.wasModified()) { + if (empty) { + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { - if (log.isInfoEnabled()) { - log.info("Get species batch for fishingOperation: " + - bean.getId() + " - " + fishingOperationText); + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + + bean.getId() + " - " + fishingOperationText); + } + + model.setFishingOperation(bean); } - model.setFishingOperation(bean); - } + model.fromBean(bean); - model.fromBean(bean); - - model.setModify(false); - fishingOperationMonitor.clearModified(); + model.setModify(false); + fishingOperationMonitor.clearModified(); - // 3) Propagate title to others tabs + // 3) Propagate title to others tabs - ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText); - ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText); - ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText); - ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText); - ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText); - ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText); + ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText); - // 4) Propagate new selected fishingoperation to others tabs + // 4) Propagate new selected fishingoperation to others tabs - ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean); - ui.getBenthosTabContent().getHandler().selectFishingOperation(bean); - ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean); - ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean); - ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean); + ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean); + ui.getBenthosTabContent().getHandler().selectFishingOperation(bean); + ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean); + ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean); + ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean); - ui.getTabPane().repaint(); + ui.getTabPane().repaint(); + } } protected void save() {