r2141 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input
Author: sletellier Date: 2009-04-23 15:47:53 +0000 (Thu, 23 Apr 2009) New Revision: 2141 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx Log: Bug StrategiesOneMonth factor resolved Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2009-04-23 15:34:25 UTC (rev 2140) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2009-04-23 15:47:53 UTC (rev 2141) @@ -100,15 +100,25 @@ } } -protected void accept(ActionEvent e) { - JComponent source = (JComponent) e.getSource(); - Class classBean = (Class)source.getClientProperty("bean"); - TopiaEntity bean = getVerifier().getEntity(classBean); - if (bean != null) { - FactorWizard wizard = new FactorWizard(this); - wizard.initNew(source, bean, EditorHelper.canBeContinue(source, bean)); - wizard.pack(); - wizard.setVisible(true); + protected void accept(ActionEvent e) { + JComponent source = (JComponent) e.getSource(); + Class classBean = (Class)source.getClientProperty("bean"); + String beanID = (String)source.getClientProperty("beanID"); + TopiaEntity bean = null; + if(beanID == null){ + bean = getVerifier().getEntity(classBean); + } + else{ + System.out.println(beanID); + bean = getVerifier().getEntity(classBean, beanID); + } + if (bean != null){ + FactorWizard wizard = new FactorWizard(this); + + wizard.initNew(source, bean, EditorHelper.canBeContinue(source, bean)); + wizard.pack(); + wizard.setVisible(true); + } } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java 2009-04-23 15:34:25 UTC (rev 2140) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java 2009-04-23 15:47:53 UTC (rev 2141) @@ -27,6 +27,8 @@ import java.beans.PropertyChangeListener; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.List; import javax.swing.JButton; @@ -50,6 +52,8 @@ import fr.ifremer.isisfish.ui.SaveVerifier; import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI; import fr.ifremer.isisfish.ui.widget.ErrorDialogUI; +import java.util.Map; +import java.util.Map.Entry; /** * InputSaveVerifier. @@ -107,8 +111,8 @@ protected String currentOnglet = null; protected TopiaContext isisContext = null; - protected List<TopiaEntity> currentEntities = new ArrayList<TopiaEntity>(); - protected List<InputContentUI> currentPanels = new ArrayList<InputContentUI>(); + protected Map<String, TopiaEntity> currentEntities = new HashMap <String, TopiaEntity>(); + protected List<InputContentUI> currentPanels = new ArrayList <InputContentUI>(); protected InputUI rootUI; protected SensitivityTabUI sensUI; @@ -269,7 +273,7 @@ public void topiaSave() { try { noModif(); - for (TopiaEntity t : currentEntities) { + for (TopiaEntity t : currentEntities.values()){ t.update(); if (log.isDebugEnabled()) { log.debug("updating : " + t); @@ -294,23 +298,24 @@ try { noModif(); isisContext.rollbackTransaction(); - List<TopiaEntity> canceledEntity = currentEntities; - currentEntities = new ArrayList<TopiaEntity>(); + Map<String, TopiaEntity> canceledEntity = new HashMap<String, TopiaEntity>(); + for (Entry<String, TopiaEntity> currentEntity : currentEntities.entrySet()) { + TopiaEntity t = isisContext.findByTopiaId(currentEntity.getValue().getTopiaId()); - // TODO a quoi ca sert de recharger les entités ? - for (TopiaEntity t : canceledEntity) { - TopiaEntity t2 = isisContext.findByTopiaId(t.getTopiaId()); - - // desynchronise la précédente - // fix : org.hibernate.NonUniqueObjectException: a different object with the - // same identifier value was already associated with the session - //((TopiaContextImpl)isisContext).getHibernate().evict(t2); - //t.setTopiaId(null); - - rootUI.repaintNode(currentNode.getContextPath()); - rootUI.setTreeSelection(currentNode.getContextPath()); - addCurrentEntity(t2); - } + // TODO a quoi ca sert de recharger les entités ? + // desynchronise la précédente + // fix : org.hibernate.NonUniqueObjectException: a different object with the + // same identifier value was already associated with the session + //((TopiaContextImpl)isisContext).getHibernate().evict(t2); + //t.setTopiaId(null); + + rootUI.repaintNode(currentNode.getContextPath()); + rootUI.setTreeSelection(currentNode.getContextPath()); + + String key = currentEntity.getKey(); + canceledEntity.put(key, t); + addCurrentEntity(t); + } rootUI.setInfoText(_("isisfish.message.cancel.finished")); } catch (Exception eee) { if (log.isErrorEnabled()) { @@ -339,7 +344,7 @@ } } - public void addCurrentEntity(TopiaEntity currentEntity) { + public void addCurrentEntity(TopiaEntity currentEntity, String key) { if (currentEntity != null) { editable = true; isisContext = currentEntity.getTopiaContext(); @@ -358,12 +363,17 @@ if (entity != null) { currentEntities.remove(entity); } - this.currentEntities.add(currentEntity); + this.currentEntities.put(key, currentEntity); setPanelsActifs(); } } - public void removeAllEntity() { + public void addCurrentEntity(TopiaEntity currentEntity) { + if (currentEntity != null){ + addCurrentEntity(currentEntity, currentEntity.getTopiaId()); + } + } + public void removeAllEntity(){ currentEntities.clear(); editable = false; noModif(); @@ -446,13 +456,17 @@ return isisContext; } - public List<TopiaEntity> getCurrentEntities() { - return currentEntities; + public Collection<TopiaEntity> getCurrentEntities() { + return currentEntities.values(); } - public <E extends TopiaEntity> E getEntity(Class<E> clazz) { - for (TopiaEntity te : currentEntities) { - if (clazz.isInstance(te)) { + public <E extends TopiaEntity> E getEntity(Class<E> clazz, String key){ + return (E)currentEntities.get(key); + } + + public <E extends TopiaEntity> E getEntity(Class<E> clazz){ + for (TopiaEntity te : currentEntities.values()){ + if (clazz.isInstance(te)){ return (E) te; } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2009-04-23 15:34:25 UTC (rev 2140) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2009-04-23 15:47:53 UTC (rev 2141) @@ -56,7 +56,7 @@ int month = 0; PropertyChangeListener listener = null; -addPropertyChangeListener("bean", new PropertyChangeListener() { +addPropertyChangeListener("strategyMonthInfo", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getOldValue() != null || evt.getNewValue() == null) { // remove previous binding on getBean() @@ -92,6 +92,9 @@ } } if (getStrategyMonthInfo() != null){ + numberOfTrips.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); + fieldStrategyMonthInfoProportion.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); + fieldStrategyMonthInfoMinInactivityDays.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); ActionListener[] listeners = fieldStrategyMonthInfoTripType.getActionListeners(); for (ActionListener listener : listeners){ fieldStrategyMonthInfoTripType.removeActionListener(listener);
participants (1)
-
sletellier@users.labs.libre-entreprise.org