This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository izi-eval. See http://git.codelutin.com/izi-eval.git commit 978274d1d74b214d482d1f110c73aeb5fc5e1d1c Author: Eric Chatellier <chatellier@codelutin.com> Date: Thu Jan 7 16:40:12 2016 +0100 fixes #7562: mise à jour de l'evaluation dexi eval lors de l'affichage des onglets evaluation, graphique et graphique synoptique --- .../src/main/java/fr/inra/masc/MascUIModel.java | 34 ++++++++----- .../java/fr/inra/masc/ui/MascMainUIHandler.java | 55 +++++++++++++--------- .../EvaluatedCriteriaEditorHandler.java | 3 ++ 3 files changed, 58 insertions(+), 34 deletions(-) diff --git a/masc-api/src/main/java/fr/inra/masc/MascUIModel.java b/masc-api/src/main/java/fr/inra/masc/MascUIModel.java index d2d07a2..1acb50c 100644 --- a/masc-api/src/main/java/fr/inra/masc/MascUIModel.java +++ b/masc-api/src/main/java/fr/inra/masc/MascUIModel.java @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2011 - 2012 Inra, Codelutin, Tony Chemit + * Copyright (C) 2011 - 2016 Inra, Codelutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,18 +24,18 @@ */ package fr.inra.masc; +import static org.nuiton.i18n.I18n._; + +import java.beans.PropertyChangeListener; +import java.io.File; + +import org.jdesktop.beans.AbstractSerializableBean; + import fr.inra.masc.charts.ChartModel; import fr.inra.masc.model.MascModel; import fr.inra.masc.model.RScriptModel; import fr.inra.masc.reports.ReportModel; import fr.inra.masc.synoptic.SynopticModel; -import java.beans.PropertyChangeListener; -import java.io.File; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.beans.AbstractSerializableBean; - -import static org.nuiton.i18n.I18n._; /** * Model for masc application @@ -45,9 +45,6 @@ import static org.nuiton.i18n.I18n._; */ public class MascUIModel extends AbstractSerializableBean { - /** Logger */ - private static Log log = LogFactory.getLog(MascUIModel.class); - private static final long serialVersionUID = 1L; public static final String PROPERTY_MASC_MODEL = "mascModel"; @@ -63,6 +60,8 @@ public class MascUIModel extends AbstractSerializableBean { public static final String PROPERTY_DEXI_FILE = "dexiFile"; public static final String PROPERTY_MODEL_CHANGED = "modelChanged"; + + public static final String PROPERTY_EVALUATION_DIRTY = "evaluationDirty"; public static final String PROPERTY_FILE_OPEN = "fileOpen"; @@ -97,6 +96,9 @@ public class MascUIModel extends AbstractSerializableBean { protected transient String mascFileName; protected transient boolean modelChanged; + + // always dirty before first evaluation + protected transient boolean evaluationDirty = true; protected transient boolean transformCriteriaToBasic; @@ -250,6 +252,16 @@ public class MascUIModel extends AbstractSerializableBean { this.modelChanged = modelChanged; firePropertyChange(PROPERTY_MODEL_CHANGED, oldValue, modelChanged); } + + public boolean isEvaluationDirty() { + return evaluationDirty; + } + + public void setEvaluationDirty(boolean evaluationDirty) { + boolean oldValue = isEvaluationDirty(); + this.evaluationDirty = evaluationDirty; + firePropertyChange(PROPERTY_EVALUATION_DIRTY, oldValue, evaluationDirty); + } public RScriptModel getScriptModel() { if (getReportModel().getScriptModel() == null) { diff --git a/masc-ui/src/main/java/fr/inra/masc/ui/MascMainUIHandler.java b/masc-ui/src/main/java/fr/inra/masc/ui/MascMainUIHandler.java index 84ea257..f9c52d5 100644 --- a/masc-ui/src/main/java/fr/inra/masc/ui/MascMainUIHandler.java +++ b/masc-ui/src/main/java/fr/inra/masc/ui/MascMainUIHandler.java @@ -28,31 +28,22 @@ import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; import java.awt.BorderLayout; +import java.awt.Cursor; import java.awt.Desktop; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URL; import java.util.Collection; import java.util.Locale; -import java.util.Properties; import javax.swing.JOptionPane; import javax.swing.JPanel; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.SwingUtil; -import jaxx.runtime.context.JAXXInitialContext; -import jaxx.runtime.swing.AboutPanel; -import jaxx.runtime.swing.config.ConfigUIHelper; -import jaxx.runtime.swing.help.JAXXHelpBroker; -import jaxx.runtime.swing.help.JAXXHelpUIHandler; -import jaxx.runtime.swing.log.JAXXLog4jUI; +import javax.swing.SwingUtilities; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.i18n.I18n; @@ -90,6 +81,11 @@ import fr.reseaumexico.model.event.InputDesignFactorEvent; import fr.reseaumexico.model.event.InputDesignFactorListener; import fr.reseaumexico.model.event.InputDesignScenarioEvent; import fr.reseaumexico.model.event.InputDesignScenarioListener; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.AboutPanel; +import jaxx.runtime.swing.config.ConfigUIHelper; +import jaxx.runtime.swing.log.JAXXLog4jUI; /** * Handler of main UI @@ -115,6 +111,7 @@ public class MascMainUIHandler extends MascHandler /*implements JAXXHelpUIHandle @Override public void factorValueChanged(InputDesignFactorEvent event) { getMascUIModel().setModelChanged(true); + getMascUIModel().setEvaluationDirty(true); } }; @@ -123,18 +120,21 @@ public class MascMainUIHandler extends MascHandler /*implements JAXXHelpUIHandle @Override public void scenarioAdded(InputDesignScenarioEvent event) { getMascUIModel().setModelChanged(true); + getMascUIModel().setEvaluationDirty(true); refreshFooter(); } @Override public void scenarioRemoved(InputDesignScenarioEvent event) { getMascUIModel().setModelChanged(true); + getMascUIModel().setEvaluationDirty(true); refreshFooter(); } @Override public void scenarioRenamed(InputDesignScenarioEvent event) { getMascUIModel().setModelChanged(true); + getMascUIModel().setEvaluationDirty(true); refreshFooter(); } }; @@ -315,7 +315,7 @@ public class MascMainUIHandler extends MascHandler /*implements JAXXHelpUIHandle } } - public boolean changeTab(MascTabs tabUI, int newIndex, int oldIndex) { + public boolean changeTab(final MascTabs tabUI, int newIndex, int oldIndex) { if (oldIndex == 1 || oldIndex == 2) { convertInputDesignModelToMascModel(tabUI); @@ -324,17 +324,16 @@ public class MascMainUIHandler extends MascHandler /*implements JAXXHelpUIHandle // second tab is input design editor if (newIndex == 1 || newIndex == 2) { - //FIXME-tchemit 1) stop instanciate listener (keep only one) - //FIXME-tchemit 2) always remove listener from previous inputDesign - avoid memory leak // get input design model try { InputDesign oldInputDesign = tabUI.getInputDesignEditor().getInputDesign(); - if (oldInputDesign != null) { + if (oldInputDesign != null) { // remove listeners oldInputDesign.removeInputDesignFactorListener(inputDesignFactorListener); oldInputDesign.removeInputDesignScenarioListener(inputDesignScenarioListener); } + InputDesign inputDesign = getService(MascModelService.class).convertMascModelToMexicoInputDesignModel(getCurrentMascModel()); // add listener to listen factor values changes @@ -350,13 +349,23 @@ public class MascMainUIHandler extends MascHandler /*implements JAXXHelpUIHandle MascUIHelper.showError(ui, errorMsg, eee); } - // third tab is eval editor - } else if (newIndex == 3) { - - // get evaluated masc model - EvaluatedCriteriaEditorHandler handler = - tabUI.getEvaluatedCriteriaEditor().getHandler(); - handler.loadEvaluatedModel(); + // call evaluation for both tab 3 to 5 only if evaluation is dirty + } else if ((newIndex == 3 || newIndex == 4 || newIndex == 5) && getMascUIModel().isEvaluationDirty()) { + + // display wiat cursor (long operation) + tabUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // get evaluated masc model + EvaluatedCriteriaEditorHandler handler = + tabUI.getEvaluatedCriteriaEditor().getHandler(); + handler.loadEvaluatedModel(); + + // restore default cursor + tabUI.setCursor(null); + } + }); } // for threshold, verify that all lines are filled before quit diff --git a/masc-ui/src/main/java/fr/inra/masc/ui/content/editor/evalutedCriteria/EvaluatedCriteriaEditorHandler.java b/masc-ui/src/main/java/fr/inra/masc/ui/content/editor/evalutedCriteria/EvaluatedCriteriaEditorHandler.java index 236842d..2637ce8 100644 --- a/masc-ui/src/main/java/fr/inra/masc/ui/content/editor/evalutedCriteria/EvaluatedCriteriaEditorHandler.java +++ b/masc-ui/src/main/java/fr/inra/masc/ui/content/editor/evalutedCriteria/EvaluatedCriteriaEditorHandler.java @@ -129,6 +129,9 @@ public class EvaluatedCriteriaEditorHandler extends MascHandler { // expend tree by default SwingUtil.expandTreeTable(ui.getEvaluatedCriteriaTreeTable()); + + // clear dirty + getMascUIModel().setEvaluationDirty(false); } catch (Exception eee) { String errorMsg = "Failed to launch DEXiEval"; log.error(errorMsg, eee); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.