Isis-fish-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
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- 3175 discussions
r4235 - trunk/src/main/java/fr/ifremer/isisfish/simulator
by echatellier@users.forge.codelutin.com 27 May '15
by echatellier@users.forge.codelutin.com 27 May '15
27 May '15
Author: echatellier
Date: 2015-05-27 12:59:32 +0000 (Wed, 27 May 2015)
New Revision: 4235
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4235
Log:
Fix code format
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java 2015-05-27 12:57:39 UTC (rev 4234)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java 2015-05-27 12:59:32 UTC (rev 4235)
@@ -246,10 +246,10 @@
* @return La matrice demandée ou null si aucune matrice ne correspond a
* la demande.
*/
- public MatrixND getMatrix(TimeStep step, Population pop, String name){
- name += " " + pop;
- return getMatrix(step, name);
- }
+ public MatrixND getMatrix(TimeStep step, Population pop, String name){
+ name += " " + pop;
+ return getMatrix(step, name);
+ }
/**
* Retourne la matrice stocke pour un pas de temps
@@ -258,13 +258,13 @@
* @return La matrice demandée ou null si aucune matrice ne correspond a
* la demande.
*/
- public MatrixND getMatrix(TimeStep step, String name){
- MatrixND result = null;
+ public MatrixND getMatrix(TimeStep step, String name){
+ MatrixND result = null;
if (getter != null) {
result = getter.getMatrix(context, step, name);
- }
+ }
return result;
- }
+ }
/**
* Retourne la matrice stocke pour des pas de temps
@@ -274,10 +274,10 @@
* @return La matrice demandée ou null si aucune matrice ne correspond a
* la demande.
*/
- public MatrixND getMatrix(List<TimeStep> steps, Population pop, String name){
- name += " " + pop;
- return getMatrix(steps, name);
- }
+ public MatrixND getMatrix(List<TimeStep> steps, Population pop, String name){
+ name += " " + pop;
+ return getMatrix(steps, name);
+ }
/**
* Retourne la matrice stocke pour des pas de temps
@@ -286,37 +286,34 @@
* @return La matrice demandée ou null si aucune matrice ne correspond a
* la demande.
*/
- public MatrixND getMatrix(List<TimeStep> steps, String name){
- MatrixND result = null;
+ public MatrixND getMatrix(List<TimeStep> steps, String name){
+ MatrixND result = null;
if (getter != null) {
result = getter.getMatrix(context, steps, name);
- }
+ }
return result;
- }
+ }
+ /**
+ * Retourne une matrice contenant tous les pas de temps.
+ * @param pop la population pour lequel on souhaite la matrice
+ * @param name le nom des resultats dont on veut une matrice globale.
+ */
+ public MatrixND getMatrix(Population pop, String name){
+ name += " " + pop;
+ return getMatrix(name);
+ }
- /**
- * Retourne une matrice contenant tous les pas de temps.
- * @param pop la population pour lequel on souhaite la matrice
- * @param name le nom des resultats dont on veut une matrice globale.
- */
- public MatrixND getMatrix(Population pop, String name){
- name += " " + pop;
- return getMatrix(name);
- }
-
- /**
- * Retourne une matrice contenant tous les pas de temps.
- * @param name le nom des resultats dont on veut une matrice globale.
- */
- public MatrixND getMatrix(String name){
- MatrixND result = null;
- if (getter != null) {
- result = getter.getMatrix(context, name);
- }
- return result;
- }
+ /**
+ * Retourne une matrice contenant tous les pas de temps.
+ * @param name le nom des resultats dont on veut une matrice globale.
+ */
+ public MatrixND getMatrix(String name){
+ MatrixND result = null;
+ if (getter != null) {
+ result = getter.getMatrix(context, name);
+ }
+ return result;
+ }
}
-
-
1
0
Author: echatellier
Date: 2015-05-27 12:57:39 +0000 (Wed, 27 May 2015)
New Revision: 4234
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4234
Log:
Update commons-email and svnkit
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2015-05-22 16:10:26 UTC (rev 4233)
+++ trunk/pom.xml 2015-05-27 12:57:39 UTC (rev 4234)
@@ -212,7 +212,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
- <version>1.3.3</version>
+ <version>1.4</version>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
@@ -342,7 +342,7 @@
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
- <version>1.8.9</version>
+ <version>1.8.10</version>
<scope>compile</scope>
<exclusions>
<exclusion>
1
0
22 May '15
Author: echatellier
Date: 2015-05-22 16:10:26 +0000 (Fri, 22 May 2015)
New Revision: 4233
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4233
Log:
Move script code to dedicated handler (sensitivity)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTransferHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTree.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/widget/Interval.java
trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -81,7 +81,7 @@
* Get ui that can display internalClass.
*
* @param internalClass internal class to get ui
- * @return ui for class
+ * @return navigationUI for class
* @throws Exception
*/
protected InputContentUI<?> getUIInstanceForBeanClass(Class<?> internalClass, NavigationUI navigationUI) throws Exception {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -22,6 +22,6 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<JPanel layout='{new BorderLayout()}'>
+<JPanel layout='{new BorderLayout()}' abstract="true">
</JPanel>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -302,8 +302,6 @@
*/
public void configurationR(WelcomeUI welcomeUI) {
RConfigUI rconfigUI = new RConfigUI(welcomeUI, welcomeUI);
- RConfigHandler handler = rconfigUI.getHandler();
- handler.init(rconfigUI);
rconfigUI.pack();
rconfigUI.setLocationRelativeTo(welcomeUI);
rconfigUI.setVisible(true);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -50,12 +50,16 @@
private static Log log = LogFactory.getLog(RConfigHandler.class);
+ protected RConfigUI rconfigUI;
+
+ public RConfigHandler(RConfigUI rconfigUI) {
+ this.rconfigUI = rconfigUI;
+ }
+
/**
* Initialise l'ui.
- *
- * @param rconfigUI ui to init
*/
- public void init(RConfigUI rconfigUI) {
+ public void afterInit() {
String rHome = System.getenv("R_HOME");
rconfigUI.getRHomeField().setText(rHome);
if (StringUtils.isBlank(rHome)) {
@@ -84,10 +88,8 @@
/**
* Test r configuration.
- *
- * @param rconfigUI
*/
- public void testRCOnfiguration(RConfigUI rconfigUI) {
+ public void testRCOnfiguration() {
REngine engine = null;
try {
engine = new RProxy();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/RConfigUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -23,7 +23,14 @@
#L%
-->
<JDialog title="isisfish.simulator.configuration.r.title" layout="{new BorderLayout()}">
- <RConfigHandler id="handler" />
+ <RConfigHandler id="handler" constructorParams='this' />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
+ ]]></script>
+
<Table constraints="BorderLayout.CENTER">
<row>
<cell columns="2">
@@ -58,7 +65,7 @@
<cell columns="2" anchor='center'>
<JPanel>
<JButton text="isisfish.simulator.configuration.r.launchtest"
- onActionPerformed="getHandler().testRCOnfiguration(this)" />
+ onActionPerformed="handler.testRCOnfiguration()" />
<JButton text="isisfish.common.close"
onActionPerformed="dispose()" />
</JPanel>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -1,561 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.config;
-
-import static org.nuiton.i18n.I18n.t;
-
-import java.awt.Color;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import javax.swing.JComponent;
-import javax.swing.JOptionPane;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.KeyPair;
-import com.jcraft.jsch.Session;
-
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.util.ssh.InvalidPassphraseException;
-import fr.ifremer.isisfish.util.ssh.ProxyCommand;
-import fr.ifremer.isisfish.util.ssh.SSHAgent;
-import fr.ifremer.isisfish.util.ssh.SSHException;
-import fr.ifremer.isisfish.util.ssh.SSHUserInfo;
-import fr.ifremer.isisfish.util.ssh.SSHUtils;
-
-/**
- * Action for SSHLauncherConfig UI.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SSHLauncherConfigAction {
-
- /** Class logger. */
- private static Log log = LogFactory.getLog(SSHLauncherConfigAction.class);
-
- protected SSHLauncherConfigUI configUI;
-
- protected String currentSSHserver;
- protected String currentSSHUsername;
- protected File currentSSHKey;
- protected String currentSSHUserhome;
- protected String currentSSHDatapath;
- protected String currentSSHIsisHome;
- protected String currentSSHTempPath;
- protected String currentSSHJavaPath;
- protected String currentSSHPbsBinPath;
- protected String currentSSHPbsQsubOptions;
- protected String currentSSHMaxThreads;
- protected String currentSSHMaxMemory;
- protected String currentSSHControlInterval;
-
- /**
- * Constructor with UI.
- *
- * @param configUI config ui
- */
- public SSHLauncherConfigAction(SSHLauncherConfigUI configUI) {
- this.configUI = configUI;
- }
-
- /**
- * Reset values with default configuration values.
- */
- public void resetSSHConfiguration() {
- // server config
- configUI.getSshServerField().setText(IsisFish.config.getSimulatorSshServer());
- configUI.getUsernameField().setText(IsisFish.config.getSimulatorSshUsername());
- configUI.getSshKeyField().setText(IsisFish.config.getSSHPrivateKeyFilePath().getAbsolutePath());
-
- // caparmor config
- configUI.getSshUserhomeField().setText(IsisFish.config.getSimulatorSshUserHome());
- configUI.getSshDatapathField().setText(IsisFish.config.getSimulatorSshDataPath());
- configUI.getSshIsisHomeField().setText(IsisFish.config.getSimulatorSshIsisHome());
- configUI.getSshTemppathField().setText(IsisFish.config.getSimulatorSshTmpPath());
- configUI.getSshJavaPathField().setText(IsisFish.config.getSimulatorSshJavaPath());
- configUI.getSshPbsBinPathField().setText(IsisFish.config.getSimulatorSshPbsBinPath());
- configUI.getSshPbsQsubOptionsField().setText(IsisFish.config.getSimulatorSshPbsQsubOptions());
- configUI.getSshControlIntervalField().setText(String.valueOf(IsisFish.config.getSimulatorSshControlCheckInterval()));
- configUI.getSshMaxThreadsField().setText(String.valueOf(IsisFish.config.getSimulatorSshMaxThreads()));
- configUI.getSshMaxMemoryField().setText(IsisFish.config.getSimulatorSshMaxMemory());
-
- doCheck();
- }
-
- /**
- * Reset display.
- */
- protected void configurationChanged() {
-
- configUI.setConnected(false);
- configUI.getMessageLabel().setText("");
- configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", "isis-database", "0"));
- configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", "isis-tmp", "0"));
-
- }
-
- /**
- * Check input format validity.
- */
- public void doCheck() {
-
- configurationChanged();
-
- // copy values
- currentSSHserver = configUI.getSshServerField().getText().trim();
- if (currentSSHserver.isEmpty()) {
- setColor(true, configUI.getSshServerField());
- } else {
- setColor(false, configUI.getSshServerField());
- }
-
- // copy values
- //currentSSHsftpServer = configUI.getSshSftpServerField().getText().trim();
-
- // can be empty (optionnal use)
- currentSSHUsername = configUI.getUsernameField().getText().trim();
- if (!currentSSHUsername.matches("\\w+")) {
- setColor(true, configUI.getUsernameField());
- } else {
- setColor(false, configUI.getUsernameField());
- }
-
- // if ssh key is set, must be a valid file
- currentSSHKey = new File(configUI.getSshKeyField().getText().trim());
- if (!currentSSHKey.isFile()) {
- setColor(true, configUI.getSshKeyField());
- } else {
- configUI.getSshKeyButton().setEnabled(false);
- configUI.getSshKeyField().setEnabled(false);
- setColor(false, configUI.getSshKeyField());
- }
-
- currentSSHDatapath = configUI.getSshDatapathField().getText().trim();
- if (currentSSHDatapath.isEmpty()) {
- setColor(true, configUI.getSshDatapathField());
- } else {
- setColor(false, configUI.getSshDatapathField());
- }
-
- currentSSHIsisHome = configUI.getSshIsisHomeField().getText().trim();
- if (currentSSHIsisHome.isEmpty()) {
- setColor(true, configUI.getSshIsisHomeField());
- } else {
- setColor(false, configUI.getSshIsisHomeField());
- }
-
- currentSSHTempPath = configUI.getSshTemppathField().getText().trim();
- if (currentSSHTempPath.isEmpty()) {
- setColor(true, configUI.getSshTemppathField());
- } else {
- setColor(false, configUI.getSshTemppathField());
- }
-
- currentSSHJavaPath = configUI.getSshJavaPathField().getText().trim();
- if (currentSSHJavaPath.isEmpty()) {
- setColor(true, configUI.getSshJavaPathField());
- } else {
- setColor(false, configUI.getSshJavaPathField());
- }
-
- currentSSHPbsBinPath = configUI.getSshPbsBinPathField().getText()
- .trim();
- if (currentSSHPbsBinPath.isEmpty()) {
- setColor(true, configUI.getSshPbsBinPathField());
- } else {
- setColor(false, configUI.getSshPbsBinPathField());
- }
-
- // currentSSHPbsQsubOptions
- currentSSHPbsQsubOptions = configUI.getSshPbsQsubOptionsField().getText().trim();
-
- // currentSSHMaxThreads
- currentSSHMaxThreads = configUI.getSshMaxThreadsField().getText().trim();
- if (!currentSSHMaxThreads.matches("\\d+")) {
- setColor(true, configUI.getSshMaxThreadsField());
- } else {
- setColor(false, configUI.getSshMaxThreadsField());
- }
-
- // currentSSHMaxMemory
- currentSSHMaxMemory = configUI.getSshMaxMemoryField().getText().trim();
-
- // currentSSHControlInterval
- currentSSHControlInterval = configUI.getSshControlIntervalField()
- .getText().trim();
- if (!currentSSHControlInterval.matches("\\d+")) {
- setColor(true, configUI.getSshControlIntervalField());
- } else {
- setColor(false, configUI.getSshControlIntervalField());
- }
- }
-
- /**
- * Set values in config and force configuration save.
- */
- public void saveSSHConfiguration() {
- IsisFish.config.setSimulatorSshServer(currentSSHserver);
- //IsisFish.config.setSimulatorSshSftpServer(currentSSHsftpServer);
- IsisFish.config.setSimulatorSshUsername(currentSSHUsername);
- IsisFish.config.setSSHPrivateKeyFilePath(currentSSHKey);
-
- IsisFish.config.setSimulatorSshUserHome(currentSSHUserhome);
- IsisFish.config.setSimulatorSshDataPath(currentSSHDatapath);
- IsisFish.config.setSimulatorSshIsisHome(currentSSHIsisHome);
- IsisFish.config.setSimulatorSshTmpPath(currentSSHTempPath);
- IsisFish.config.setSimulatorSshJavaPath(currentSSHJavaPath);
- IsisFish.config.setSimulatorSshPbsBinPath(currentSSHPbsBinPath);
- IsisFish.config.setSimulatorSshPbsQsubOptions(currentSSHPbsQsubOptions);
- IsisFish.config.setSimulatorSshControlCheckInterval(Integer.parseInt(currentSSHControlInterval));
- IsisFish.config.setSimulatorSshMaxThreads(Integer.parseInt(currentSSHMaxThreads));
- IsisFish.config.setSimulatorSshMaxMemory(currentSSHMaxMemory);
-
- IsisFish.config.saveForUser();
- configUI.dispose();
- }
-
- /**
- * Close frame.
- */
- public void cancelSSHConfiguration() {
- configUI.dispose();
- }
-
- /**
- * Realise une connexion ssh et teste les données.
- */
- public void testSSHConfiguration() {
- JSch jsch = new JSch();
-
- String host = currentSSHserver;
- int port = 22; // by default, 22
- String sPort = null;
-
- try {
- if (host.indexOf(':') > 0) {
- sPort = host.substring(host.indexOf(':') + 1);
- port = Integer.parseInt(sPort);
- host = host.substring(0, host.indexOf(':'));
- }
-
- // add ssh key
- boolean sshKeyUsed = false;
- if (currentSSHKey.canRead()) {
- if (log.isInfoEnabled()) {
- log.info(t("Ssh key found '%s' will be used to connect to",
- currentSSHKey.getAbsoluteFile(), host));
- }
- jsch.addIdentity(currentSSHKey.getAbsolutePath());
- sshKeyUsed = true;
- } else {
- if (log.isInfoEnabled()) {
- log.info(t("Can't read ssh key : %s", currentSSHKey));
- }
- }
-
- Session session = jsch.getSession(currentSSHUsername, host, port);
- String proxyCommand = IsisFish.config.getSimulatorSshProxyCommand();
- if (StringUtils.isNotBlank(proxyCommand)) {
- session.setProxy(new ProxyCommand(proxyCommand));
- }
-
- // username and password will be given via UserInfo interface.
- SSHUserInfo ui = new SSHUserInfo();
- if (sshKeyUsed) {
- char[] passchars = SSHAgent.getAgent().getPassphrase(currentSSHKey);
- String passphrase = String.valueOf(passchars);
- ui.setPassphrase(passphrase);
- setTestMessage(t("isisfish.simulator.ssh.configuration.connectingpk"), false);
- } else {
- setTestMessage(t("isisfish.simulator.ssh.configuration.connecting"), false);
- }
- session.setUserInfo(ui);
- session.connect(10000); // timeout
-
- setTestMessage(t("isisfish.simulator.ssh.configuration.connectionok"), false);
-
- // get user home
- currentSSHUserhome = getUserHomeDirectory(session);
- configUI.getSshUserhomeField().setText(currentSSHUserhome);
- // get space disk
- String databaseSize = getFolderSize(session, currentSSHDatapath);
- String temppathSize = getFolderSize(session, currentSSHTempPath);
- configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHDatapath, databaseSize));
- configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHTempPath, temppathSize));
- session.disconnect();
-
- configUI.setConnected(true);
- } catch (NumberFormatException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't connect", e);
- }
- setTestMessage(t("isisfish.error.simulation.remote.wrongportvalue",
- sPort), true);
- } catch (JSchException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't connect", e);
- }
- setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e
- .getMessage()), true);
- } catch (SSHException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't connect", e);
- }
- setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e
- .getMessage()), true);
- } catch (InvalidPassphraseException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't connect", e);
- }
- setTestMessage(
- t("isisfish.simulator.ssh.configuration.invalidpassphrase"),
- true);
- }
- }
-
- /**
- * Get user home directory with an opened session.
- *
- * @param session opened session
- * @return 'pwd' result
- * @throws SSHException
- */
- protected String getUserHomeDirectory(Session session) throws SSHException {
-
- String command = "pwd";
-
- Writer output = new StringWriter();
- int exit = SSHUtils.exec(session, command, output);
-
- if (exit != 0) {
- throw new SSHException(t("Command '%s' fail to execute", command));
- }
-
- String out = output.toString();
- return out;
- }
-
- /**
- * Get user home directory with an opened session.
- *
- * @param session opened session
- * @param path path to get size
- * @return dir size
- * @throws SSHException
- */
- protected String getFolderSize(Session session, String path) throws SSHException {
-
- String command = "du -hs \"" + path + "\"";
-
- Writer output = new StringWriter();
- SSHUtils.exec(session, command, output);
-
- // la sortie est "35Go isisdatabase-3"
- String out = output.toString();
- out = out.split("\\s+")[0];
- return out;
- }
-
- /**
- * Clear database.
- */
- public void clearDatabase() {
- clearFolder(currentSSHDatapath);
- }
-
- /**
- * Clear temp directory.
- */
- public void clearTempDirectory() {
- clearFolder(currentSSHTempPath);
- }
-
- /**
- * Clear specified directory.
- *
- * @param path path to clear
- */
- protected void clearFolder(String path) {
-
- // prevent, for home deletion, can happens :D
- if (StringUtils.isEmpty(path) || path.trim().equals(".")) {
- throw new IllegalArgumentException("Can't delete directory : " + path);
- }
-
- int response = JOptionPane.showConfirmDialog(configUI, t("isisfish.simulator.ssh.configuration.freespace.confirmdelete", path),
- t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
-
- if (response == JOptionPane.YES_OPTION) {
- JSch jsch = new JSch();
-
- String host = currentSSHserver;
- int port = 22; // by default, 22
- String sPort = null;
-
- try {
- if (host.indexOf(':') > 0) {
- sPort = host.substring(host.indexOf(':') + 1);
- port = Integer.parseInt(sPort);
- host = host.substring(0, host.indexOf(':'));
- }
-
- // add ssh key
- boolean sshKeyUsed = false;
- if (currentSSHKey.canRead()) {
- if (log.isInfoEnabled()) {
- log.info(t("Ssh key found '%s' will be used to connect to",
- currentSSHKey.getAbsoluteFile(), host));
- }
- jsch.addIdentity(currentSSHKey.getAbsolutePath());
- sshKeyUsed = true;
- } else {
- if (log.isInfoEnabled()) {
- log.info(t("Can't read ssh key : %s", currentSSHKey));
- }
- }
-
- Session session = jsch.getSession(currentSSHUsername, host, port);
- String proxyCommand = IsisFish.config.getSimulatorSshProxyCommand();
- if (StringUtils.isNotBlank(proxyCommand)) {
- session.setProxy(new ProxyCommand(proxyCommand));
- }
-
- // username and password will be given via UserInfo interface.
- SSHUserInfo ui = new SSHUserInfo();
- if (sshKeyUsed) {
- char[] passchars = SSHAgent.getAgent().getPassphrase(currentSSHKey);
- String passphrase = String.valueOf(passchars);
- ui.setPassphrase(passphrase);
- }
- session.setUserInfo(ui);
- session.connect(10000); // timeout
-
- String command = "rm -rf \"" + path + "\"";
-
- if (log.isDebugEnabled()) {
- log.debug("Removing folder with command : " + command);
- }
- Writer output = new StringWriter();
- int exit = SSHUtils.exec(session, command, output);
-
- // get space disk
- String databaseSize = getFolderSize(session, currentSSHDatapath);
- String temppathSize = getFolderSize(session, currentSSHTempPath);
- configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHDatapath, databaseSize));
- configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHTempPath, temppathSize));
- session.disconnect();
-
- session.disconnect();
- if (exit != 0) {
- throw new SSHException(t("Command '%s' fail to execute", command));
- }
- }
- catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't connect", e);
- }
- setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e.getMessage()), true);
- }
- }
- else {
- if (log.isInfoEnabled()) {
- log.info("Delete action canceled by user");
- }
- }
- }
-
- /**
- * Generate new SSH key.
- */
- protected void generateSSHKey() {
- if (currentSSHKey.exists()) {
- throw new IllegalArgumentException("Can't overwrite ssh key");
- }
-
- try {
- // make parent dir
- if (currentSSHKey.getParentFile() != null
- && !currentSSHKey.getParentFile().exists()) {
- currentSSHKey.getParentFile().mkdirs();
- }
- JSch jsch = new JSch();
- KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 2048);
- //kpair.setPassphrase(passphrase);
- kpair.writePrivateKey(currentSSHKey.getAbsolutePath());
- kpair.writePublicKey(currentSSHKey.getAbsolutePath() + ".pub",
- currentSSHUsername + "@forIsisFish");
- if (log.isInfoEnabled()) {
- log.info("Finger print: " + kpair.getFingerPrint());
- }
- kpair.dispose();
- } catch (JSchException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't make ssh key", e);
- }
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't make ssh key", e);
- }
- }
-
- // refresh ckeck
- doCheck();
- }
-
- /**
- * Set color depending of field validity.
- *
- *
- * @param invalid valid field
- * @param component component to set color
- */
- protected void setColor(boolean invalid, JComponent component) {
- component.setForeground(invalid ? Color.RED : Color.BLACK);
- }
-
- /**
- * Set message in message field with status color.
- *
- * @param message message to display
- * @param error error status
- */
- protected void setTestMessage(String message, boolean error) {
- configUI.getMessageLabel().setForeground(
- error ? Color.RED : Color.GREEN.darker());
- configUI.getMessageLabel().setText(message);
- }
-}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigHandler.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,566 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.config;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.KeyPair;
+import com.jcraft.jsch.Session;
+
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.util.ssh.InvalidPassphraseException;
+import fr.ifremer.isisfish.util.ssh.ProxyCommand;
+import fr.ifremer.isisfish.util.ssh.SSHAgent;
+import fr.ifremer.isisfish.util.ssh.SSHException;
+import fr.ifremer.isisfish.util.ssh.SSHUserInfo;
+import fr.ifremer.isisfish.util.ssh.SSHUtils;
+
+/**
+ * Action for SSHLauncherConfig UI.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SSHLauncherConfigHandler {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(SSHLauncherConfigHandler.class);
+
+ protected SSHLauncherConfigUI configUI;
+
+ protected String currentSSHserver;
+ protected String currentSSHUsername;
+ protected File currentSSHKey;
+ protected String currentSSHUserhome;
+ protected String currentSSHDatapath;
+ protected String currentSSHIsisHome;
+ protected String currentSSHTempPath;
+ protected String currentSSHJavaPath;
+ protected String currentSSHPbsBinPath;
+ protected String currentSSHPbsQsubOptions;
+ protected String currentSSHMaxThreads;
+ protected String currentSSHMaxMemory;
+ protected String currentSSHControlInterval;
+
+ /**
+ * Constructor with UI.
+ *
+ * @param configUI config ui
+ */
+ public SSHLauncherConfigHandler(SSHLauncherConfigUI configUI) {
+ this.configUI = configUI;
+ }
+
+ protected void afterInit() {
+ // fill default values
+ resetSSHConfiguration();
+ }
+
+ /**
+ * Reset values with default configuration values.
+ */
+ public void resetSSHConfiguration() {
+ // server config
+ configUI.getSshServerField().setText(IsisFish.config.getSimulatorSshServer());
+ configUI.getUsernameField().setText(IsisFish.config.getSimulatorSshUsername());
+ configUI.getSshKeyField().setText(IsisFish.config.getSSHPrivateKeyFilePath().getAbsolutePath());
+
+ // caparmor config
+ configUI.getSshUserhomeField().setText(IsisFish.config.getSimulatorSshUserHome());
+ configUI.getSshDatapathField().setText(IsisFish.config.getSimulatorSshDataPath());
+ configUI.getSshIsisHomeField().setText(IsisFish.config.getSimulatorSshIsisHome());
+ configUI.getSshTemppathField().setText(IsisFish.config.getSimulatorSshTmpPath());
+ configUI.getSshJavaPathField().setText(IsisFish.config.getSimulatorSshJavaPath());
+ configUI.getSshPbsBinPathField().setText(IsisFish.config.getSimulatorSshPbsBinPath());
+ configUI.getSshPbsQsubOptionsField().setText(IsisFish.config.getSimulatorSshPbsQsubOptions());
+ configUI.getSshControlIntervalField().setText(String.valueOf(IsisFish.config.getSimulatorSshControlCheckInterval()));
+ configUI.getSshMaxThreadsField().setText(String.valueOf(IsisFish.config.getSimulatorSshMaxThreads()));
+ configUI.getSshMaxMemoryField().setText(IsisFish.config.getSimulatorSshMaxMemory());
+
+ doCheck();
+ }
+
+ /**
+ * Reset display.
+ */
+ protected void configurationChanged() {
+
+ configUI.setConnected(false);
+ configUI.getMessageLabel().setText("");
+ configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", "isis-database", "0"));
+ configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", "isis-tmp", "0"));
+
+ }
+
+ /**
+ * Check input format validity.
+ */
+ public void doCheck() {
+
+ configurationChanged();
+
+ // copy values
+ currentSSHserver = configUI.getSshServerField().getText().trim();
+ if (currentSSHserver.isEmpty()) {
+ setColor(true, configUI.getSshServerField());
+ } else {
+ setColor(false, configUI.getSshServerField());
+ }
+
+ // copy values
+ //currentSSHsftpServer = configUI.getSshSftpServerField().getText().trim();
+
+ // can be empty (optionnal use)
+ currentSSHUsername = configUI.getUsernameField().getText().trim();
+ if (!currentSSHUsername.matches("\\w+")) {
+ setColor(true, configUI.getUsernameField());
+ } else {
+ setColor(false, configUI.getUsernameField());
+ }
+
+ // if ssh key is set, must be a valid file
+ currentSSHKey = new File(configUI.getSshKeyField().getText().trim());
+ if (!currentSSHKey.isFile()) {
+ setColor(true, configUI.getSshKeyField());
+ } else {
+ configUI.getSshKeyButton().setEnabled(false);
+ configUI.getSshKeyField().setEnabled(false);
+ setColor(false, configUI.getSshKeyField());
+ }
+
+ currentSSHDatapath = configUI.getSshDatapathField().getText().trim();
+ if (currentSSHDatapath.isEmpty()) {
+ setColor(true, configUI.getSshDatapathField());
+ } else {
+ setColor(false, configUI.getSshDatapathField());
+ }
+
+ currentSSHIsisHome = configUI.getSshIsisHomeField().getText().trim();
+ if (currentSSHIsisHome.isEmpty()) {
+ setColor(true, configUI.getSshIsisHomeField());
+ } else {
+ setColor(false, configUI.getSshIsisHomeField());
+ }
+
+ currentSSHTempPath = configUI.getSshTemppathField().getText().trim();
+ if (currentSSHTempPath.isEmpty()) {
+ setColor(true, configUI.getSshTemppathField());
+ } else {
+ setColor(false, configUI.getSshTemppathField());
+ }
+
+ currentSSHJavaPath = configUI.getSshJavaPathField().getText().trim();
+ if (currentSSHJavaPath.isEmpty()) {
+ setColor(true, configUI.getSshJavaPathField());
+ } else {
+ setColor(false, configUI.getSshJavaPathField());
+ }
+
+ currentSSHPbsBinPath = configUI.getSshPbsBinPathField().getText()
+ .trim();
+ if (currentSSHPbsBinPath.isEmpty()) {
+ setColor(true, configUI.getSshPbsBinPathField());
+ } else {
+ setColor(false, configUI.getSshPbsBinPathField());
+ }
+
+ // currentSSHPbsQsubOptions
+ currentSSHPbsQsubOptions = configUI.getSshPbsQsubOptionsField().getText().trim();
+
+ // currentSSHMaxThreads
+ currentSSHMaxThreads = configUI.getSshMaxThreadsField().getText().trim();
+ if (!currentSSHMaxThreads.matches("\\d+")) {
+ setColor(true, configUI.getSshMaxThreadsField());
+ } else {
+ setColor(false, configUI.getSshMaxThreadsField());
+ }
+
+ // currentSSHMaxMemory
+ currentSSHMaxMemory = configUI.getSshMaxMemoryField().getText().trim();
+
+ // currentSSHControlInterval
+ currentSSHControlInterval = configUI.getSshControlIntervalField()
+ .getText().trim();
+ if (!currentSSHControlInterval.matches("\\d+")) {
+ setColor(true, configUI.getSshControlIntervalField());
+ } else {
+ setColor(false, configUI.getSshControlIntervalField());
+ }
+ }
+
+ /**
+ * Set values in config and force configuration save.
+ */
+ public void saveSSHConfiguration() {
+ IsisFish.config.setSimulatorSshServer(currentSSHserver);
+ //IsisFish.config.setSimulatorSshSftpServer(currentSSHsftpServer);
+ IsisFish.config.setSimulatorSshUsername(currentSSHUsername);
+ IsisFish.config.setSSHPrivateKeyFilePath(currentSSHKey);
+
+ IsisFish.config.setSimulatorSshUserHome(currentSSHUserhome);
+ IsisFish.config.setSimulatorSshDataPath(currentSSHDatapath);
+ IsisFish.config.setSimulatorSshIsisHome(currentSSHIsisHome);
+ IsisFish.config.setSimulatorSshTmpPath(currentSSHTempPath);
+ IsisFish.config.setSimulatorSshJavaPath(currentSSHJavaPath);
+ IsisFish.config.setSimulatorSshPbsBinPath(currentSSHPbsBinPath);
+ IsisFish.config.setSimulatorSshPbsQsubOptions(currentSSHPbsQsubOptions);
+ IsisFish.config.setSimulatorSshControlCheckInterval(Integer.parseInt(currentSSHControlInterval));
+ IsisFish.config.setSimulatorSshMaxThreads(Integer.parseInt(currentSSHMaxThreads));
+ IsisFish.config.setSimulatorSshMaxMemory(currentSSHMaxMemory);
+
+ IsisFish.config.saveForUser();
+ configUI.dispose();
+ }
+
+ /**
+ * Close frame.
+ */
+ public void cancelSSHConfiguration() {
+ configUI.dispose();
+ }
+
+ /**
+ * Realise une connexion ssh et teste les données.
+ */
+ public void testSSHConfiguration() {
+ JSch jsch = new JSch();
+
+ String host = currentSSHserver;
+ int port = 22; // by default, 22
+ String sPort = null;
+
+ try {
+ if (host.indexOf(':') > 0) {
+ sPort = host.substring(host.indexOf(':') + 1);
+ port = Integer.parseInt(sPort);
+ host = host.substring(0, host.indexOf(':'));
+ }
+
+ // add ssh key
+ boolean sshKeyUsed = false;
+ if (currentSSHKey.canRead()) {
+ if (log.isInfoEnabled()) {
+ log.info(t("Ssh key found '%s' will be used to connect to",
+ currentSSHKey.getAbsoluteFile(), host));
+ }
+ jsch.addIdentity(currentSSHKey.getAbsolutePath());
+ sshKeyUsed = true;
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info(t("Can't read ssh key : %s", currentSSHKey));
+ }
+ }
+
+ Session session = jsch.getSession(currentSSHUsername, host, port);
+ String proxyCommand = IsisFish.config.getSimulatorSshProxyCommand();
+ if (StringUtils.isNotBlank(proxyCommand)) {
+ session.setProxy(new ProxyCommand(proxyCommand));
+ }
+
+ // username and password will be given via UserInfo interface.
+ SSHUserInfo ui = new SSHUserInfo();
+ if (sshKeyUsed) {
+ char[] passchars = SSHAgent.getAgent().getPassphrase(currentSSHKey);
+ String passphrase = String.valueOf(passchars);
+ ui.setPassphrase(passphrase);
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connectingpk"), false);
+ } else {
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connecting"), false);
+ }
+ session.setUserInfo(ui);
+ session.connect(10000); // timeout
+
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connectionok"), false);
+
+ // get user home
+ currentSSHUserhome = getUserHomeDirectory(session);
+ configUI.getSshUserhomeField().setText(currentSSHUserhome);
+ // get space disk
+ String databaseSize = getFolderSize(session, currentSSHDatapath);
+ String temppathSize = getFolderSize(session, currentSSHTempPath);
+ configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHDatapath, databaseSize));
+ configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHTempPath, temppathSize));
+ session.disconnect();
+
+ configUI.setConnected(true);
+ } catch (NumberFormatException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't connect", e);
+ }
+ setTestMessage(t("isisfish.error.simulation.remote.wrongportvalue",
+ sPort), true);
+ } catch (JSchException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't connect", e);
+ }
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e
+ .getMessage()), true);
+ } catch (SSHException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't connect", e);
+ }
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e
+ .getMessage()), true);
+ } catch (InvalidPassphraseException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't connect", e);
+ }
+ setTestMessage(
+ t("isisfish.simulator.ssh.configuration.invalidpassphrase"),
+ true);
+ }
+ }
+
+ /**
+ * Get user home directory with an opened session.
+ *
+ * @param session opened session
+ * @return 'pwd' result
+ * @throws SSHException
+ */
+ protected String getUserHomeDirectory(Session session) throws SSHException {
+
+ String command = "pwd";
+
+ Writer output = new StringWriter();
+ int exit = SSHUtils.exec(session, command, output);
+
+ if (exit != 0) {
+ throw new SSHException(t("Command '%s' fail to execute", command));
+ }
+
+ String out = output.toString();
+ return out;
+ }
+
+ /**
+ * Get user home directory with an opened session.
+ *
+ * @param session opened session
+ * @param path path to get size
+ * @return dir size
+ * @throws SSHException
+ */
+ protected String getFolderSize(Session session, String path) throws SSHException {
+
+ String command = "du -hs \"" + path + "\"";
+
+ Writer output = new StringWriter();
+ SSHUtils.exec(session, command, output);
+
+ // la sortie est "35Go isisdatabase-3"
+ String out = output.toString();
+ out = out.split("\\s+")[0];
+ return out;
+ }
+
+ /**
+ * Clear database.
+ */
+ public void clearDatabase() {
+ clearFolder(currentSSHDatapath);
+ }
+
+ /**
+ * Clear temp directory.
+ */
+ public void clearTempDirectory() {
+ clearFolder(currentSSHTempPath);
+ }
+
+ /**
+ * Clear specified directory.
+ *
+ * @param path path to clear
+ */
+ protected void clearFolder(String path) {
+
+ // prevent, for home deletion, can happens :D
+ if (StringUtils.isEmpty(path) || path.trim().equals(".")) {
+ throw new IllegalArgumentException("Can't delete directory : " + path);
+ }
+
+ int response = JOptionPane.showConfirmDialog(configUI, t("isisfish.simulator.ssh.configuration.freespace.confirmdelete", path),
+ t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ JSch jsch = new JSch();
+
+ String host = currentSSHserver;
+ int port = 22; // by default, 22
+ String sPort = null;
+
+ try {
+ if (host.indexOf(':') > 0) {
+ sPort = host.substring(host.indexOf(':') + 1);
+ port = Integer.parseInt(sPort);
+ host = host.substring(0, host.indexOf(':'));
+ }
+
+ // add ssh key
+ boolean sshKeyUsed = false;
+ if (currentSSHKey.canRead()) {
+ if (log.isInfoEnabled()) {
+ log.info(t("Ssh key found '%s' will be used to connect to",
+ currentSSHKey.getAbsoluteFile(), host));
+ }
+ jsch.addIdentity(currentSSHKey.getAbsolutePath());
+ sshKeyUsed = true;
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info(t("Can't read ssh key : %s", currentSSHKey));
+ }
+ }
+
+ Session session = jsch.getSession(currentSSHUsername, host, port);
+ String proxyCommand = IsisFish.config.getSimulatorSshProxyCommand();
+ if (StringUtils.isNotBlank(proxyCommand)) {
+ session.setProxy(new ProxyCommand(proxyCommand));
+ }
+
+ // username and password will be given via UserInfo interface.
+ SSHUserInfo ui = new SSHUserInfo();
+ if (sshKeyUsed) {
+ char[] passchars = SSHAgent.getAgent().getPassphrase(currentSSHKey);
+ String passphrase = String.valueOf(passchars);
+ ui.setPassphrase(passphrase);
+ }
+ session.setUserInfo(ui);
+ session.connect(10000); // timeout
+
+ String command = "rm -rf \"" + path + "\"";
+
+ if (log.isDebugEnabled()) {
+ log.debug("Removing folder with command : " + command);
+ }
+ Writer output = new StringWriter();
+ int exit = SSHUtils.exec(session, command, output);
+
+ // get space disk
+ String databaseSize = getFolderSize(session, currentSSHDatapath);
+ String temppathSize = getFolderSize(session, currentSSHTempPath);
+ configUI.getStatusFreeDatabaseLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHDatapath, databaseSize));
+ configUI.getStatusFreeTempLabel().setText(t("isisfish.simulator.ssh.configuration.freespace.label", currentSSHTempPath, temppathSize));
+ session.disconnect();
+
+ session.disconnect();
+ if (exit != 0) {
+ throw new SSHException(t("Command '%s' fail to execute", command));
+ }
+ }
+ catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't connect", e);
+ }
+ setTestMessage(t("isisfish.simulator.ssh.configuration.connectionerror", e.getMessage()), true);
+ }
+ }
+ else {
+ if (log.isInfoEnabled()) {
+ log.info("Delete action canceled by user");
+ }
+ }
+ }
+
+ /**
+ * Generate new SSH key.
+ */
+ protected void generateSSHKey() {
+ if (currentSSHKey.exists()) {
+ throw new IllegalArgumentException("Can't overwrite ssh key");
+ }
+
+ try {
+ // make parent dir
+ if (currentSSHKey.getParentFile() != null
+ && !currentSSHKey.getParentFile().exists()) {
+ currentSSHKey.getParentFile().mkdirs();
+ }
+ JSch jsch = new JSch();
+ KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 2048);
+ //kpair.setPassphrase(passphrase);
+ kpair.writePrivateKey(currentSSHKey.getAbsolutePath());
+ kpair.writePublicKey(currentSSHKey.getAbsolutePath() + ".pub",
+ currentSSHUsername + "@forIsisFish");
+ if (log.isInfoEnabled()) {
+ log.info("Finger print: " + kpair.getFingerPrint());
+ }
+ kpair.dispose();
+ } catch (JSchException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't make ssh key", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't make ssh key", e);
+ }
+ }
+
+ // refresh ckeck
+ doCheck();
+ }
+
+ /**
+ * Set color depending of field validity.
+ *
+ *
+ * @param invalid valid field
+ * @param component component to set color
+ */
+ protected void setColor(boolean invalid, JComponent component) {
+ component.setForeground(invalid ? Color.RED : Color.BLACK);
+ }
+
+ /**
+ * Set message in message field with status color.
+ *
+ * @param message message to display
+ * @param error error status
+ */
+ protected void setTestMessage(String message, boolean error) {
+ configUI.getMessageLabel().setForeground(
+ error ? Color.RED : Color.GREEN.darker());
+ configUI.getMessageLabel().setText(message);
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -24,19 +24,21 @@
-->
<JDialog resizable="false" title="isisfish.simulator.ssh.configuration.title"
layout="{new javax.swing.BoxLayout(this.getContentPane(), javax.swing.BoxLayout.PAGE_AXIS)}">
+
+ <SSHLauncherConfigHandler id="handler" constructorParams='this' />
+
<import>
static org.nuiton.i18n.I18n.t
</import>
- <SSHLauncherConfigAction id="action" javaBean="new SSHLauncherConfigAction(this)" />
+
<Boolean id="connected" javaBean="false" />
<script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
+ ]]></script>
- // fill default values
- getAction().resetSSHConfiguration();
-
- ]]></script>
-
<Table border='{BorderFactory.createTitledBorder(t("isisfish.simulator.ssh.configuration.connection"))}'
fill='horizontal'>
<row>
@@ -46,7 +48,7 @@
</cell>
<cell fill='horizontal' columns="2">
<JTextField id='sshServerField' toolTipText='isisfish.config.main.simulation.ssh.server.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -56,7 +58,7 @@
</cell>
<cell columns="2">
<JTextField id='usernameField' toolTipText='isisfish.config.main.simulation.ssh.username.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -65,10 +67,10 @@
</cell>
<cell weightx="2.0">
<JTextField id='sshKeyField' toolTipText='isisfish.config.ssh.key.file.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
<cell>
- <JButton id='sshKeyButton' text='isisfish.simulator.ssh.configuration.keygenerate' onActionPerformed="getAction().generateSSHKey()" />
+ <JButton id='sshKeyButton' text='isisfish.simulator.ssh.configuration.keygenerate' onActionPerformed="handler.generateSSHKey()" />
</cell>
</row>
</Table>
@@ -80,7 +82,7 @@
</cell>
<cell weightx="1.0">
<JTextField id='sshUserhomeField' enabled='false' toolTipText='isisfish.config.main.simulation.ssh.userhome.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -90,7 +92,7 @@
</cell>
<cell weightx="1.0">
<JTextField id='sshDatapathField' toolTipText='isisfish.config.main.simulation.ssh.datapath.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -100,7 +102,7 @@
</cell>
<cell>
<JTextField id='sshIsisHomeField' toolTipText='isisfish.config.main.simulation.ssh.isis.home.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -110,7 +112,7 @@
</cell>
<cell>
<JTextField id='sshTemppathField' toolTipText='isisfish.config.main.simulation.ssh.tmppath.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -121,7 +123,7 @@
<cell>
<JTextField id='sshJavaPathField'
toolTipText='isisfish.config.main.simulation.ssh.javapath.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -132,7 +134,7 @@
<cell>
<JTextField id='sshPbsBinPathField'
toolTipText='isisfish.config.main.simulation.ssh.pbsbinpath.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -143,7 +145,7 @@
<cell>
<JTextField id='sshPbsQsubOptionsField'
toolTipText='isisfish.config.main.simulation.ssh.pbsqsuboptions.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -154,7 +156,7 @@
<cell>
<JTextField id='sshMaxThreadsField'
toolTipText='isisfish.config.main.simulation.ssh.max.threads.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -165,7 +167,7 @@
<cell>
<JTextField id='sshMaxMemoryField'
toolTipText='isisfish.config.main.simulation.ssh.max.memory.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
<row fill='horizontal'>
@@ -176,23 +178,23 @@
<cell>
<JTextField id='sshControlIntervalField'
toolTipText='isisfish.config.main.simulation.ssh.control.check.interval.description'
- onKeyReleased="getAction().doCheck()" />
+ onKeyReleased="handler.doCheck()" />
</cell>
</row>
</Table>
<Table>
<row fill='horizontal'>
<cell fill='horizontal' weightx="1.0">
- <JButton id='testButton' text='isisfish.simulator.ssh.configuration.test' onActionPerformed="getAction().testSSHConfiguration()" icon="connect.png" />
+ <JButton id='testButton' text='isisfish.simulator.ssh.configuration.test' onActionPerformed="handler.testSSHConfiguration()" icon="connect.png" />
</cell>
<cell fill='horizontal' weightx="1.0">
- <JButton id='validButton' text='isisfish.common.valid' onActionPerformed="getAction().saveSSHConfiguration()" icon="accept.png" enabled='{isConnected()}' />
+ <JButton id='validButton' text='isisfish.common.valid' onActionPerformed="handler.saveSSHConfiguration()" icon="accept.png" enabled='{isConnected()}' />
</cell>
<cell fill='horizontal' weightx="1.0">
- <JButton id='resetButton' text='isisfish.common.reset' onActionPerformed="getAction().resetSSHConfiguration()" icon="arrow_undo.png" />
+ <JButton id='resetButton' text='isisfish.common.reset' onActionPerformed="handler.resetSSHConfiguration()" icon="arrow_undo.png" />
</cell>
<cell fill='horizontal' weightx="1.0">
- <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed="getAction().cancelSSHConfiguration()" icon="cancel.png" />
+ <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed="handler.cancelSSHConfiguration()" icon="cancel.png" />
</cell>
</row>
</Table>
@@ -214,7 +216,7 @@
</cell>
<cell>
<JButton id='clearDatabaseButton' text='isisfish.common.clear' icon="paintbrush.png"
- onActionPerformed="getAction().clearDatabase()" enabled='{isConnected()}' />
+ onActionPerformed="handler.clearDatabase()" enabled='{isConnected()}' />
</cell>
</row>
<row fill='horizontal'>
@@ -223,7 +225,7 @@
</cell>
<cell>
<JButton id='clearTempButton' text='isisfish.common.clear' icon="paintbrush.png"
- onActionPerformed="getAction().clearTempDirectory()" enabled='{isConnected()}' />
+ onActionPerformed="handler.clearTempDirectory()" enabled='{isConnected()}' />
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -32,8 +32,8 @@
import org.nuiton.topia.persistence.TopiaEntityContextable;
import fr.ifremer.isisfish.ui.CommonHandler;
+import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardHandler;
import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI;
-import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler;
/**
* Common handler for all input ui.
@@ -87,7 +87,7 @@
if (bean != null) {
FactorWizardUI factorWizardUI = new FactorWizardUI(inputContentUI);
- SensitivityWizardHandler handler = factorWizardUI.getHandler();
+ FactorWizardHandler handler = factorWizardUI.getHandler();
handler.initNewFactor(factorWizardUI, bean, sensitivityMethod);
factorWizardUI.pack();
factorWizardUI.setLocationRelativeTo(inputContentUI);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -39,7 +39,7 @@
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputUI;
/**
* Cell handler.
@@ -114,11 +114,10 @@
InputUI inputUI = inputContentUI.getParentContainer(InputUI.class);
if (inputUI != null) {
inputUI.getHandler().setTreeSelection(this.inputContentUI, c.getTopiaId());
+ } else {
+ SensitivityInputUI sensitivityInputUI = inputContentUI.getParentContainer(SensitivityInputUI.class);
+ sensitivityInputUI.getHandler().setTreeSelection(this.inputContentUI, c.getTopiaId());
}
- else {
- SensitivityTabUI sensitivityTabUI = inputContentUI.getParentContainer(SensitivityTabUI.class);
- sensitivityTabUI.getHandler().setTreeSelection(this.inputContentUI, c.getTopiaId());
- }
}
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -75,12 +75,16 @@
protected SimulationServiceListener listener = null;
+ protected ResultUI resultUI;
+
+ public ResultHandler(ResultUI resultUI) {
+ this.resultUI = resultUI;
+ }
+
/**
* Initialise la vue avec les liste des simulations disponible.
- *
- * @param resultUI
*/
- public void init(final ResultUI resultUI) {
+ public void afterInit() {
initSimulationList(resultUI);
// reference must stay allocated
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -33,8 +33,6 @@
}
}
]]></script>
-
- <ResultHandler id="handler"/>
<fr.ifremer.isisfish.datastore.SimulationStorage id="simulationStorage" javaBean="null"/>
<fr.ifremer.isisfish.entities.FisheryRegion id="fisheryRegion" javaBean="null"/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -24,13 +24,14 @@
-->
<JPanel layout='{new BorderLayout()}'>
- <ResultHandler id="handler" />
+ <ResultHandler id="handler" constructorParams='this' />
<script><![CDATA[
protected void $afterCompleteSetup() {
- getHandler().init(this);
+ handler.afterInit();
}
]]></script>
+
<Table constraints="BorderLayout.NORTH">
<row>
<cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,229 @@
+package fr.ifremer.isisfish.ui.sensitivity;
+
+import java.awt.CardLayout;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.table.DefaultTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
+import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.StorageChangeEvent;
+import fr.ifremer.isisfish.datastore.StorageChangeListener;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.simulator.sensitivity.Domain;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel;
+import fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportListRenderer;
+import fr.ifremer.isisfish.ui.sensitivity.model.FactorCardinalityTableModel;
+import fr.ifremer.isisfish.ui.simulator.SimulAction;
+
+public class SensitivityChooserHandler {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(SensitivityInputHandler.class);
+
+ protected SensitivityChooserUI sensitivityChooserUI;
+
+ protected StorageChangeListener sensitivityAnalysisListener;
+ protected StorageChangeListener sensitivityExportListener;
+
+ public SensitivityChooserHandler(SensitivityChooserUI sensitivityChooserUI) {
+ this.sensitivityChooserUI = sensitivityChooserUI;
+ }
+
+ protected void afterInit() {
+ // listener to listen for modification on sensitivity analysis
+ sensitivityAnalysisListener = new StorageChangeListener() {
+ @Override
+ public void versionDataChanged(StorageChangeEvent e) {
+ sensitivityChooserUI.fieldSensitivityAnalysisSelect.setModel(getSensitivityAnalysisModel());
+ }
+ };
+ SensitivityAnalysisStorage.addStorageChangeListener(sensitivityAnalysisListener);
+
+ // listener to listen for modification on sensitivity exports
+ sensitivityExportListener = new StorageChangeListener() {
+ @Override
+ public void versionDataChanged(StorageChangeEvent e) {
+ sensitivityChooserUI.availableSensitivityExports.setModel(getAvailableExportListModel());
+ }
+ };
+ SensitivityExportStorage.addStorageChangeListener(sensitivityExportListener);
+ }
+
+ @Deprecated
+ protected SimulAction getSimulAction() {
+ return sensitivityChooserUI.getContextValue(SimulAction.class);
+ }
+
+ public ComboBoxModel<String> getSensitivityAnalysisModel() {
+ List<String> sensitivityNames = getSimulAction().getSensitivityAnalysisNames();
+ GenericComboModel<String> model = new GenericComboModel<>(sensitivityNames);
+ return model;
+ }
+
+ /**
+ * Auto select analysis in JComboBox
+ * with analysis selected in SimulAction.
+ *
+ * Used by "reloadOldSimulation" operation.
+ */
+ public void refreshSelectedSensitivityAnalysis() {
+ SensitivityAnalysis sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
+ if (sensitivityAnalysis != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Refreshing sensitivity analysis list");
+ }
+ // TODO it's not getSimpleName() here !
+ sensitivityChooserUI.fieldSensitivityAnalysisSelect.setSelectedItem(sensitivityAnalysis.getClass().getSimpleName());
+ }
+ }
+
+ protected void sensitivityAnalysisChanged() {
+
+ String sensitivityName = (String)sensitivityChooserUI.fieldSensitivityAnalysisSelect.getSelectedItem();
+
+ // when analysis is changed by refreshSelectedSensitivityAnalysis
+ // this event is thrown by build a new Analysis instance
+ // and parameter are lost
+ // fix it with a small class name test
+ SensitivityAnalysis sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
+ if (sensitivityAnalysis != null && sensitivityAnalysis.getClass().getSimpleName().equals(sensitivityName)) {
+ sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
+ } else {
+ sensitivityAnalysis = getSimulAction().getSensitivityAnalysisInstance(sensitivityName);
+ }
+
+ // can be null for example if analysis can't be compiled
+ if (sensitivityAnalysis != null) {
+ getSimulAction().setSensitivityAnalysis(sensitivityAnalysis);
+
+ CardLayout factorPanelLayout = (CardLayout)sensitivityChooserUI.factorCardinalityPanel.getLayout();
+ if (sensitivityAnalysis.canManageCardinality()) {
+ factorPanelLayout.show(sensitivityChooserUI.factorCardinalityPanel, "factorCardinalitySupported");
+ } else {
+ factorPanelLayout.show(sensitivityChooserUI.factorCardinalityPanel, "factorCardinalityNotSupported");
+ }
+
+ // update model
+ ScriptParametersTableModel parametersTableModel = new ScriptParametersTableModel(sensitivityAnalysis);
+ sensitivityChooserUI.simulSensitivityAnalysisParam.setModel(parametersTableModel);
+ sensitivityChooserUI.simulSensitivityAnalysisParam.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(sensitivityAnalysis));
+ sensitivityChooserUI.simulSensitivityAnalysisParam.getColumnModel().getColumn(1).setCellEditor(new ScriptParametersTableCellEditor(sensitivityAnalysis));
+ }
+ }
+
+ public void setFactorCardinalityTableModel() {
+ List<Factor> factors = getSimulAction().getFactorGroup().getFactors();
+ List<Factor> factorsContinue = new ArrayList<Factor>();
+ /* get sublist with only Continous factor */
+ for (Factor f : factors) {
+ Domain domain = f.getDomain();
+ if (ContinuousDomain.class.isInstance(domain)) {
+ ContinuousDomain continuousDomain = (ContinuousDomain)domain;
+ factorsContinue.add(f);
+ }
+ }
+ FactorCardinalityTableModel model = new FactorCardinalityTableModel(factorsContinue);
+ sensitivityChooserUI.factorCardinality.setModel(model);
+ }
+
+ protected GenericListModel<String> getAvailableExportListModel() {
+ List<String> exportNames = getSimulAction().getSensitivityExportNames();
+ GenericListModel<String> model = new GenericListModel<>(exportNames);
+ return model;
+ }
+
+ /**
+ * Add multiples export.
+ *
+ * Export name can be duplicated.
+ */
+ protected void addExports() {
+ List<String> exportNames = sensitivityChooserUI.availableSensitivityExports.getSelectedValuesList();
+ for (String exportName : exportNames) {
+ getSimulAction().addSensitivityExport(sensitivityChooserUI, exportName);
+ }
+ setSensitivityExportListModel();
+ }
+
+ /**
+ * Remove multiple export.
+ */
+ protected void removeExports() {
+ List<SensitivityExport> exports = sensitivityChooserUI.selectedSensitivityExports.getSelectedValuesList();
+ for (SensitivityExport export : exports) {
+ getSimulAction().removeSensitivityExport(export);
+ }
+ setSensitivityExportListModel();
+ }
+
+ /**
+ * Clear all export.
+ */
+ protected void clearExports() {
+ getSimulAction().clearSensitivityExport();
+ setSensitivityExportListModel();
+ }
+
+ /**
+ * Set model (refresh export JList).
+ */
+ public void setSensitivityExportListModel() {
+ List<SensitivityExport> exports = getSimulAction().getSensitivityExports();
+ GenericListModel<SensitivityExport> model = new GenericListModel<>(exports);
+ sensitivityChooserUI.selectedSensitivityExports.setModel(model);
+ sensitivityChooserUI.selectedSensitivityExports.setCellRenderer(new SensitivityExportListRenderer());
+
+ sensitivityChooserUI.clearExportsButton.setEnabled(!exports.isEmpty());
+ }
+
+ /**
+ * When selection change on available export list.
+ */
+ protected void availableSensitivityExportSelection() {
+ sensitivityChooserUI.addExportButton.setEnabled(sensitivityChooserUI.availableSensitivityExports.getSelectedIndices().length != 0);
+ }
+
+ /**
+ * When selection change on choosen export list.
+ */
+ protected void selectedSensitivityExportSelection() {
+ if (log.isDebugEnabled()) {
+ log.debug("Sensitivity export selection change");
+ }
+ setExportParams();
+ sensitivityChooserUI.removeExportButton.setEnabled(sensitivityChooserUI.selectedSensitivityExports.getSelectedIndices().length != 0);
+ }
+
+ /**
+ * Fill export parameters names and values in table.
+ */
+ protected void setExportParams() {
+ SimulAction simulAction = sensitivityChooserUI.getContextValue(SimulAction.class);
+
+ if (sensitivityChooserUI.selectedSensitivityExports.getSelectedIndices().length == 1) {
+ SensitivityExport export = (SensitivityExport)sensitivityChooserUI.selectedSensitivityExports.getSelectedValue();
+ ScriptParametersTableModel model = new ScriptParametersTableModel(export);
+ sensitivityChooserUI.exportParamsTable.setModel(model);
+ sensitivityChooserUI.exportParamsTable.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(export));
+ ScriptParametersTableCellEditor cellEditor = new ScriptParametersTableCellEditor(export);
+ cellEditor.setRegionStorage(sensitivityChooserUI.getContextValue(RegionStorage.class));
+ sensitivityChooserUI.exportParamsTable.getColumnModel().getColumn(1).setCellEditor(cellEditor);
+ } else {
+ sensitivityChooserUI.exportParamsTable.setModel(new DefaultTableModel());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -23,227 +23,22 @@
#L%
-->
<Table>
- <import>
- java.awt.CardLayout
- javax.swing.ComboBoxModel
- javax.swing.table.DefaultTableModel
- fr.ifremer.isisfish.datastore.RegionStorage
- fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage
- fr.ifremer.isisfish.datastore.SensitivityExportStorage
- fr.ifremer.isisfish.datastore.StorageChangeEvent
- fr.ifremer.isisfish.datastore.StorageChangeListener
- fr.ifremer.isisfish.export.SensitivityExport
- fr.ifremer.isisfish.simulator.sensitivity.Domain
- fr.ifremer.isisfish.simulator.sensitivity.Factor
- fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis
- fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportListRenderer
- fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportNameListRenderer
- fr.ifremer.isisfish.ui.models.sensitivityanalysis.SensitivityAnalysisComboRenderer
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel
- fr.ifremer.isisfish.ui.sensitivity.model.FactorCardinalityTableModel
- fr.ifremer.isisfish.ui.simulator.SimulAction
- </import>
+ <SensitivityChooserHandler id="handler" constructorParams='this' />
- <script><![CDATA[
-
- // listener to listen for modification on sensitivity analysis
- StorageChangeListener sensitivityAnalysisListener;
- sensitivityAnalysisListener = new StorageChangeListener() {
- @Override
- public void versionDataChanged(StorageChangeEvent e) {
- fieldSensitivityAnalysisSelect.setModel(getSensitivityAnalysisModel());
- }
- };
- SensitivityAnalysisStorage.addStorageChangeListener(sensitivityAnalysisListener);
-
- // listener to listen for modification on sensitivity exports
- StorageChangeListener sensitivityExportListener;
- sensitivityExportListener = new StorageChangeListener() {
- @Override
- public void versionDataChanged(StorageChangeEvent e) {
- availableSensitivityExports.setModel(getAvailableExportListModel());
- }
- };
- SensitivityExportStorage.addStorageChangeListener(sensitivityExportListener);
-
-
- protected SimulAction getSimulAction() {
- return getContextValue(SimulAction.class);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
}
-
- public ComboBoxModel<String> getSensitivityAnalysisModel() {
- List<String> sensitivityNames = getSimulAction().getSensitivityAnalysisNames();
- GenericComboModel<String> model = new GenericComboModel<>(sensitivityNames);
- return model;
- }
-
- /**
- * Auto select analysis in JComboBox
- * with analysis selected in SimulAction.
- *
- * Used by "reloadOldSimulation" operation.
- */
- public void refreshSelectedSensitivityAnalysis() {
- SensitivityAnalysis sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
- if (sensitivityAnalysis != null) {
- if (log.isDebugEnabled()) {
- log.debug("Refreshing sensitivity analysis list");
- }
- // TODO it's not getSimpleName() here !
- fieldSensitivityAnalysisSelect.setSelectedItem(sensitivityAnalysis.getClass().getSimpleName());
- }
- }
-
- protected void sensitivityAnalysisChanged() {
-
- String sensitivityName = (String)fieldSensitivityAnalysisSelect.getSelectedItem();
-
- // when analysis is changed by refreshSelectedSensitivityAnalysis
- // this event is thrown by build a new Analysis instance
- // and parameter are lost
- // fix it with a small class name test
- SensitivityAnalysis sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
- if (sensitivityAnalysis != null && sensitivityAnalysis.getClass().getSimpleName().equals(sensitivityName)) {
- sensitivityAnalysis = getSimulAction().getSensitivityAnalysis();
- } else {
- sensitivityAnalysis = getSimulAction().getSensitivityAnalysisInstance(sensitivityName);
- }
-
- // can be null for example if analysis can't be compiled
- if (sensitivityAnalysis != null) {
- getSimulAction().setSensitivityAnalysis(sensitivityAnalysis);
-
- CardLayout factorPanelLayout = (CardLayout)factorCardinalityPanel.getLayout();
- if (sensitivityAnalysis.canManageCardinality()) {
- factorPanelLayout.show(factorCardinalityPanel, "factorCardinalitySupported");
- } else {
- factorPanelLayout.show(factorCardinalityPanel, "factorCardinalityNotSupported");
- }
-
- // update model
- ScriptParametersTableModel parametersTableModel = new ScriptParametersTableModel(sensitivityAnalysis);
- simulSensitivityAnalysisParam.setModel(parametersTableModel);
- simulSensitivityAnalysisParam.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(sensitivityAnalysis));
- simulSensitivityAnalysisParam.getColumnModel().getColumn(1).setCellEditor(new ScriptParametersTableCellEditor(sensitivityAnalysis));
- }
- }
-
- public void setFactorCardinalityTableModel() {
- List<Factor> factors = getSimulAction().getFactorGroup().getFactors();
- List<Factor> factorsContinue = new ArrayList<Factor>();
- /* get sublist with only Continous factor */
- for (Factor f : factors) {
- Domain domain = f.getDomain();
- if (ContinuousDomain.class.isInstance(domain)) {
- ContinuousDomain continuousDomain = (ContinuousDomain)domain;
- factorsContinue.add(f);
- }
- }
- FactorCardinalityTableModel model = new FactorCardinalityTableModel(factorsContinue);
- factorCardinality.setModel(model);
- }
-
- protected GenericListModel<String> getAvailableExportListModel() {
- List<String> exportNames = getSimulAction().getSensitivityExportNames();
- GenericListModel<String> model = new GenericListModel<>(exportNames);
- return model;
- }
-
- /**
- * Add multiples export.
- *
- * Export name can be duplicated.
- */
- protected void addExports() {
- List<String> exportNames = availableSensitivityExports.getSelectedValuesList();
- for (String exportName : exportNames) {
- getSimulAction().addSensitivityExport(this, exportName);
- }
- setSensitivityExportListModel();
- }
-
- /**
- * Remove multiple export.
- */
- protected void removeExports() {
- List<SensitivityExport> exports = selectedSensitivityExports.getSelectedValuesList();
- for (SensitivityExport export : exports) {
- getSimulAction().removeSensitivityExport(export);
- }
- setSensitivityExportListModel();
- }
-
- /**
- * Clear all export.
- */
- protected void clearExports() {
- getSimulAction().clearSensitivityExport();
- setSensitivityExportListModel();
- }
-
- /**
- * Set model (refresh export JList).
- */
- public void setSensitivityExportListModel() {
- List<SensitivityExport> exports = getSimulAction().getSensitivityExports();
- GenericListModel<SensitivityExport> model = new GenericListModel<>(exports);
- selectedSensitivityExports.setModel(model);
- selectedSensitivityExports.setCellRenderer(new SensitivityExportListRenderer());
-
- clearExportsButton.setEnabled(!exports.isEmpty());
- }
-
- /**
- * When selection change on available export list.
- */
- protected void availableSensitivityExportSelection() {
- addExportButton.setEnabled(availableSensitivityExports.getSelectedIndices().length != 0);
- }
-
- /**
- * When selection change on choosen export list.
- */
- protected void selectedSensitivityExportSelection() {
- if (log.isDebugEnabled()) {
- log.debug("Sensitivity export selection change");
- }
- setExportParams();
- removeExportButton.setEnabled(selectedSensitivityExports.getSelectedIndices().length != 0);
- }
-
- /**
- * Fill export parameters names and values in table.
- */
- protected void setExportParams() {
- SimulAction simulAction = getContextValue(SimulAction.class);
-
- if (selectedSensitivityExports.getSelectedIndices().length == 1) {
- SensitivityExport export = (SensitivityExport)selectedSensitivityExports.getSelectedValue();
- ScriptParametersTableModel model = new ScriptParametersTableModel(export);
- exportParamsTable.setModel(model);
- exportParamsTable.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(export));
- ScriptParametersTableCellEditor cellEditor = new ScriptParametersTableCellEditor(export);
- cellEditor.setRegionStorage(getContextValue(RegionStorage.class));
- exportParamsTable.getColumnModel().getColumn(1).setCellEditor(cellEditor);
- }
- else {
- exportParamsTable.setModel(new DefaultTableModel());
- }
- }
]]></script>
+
<row>
<cell fill="horizontal">
<JLabel text="isisfish.sensitivity.select"/>
</cell>
<cell fill="horizontal" weightx="1.0">
- <JComboBox id="fieldSensitivityAnalysisSelect" model='{getSensitivityAnalysisModel()}'
- genericType="String"
- renderer='{new SensitivityAnalysisComboRenderer()}' onActionPerformed='sensitivityAnalysisChanged()'/>
+ <JComboBox id="fieldSensitivityAnalysisSelect" model='{handler.getSensitivityAnalysisModel()}'
+ genericType="String" onActionPerformed='handler.sensitivityAnalysisChanged()'
+ renderer='{new fr.ifremer.isisfish.ui.models.sensitivityanalysis.SensitivityAnalysisComboRenderer()}' />
</cell>
</row>
<row>
@@ -255,11 +50,12 @@
</row>
<row>
<cell columns="2" fill="both" weightx="1.0" weighty="1.0">
- <JPanel id="factorCardinalityPanel" layout="{new CardLayout()}">
+ <JPanel id="factorCardinalityPanel" layout="{new java.awt.CardLayout()}">
<JLabel text="isisfish.sensitivity.methodfactorsupported" horizontalAlignment="center"
border="{BorderFactory.createEtchedBorder()}" font-style="italic" constraints='"factorCardinalitySupported"'/>
<JScrollPane id="factorCardinalityScrollPane" constraints='"factorCardinalityNotSupported"'>
- <JTable id="factorCardinality" model="{new FactorCardinalityTableModel()}" rowHeight='24' />
+ <JTable id="factorCardinality" rowHeight='24'
+ model="{new fr.ifremer.isisfish.ui.sensitivity.model.FactorCardinalityTableModel()}" />
</JScrollPane>
</JPanel>
</cell>
@@ -276,26 +72,26 @@
<cell fill="both" weightx="0.5" weighty="1.0">
<JScrollPane>
<JList id="availableSensitivityExports" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- model='{getAvailableExportListModel()}' cellRenderer='{new SensitivityExportNameListRenderer()}'
- genericType="String"
- onValueChanged='availableSensitivityExportSelection()' />
+ model='{handler.getAvailableExportListModel()}'
+ cellRenderer='{new fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportNameListRenderer()}'
+ genericType="String" onValueChanged='handler.availableSensitivityExportSelection()' />
</JScrollPane>
</cell>
<cell fill="both" weighty="1.0">
<Table>
<row>
<cell fill="both">
- <JButton id="addExportButton" text="isisfish.common.add" enabled="false" onActionPerformed='addExports()' />
+ <JButton id="addExportButton" text="isisfish.common.add" enabled="false" onActionPerformed='handler.addExports()' />
</cell>
</row>
<row>
<cell fill="both">
- <JButton id="removeExportButton" text="isisfish.common.remove" enabled="false" onActionPerformed='removeExports()' />
+ <JButton id="removeExportButton" text="isisfish.common.remove" enabled="false" onActionPerformed='handler.removeExports()' />
</cell>
</row>
<row>
<cell fill="both">
- <JButton id="clearExportsButton" text="isisfish.common.clear" enabled="false" onActionPerformed='clearExports()' />
+ <JButton id="clearExportsButton" text="isisfish.common.clear" enabled="false" onActionPerformed='handler.clearExports()' />
</cell>
</row>
</Table>
@@ -304,7 +100,7 @@
<JScrollPane>
<JList id="selectedSensitivityExports" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
genericType="fr.ifremer.isisfish.export.SensitivityExport"
- onValueChanged='selectedSensitivityExportSelection()' />
+ onValueChanged='handler.selectedSensitivityExportSelection()' />
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -50,19 +50,23 @@
import org.nuiton.util.FileUtil;
import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.entities.FisheryRegion;
import fr.ifremer.isisfish.mexico.MexicoHelper;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
import fr.ifremer.isisfish.ui.NavigationHandler;
+import fr.ifremer.isisfish.ui.WelcomePanelUI;
import fr.ifremer.isisfish.ui.input.InputContentUI;
+import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeRenderer;
+import fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeModel;
+import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardHandler;
import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI;
-import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
/**
@@ -79,18 +83,66 @@
/** Class logger. */
private static Log log = LogFactory.getLog(SensitivityInputHandler.class);
+ protected SensitivityInputUI sensitivityInputUI;
+
+ public SensitivityInputHandler(SensitivityInputUI sensitivityInputUI) {
+ this.sensitivityInputUI = sensitivityInputUI;
+ }
+
+ protected void afterInit() {
+
+ }
+
+ @Deprecated
+ protected SimulAction getSimulAction() {
+ return sensitivityInputUI.getContextValue(SimulAction.class);
+ }
+
+ protected InputSaveVerifier getVerifier() {
+ return sensitivityInputUI.getContextValue(InputSaveVerifier.class);
+ }
+
+ protected RegionStorage getRegionStorage() {
+ return sensitivityInputUI.getContextValue(RegionStorage.class);
+ }
+
+ public void setTreeModel() {
+ if (sensitivityInputUI.getFisheryRegion() != null) {
+ sensitivityInputUI.getCardlayoutPrincipal().show(sensitivityInputUI.inputPanePrincipal,"normale");
+ sensitivityInputUI.setContextValue(sensitivityInputUI.getFisheryRegion());
+ loadFisheryRegionTree();
+ }
+ }
+
+ protected void setInfoText(String s) {
+ WelcomePanelUI root = sensitivityInputUI.getParentContainer(WelcomePanelUI.class);
+ root.setStatusMessage(s);
+ }
+
+ protected void regionNull() {
+ sensitivityInputUI.getCardlayoutPrincipal().show(sensitivityInputUI.inputPanePrincipal,"none");
+ DefaultTreeModel model = new DefaultTreeModel(null);
+ sensitivityInputUI.fisheryRegionTree.setModel(model);
+ }
+
+ public void setFactorModel() {
+ FactorGroup factorGroup = getSimulAction().getFactorGroup();
+ FactorTreeModel model = new FactorTreeModel(factorGroup);
+ sensitivityInputUI.factorsTree.setModel(model);
+ sensitivityInputUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().getHandler().setFactorCardinalityTableModel();
+ }
+
/**
*
- * @param sensitivityTabUI
*/
- public void loadFisheryRegionTree(SensitivityTabUI sensitivityTabUI) {
- FisheryRegion fisheryRegion = sensitivityTabUI.getFisheryRegion();
+ public void loadFisheryRegionTree() {
+ FisheryRegion fisheryRegion = sensitivityInputUI.getFisheryRegion();
if (fisheryRegion == null) {
// show empty region ui
- sensitivityTabUI.getCardlayoutPrincipal().show(sensitivityTabUI.getInputPanePrincipal(),"none");
+ sensitivityInputUI.getCardlayoutPrincipal().show(sensitivityInputUI.getInputPanePrincipal(),"none");
TreeModel model = new DefaultTreeModel(null);
- sensitivityTabUI.getFisheryRegionTree().setModel(model);
+ sensitivityInputUI.getFisheryRegionTree().setModel(model);
}
else {
// init tree model loader with fishery region
@@ -98,27 +150,26 @@
FisheryDataProvider dataProvider = new FisheryDataProvider(fisheryRegion);
treeHelper.setDataProvider(dataProvider);
TreeModel model = treeHelper.createTreeModel(fisheryRegion);
- sensitivityTabUI.getFisheryRegionTree().setModel(model);
- sensitivityTabUI.getFisheryRegionTree().setCellRenderer(new FisheryTreeRenderer(dataProvider));
- treeHelper.setUI(sensitivityTabUI.getFisheryRegionTree(), true, false, null);
+ sensitivityInputUI.getFisheryRegionTree().setModel(model);
+ sensitivityInputUI.getFisheryRegionTree().setCellRenderer(new FisheryTreeRenderer(dataProvider));
+ treeHelper.setUI(sensitivityInputUI.getFisheryRegionTree(), true, false, null);
// global context value : fisheryRegion, regionStorage, treeHelper
- sensitivityTabUI.setContextValue(fisheryRegion);
- sensitivityTabUI.setContextValue(treeHelper);
- sensitivityTabUI.setContextValue(model);
- sensitivityTabUI.setContextValue(fisheryRegion.getTopiaContext());
+ sensitivityInputUI.setContextValue(fisheryRegion);
+ sensitivityInputUI.setContextValue(treeHelper);
+ sensitivityInputUI.setContextValue(model);
+ sensitivityInputUI.setContextValue(fisheryRegion.getTopiaContext());
- sensitivityTabUI.getCardlayoutPrincipal().show(sensitivityTabUI.getInputPanePrincipal(),"normale");
+ sensitivityInputUI.getCardlayoutPrincipal().show(sensitivityInputUI.getInputPanePrincipal(),"normale");
}
}
/**
* Changement de selection dans l'arbre de la pecherie.
*
- * @param sensitivityTabUI
* @param event
*/
- public void nodeSelectionChanged(SensitivityTabUI sensitivityTabUI, TreeSelectionEvent event) {
+ public void nodeSelectionChanged(TreeSelectionEvent event) {
TreePath newTreePath = event.getNewLeadSelectionPath();
@@ -135,12 +186,12 @@
try {
if (isisTreeNode.isStaticNode()) {
- FisheryRegion fisheryRegion = sensitivityTabUI.getContextValue(FisheryRegion.class);
+ FisheryRegion fisheryRegion = sensitivityInputUI.getContextValue(FisheryRegion.class);
TopiaContext topiaContext = fisheryRegion.getTopiaContext();
topiaEntity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
}
- InputContentUI inputContentUI = getUIInstanceForBeanClass(internalClass, sensitivityTabUI);
+ InputContentUI inputContentUI = getUIInstanceForBeanClass(internalClass, sensitivityInputUI);
// mandatory set
inputContentUI.getSaveVerifier().reset(); // before set bean !!!
@@ -155,11 +206,11 @@
inputContentUI.setSensitivity(true);
// add initialized ui to panel
- sensitivityTabUI.getCardlayoutPrincipal().show(sensitivityTabUI.getInputPanePrincipal(), "normale");
- sensitivityTabUI.getInputPane().removeAll();
- sensitivityTabUI.getInputPane().add(inputContentUI, BorderLayout.CENTER);
- sensitivityTabUI.getInputPane().repaint();
- sensitivityTabUI.getInputPane().validate();
+ sensitivityInputUI.getCardlayoutPrincipal().show(sensitivityInputUI.getInputPanePrincipal(), "normale");
+ sensitivityInputUI.getInputPane().removeAll();
+ sensitivityInputUI.getInputPane().add(inputContentUI, BorderLayout.CENTER);
+ sensitivityInputUI.getInputPane().repaint();
+ sensitivityInputUI.getInputPane().validate();
} catch (Exception ex) {
throw new IsisFishRuntimeException("Can't display bean " + topiaId, ex);
}
@@ -170,36 +221,34 @@
/**
* Add new continuous factor group in factor tree.
*
- * @param sensitivityTabUI
* @param continuous continuous
*/
- public void addNewFactorGroup(SensitivityTabUI sensitivityTabUI, boolean continuous) {
- String factorName = JOptionPane.showInputDialog(sensitivityTabUI, t("isisfish.sensitivity.newfactorname"),
+ public void addNewFactorGroup(boolean continuous) {
+ String factorName = JOptionPane.showInputDialog(sensitivityInputUI, t("isisfish.sensitivity.newfactorname"),
t("isisfish.sensitivity.title"), JOptionPane.QUESTION_MESSAGE);
if (StringUtils.isNotBlank(factorName)) {
- FactorGroup rootFactorGroup = sensitivityTabUI.getSimulAction().getFactorGroup();
+ FactorGroup rootFactorGroup = getSimulAction().getFactorGroup();
FactorGroup factorGroup = new FactorGroup(factorName, continuous);
rootFactorGroup.addFactor(factorGroup);
- sensitivityTabUI.setFactorModel();
+ setFactorModel();
}
}
/**
* Move factors to another factorgroup.
*
- * @param sensitivityTabUI
* @param selectedFactorGroup
* @param movedFactors
*/
- public void moveFactor(SensitivityTabUI sensitivityTabUI, FactorGroup selectedFactorGroup, List<Factor> movedFactors) {
+ public void moveFactor(FactorGroup selectedFactorGroup, List<Factor> movedFactors) {
try {
// add all factors, to do first, throw
// exception if can't be done
selectedFactorGroup.addAllFactors(movedFactors);
// remove duplicated from factor group
- FactorGroup rootFactorGroup = sensitivityTabUI.getSimulAction().getFactorGroup();
+ FactorGroup rootFactorGroup = getSimulAction().getFactorGroup();
if (!rootFactorGroup.equals(selectedFactorGroup)) {
rootFactorGroup.removeAll(movedFactors);
}
@@ -212,9 +261,9 @@
}
}
}
- sensitivityTabUI.setFactorModel();
+ setFactorModel();
} catch (IllegalArgumentException ex) {
- JOptionPane.showMessageDialog(sensitivityTabUI, t("isisfish.sensitivity.moveillegal"),
+ JOptionPane.showMessageDialog(sensitivityInputUI, t("isisfish.sensitivity.moveillegal"),
t("isisfish.sensitivity.title"), JOptionPane.ERROR_MESSAGE);
}
}
@@ -227,10 +276,9 @@
* <li>right click : popup menu</li>
* </ul>
*
- * @param sensitivityTabUI ui
* @param e mouse event
*/
- public void factorsTreeMouseClicked(final SensitivityTabUI sensitivityTabUI, MouseEvent e) {
+ public void factorsTreeMouseClicked(MouseEvent e) {
// clic droit
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menu = new JPopupMenu();
@@ -238,7 +286,7 @@
menuItemDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- deleteSelectedFactors(sensitivityTabUI);
+ deleteSelectedFactors();
}
});
menu.add(menuItemDelete);
@@ -246,18 +294,16 @@
}
else if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
// autre double clic
- factorSelected(sensitivityTabUI);
+ factorSelected();
}
}
/**
* Factor selection, display modification wizard.
- *
- * @param sensitivityTabUI
*/
- protected void factorSelected(SensitivityTabUI sensitivityTabUI) {
+ protected void factorSelected() {
// get selected factor
- TreePath selectedPath = sensitivityTabUI.getFactorsTree().getSelectionPath();
+ TreePath selectedPath = sensitivityInputUI.getFactorsTree().getSelectionPath();
// method appelee au clic, donc pas forcement de selection
if (selectedPath != null) {
@@ -266,11 +312,11 @@
if (selectedObject != null) {
if (!(selectedObject instanceof FactorGroup)) {
Factor selectedFactor = (Factor)selectedObject;
- FactorWizardUI factorWizardUI = new FactorWizardUI(sensitivityTabUI);
- SensitivityWizardHandler handler = factorWizardUI.getHandler();
+ FactorWizardUI factorWizardUI = new FactorWizardUI(sensitivityInputUI);
+ FactorWizardHandler handler = factorWizardUI.getHandler();
handler.initExistingFactor(factorWizardUI, selectedFactor);
factorWizardUI.pack();
- factorWizardUI.setLocationRelativeTo(sensitivityTabUI);
+ factorWizardUI.setLocationRelativeTo(sensitivityInputUI);
factorWizardUI.setVisible(true);
}
}
@@ -280,9 +326,9 @@
/**
* Delete selection factors.
*/
- protected void deleteSelectedFactors(SensitivityTabUI sensitivityTabUI) {
+ protected void deleteSelectedFactors() {
// get selected factor
- TreePath[] selectedPaths = sensitivityTabUI.getFactorsTree().getSelectionPaths();
+ TreePath[] selectedPaths = sensitivityInputUI.getFactorsTree().getSelectionPaths();
if (!ArrayUtils.isEmpty(selectedPaths)) { // can happen
for (TreePath selectedPath : selectedPaths) {
Object[] pathWay = selectedPath.getPath();
@@ -297,7 +343,7 @@
log.debug("Deleting factor " + selectedFactor.getName());
}
selectedFactorGroup.remove(selectedFactor);
- sensitivityTabUI.setFactorModel();
+ setFactorModel();
}
}
}
@@ -305,39 +351,14 @@
}
}
- /*
- * Return value in swing component that could be next used into factor
- * for discrete factor values.
- *
- * @param component component
- * @return factor value
- *
- protected Object getComponentValue(JComponent component) {
- Object result = null;
- if (component instanceof JTextComponent) {
- result = ((JTextComponent) component).getText();
- } else if (component instanceof MatrixPanelEditor) {
- result = ((MatrixPanelEditor) component).getMatrix();
- } else if (component instanceof InputOneEquationUI) {
- result = ((InputOneEquationUI) component).getEditor().getText();
- } else if (component instanceof RuleChooser) {
- result = ((RuleChooser)component).getRulesList();
- }
- if (log.isDebugEnabled()) {
- log.debug("Value for component : " + component.getClass().getSimpleName() + " is " + result);
- }
-
- return result;
- }*/
-
/**
* Export factors list to xml mexico file.
*
* @since 4.1.1.2
*/
- public void exportFactorsToMexico(SensitivityTabUI view) {
+ public void exportFactorsToMexico() {
File xmlFile = FileUtil.getFile(t("isisfish.sensitivity.mexico.exporttoxml.title"),
- t("isisfish.sensitivity.mexico.exporttoxml.approve"), view,
+ t("isisfish.sensitivity.mexico.exporttoxml.approve"), sensitivityInputUI,
new String[]{
".*\\.xml",
t("isisfish.sensitivity.mexico.exporttoxml.filter")
@@ -350,11 +371,11 @@
xmlFile = new File(xmlFile.getAbsolutePath() + ".xml");
}
- SimulAction simulAction = view.getContextValue(SimulAction.class);
+ SimulAction simulAction = sensitivityInputUI.getContextValue(SimulAction.class);
DesignPlan designPlan = new DesignPlan();
designPlan.setFactorGroup(simulAction.getFactorGroup());
- String xml = MexicoHelper.getDesignPlanAsXML(designPlan);
+ //String xml = MexicoHelper.getDesignPlanAsXML(designPlan);
MexicoHelper.writeDesignPlanToFile(xmlFile, designPlan);
}
}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx (from rev 4230, trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,86 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 Ifremer, CodeLutin, Chatellier Eric
+ %%
+ 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%
+ -->
+<fr.ifremer.isisfish.ui.NavigationUI>
+
+ <SensitivityInputHandler id="handler" constructorParams='this' />
+
+ <fr.ifremer.isisfish.entities.FisheryRegion id='fisheryRegion' javaBean='null'/>
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
+ ]]></script>
+
+ <JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="HORIZONTAL" constraints='BorderLayout.CENTER'>
+ <JPanel layout='{new BorderLayout()}'>
+ <JSplitPane oneTouchExpandable="true" dividerLocation="400" orientation="VERTICAL" constraints='BorderLayout.CENTER'>
+ <JScrollPane>
+ <javax.swing.tree.DefaultTreeSelectionModel id='fisheryRegionTreeSelectionModel'
+ selectionMode='{javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION}'/>
+ <JTree id="fisheryRegionTree" rootVisible="true" selectionRow='0'
+ selectionModel='{getFisheryRegionTreeSelectionModel()}'
+ model='{new javax.swing.tree.DefaultTreeModel(null)}'
+ onValueChanged="handler.nodeSelectionChanged(event)" />
+ </JScrollPane>
+ <Table>
+ <row>
+ <cell anchor='west'>
+ <JButton icon="factors/dgroup.png" toolTipText="isisfish.sensitivity.newfactordgroup.tip"
+ onActionPerformed="handler.addNewFactorGroup(false)"/>
+ </cell>
+ <cell anchor='west'>
+ <JButton icon="factors/cgroup.png" toolTipText="isisfish.sensitivity.newfactorcgroup.tip"
+ onActionPerformed="handler.addNewFactorGroup(true)"/>
+ </cell>
+ <cell anchor='west' weightx='1'>
+ <JButton icon="script_go.png" toolTipText="isisfish.sensitivity.mexico.exporttoxml.tip"
+ onActionPerformed="handler.exportFactorsToMexico()"/>
+ </cell>
+ </row>
+ <row>
+ <cell columns='3' fill="both" weightx='1.0' weighty='1.0'>
+ <JScrollPane>
+ <fr.ifremer.isisfish.ui.sensitivity.model.FactorTree id="factorsTree" constructorParams='this'
+ rootVisible="true" selectionRow='0'
+ model='{new fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeModel(handler.getSimulAction().getFactorGroup())}'
+ cellRenderer='{new fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeCellRenderer()}'
+ onMouseClicked='handler.factorsTreeMouseClicked(event)'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+ </JSplitPane>
+ </JPanel>
+ <java.awt.CardLayout id='cardlayoutPrincipal'/>
+ <JPanel id='inputPanePrincipal' layout='{getCardlayoutPrincipal()}'>
+ <JPanel layout='{new BorderLayout()}' constraints='"none"'>
+ <JLabel id='none' horizontalAlignment="0" text="isisfish.input.selectRegion" constraints='BorderLayout.CENTER'/>
+ </JPanel>
+ <jaxx.runtime.swing.CardLayout2 id='cardlayout'/>
+ <JPanel id="inputPane" layout='{getCardlayout()}' constraints='"normale"'/>
+ </JPanel>
+ </JSplitPane>
+</fr.ifremer.isisfish.ui.NavigationUI>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,116 @@
+package fr.ifremer.isisfish.ui.sensitivity;
+
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
+import fr.ifremer.isisfish.simulator.launcher.SimulationService;
+import fr.ifremer.isisfish.simulator.launcher.SimulationServiceListener;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.simulator.SimulAction;
+
+public class SensitivitySecondPassHandler {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(SensitivitySecondPassHandler.class);
+
+ protected SensitivitySecondPassUI sensitivitySecondPassUI;
+
+ // declaration sépérée de la variable d'instance (jaxx)
+ protected SimulationServiceListener simulationListener;
+
+ public SensitivitySecondPassHandler(SensitivitySecondPassUI sensitivitySecondPassUI) {
+ this.sensitivitySecondPassUI = sensitivitySecondPassUI;
+ }
+
+ protected void afterInit() {
+ // permet de rafaichir la liste les simulations
+ // des qu'une simulation se termine
+ simulationListener = new SimulationServiceListener() {
+ @Override
+ public void simulationStart(SimulationService simService, SimulationJob job) {
+ }
+
+ @Override
+ public void simulationStop(SimulationService simService, SimulationJob job) {
+ if (log.isDebugEnabled()) {
+ log.debug("Refresh second pass UI simulations list");
+ }
+ GenericComboModel<String> model = (GenericComboModel<String>)sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getModel();
+ String simulationName = job.getId();
+ if (simulationName.startsWith("as_")) {
+ String masterSensitivityName = simulationName.substring(0, simulationName.lastIndexOf("_"));
+ if (!model.containsElement(masterSensitivityName)) {
+ model.addElement(masterSensitivityName);
+ }
+ }
+ }
+
+ @Override
+ public void clearJobDone(SimulationService simService) {
+ }
+ };
+ SimulationService.getService().addSimulationServiceListener(simulationListener);
+ }
+
+ /**
+ * Model de contenu de la liste des nom de simulations
+ */
+ public GenericComboModel<String> getSensitivitySimulationModel() {
+ List<String> asNames = new ArrayList<>();
+ for (String simulationName : SimulationStorage.getSimulationNames()) {
+ if (simulationName.startsWith("as_")) {
+ String masterSensitivityName = simulationName.substring(0, simulationName.lastIndexOf("_"));
+ if (!asNames.contains(masterSensitivityName)) {
+ asNames.add(masterSensitivityName);
+ }
+ }
+ }
+
+ GenericComboModel<String> model = new GenericComboModel<>(asNames);
+ return model;
+ }
+
+ @Deprecated
+ protected SimulAction getSimulAction() {
+ return sensitivitySecondPassUI.getContextValue(SimulAction.class);
+ }
+
+ protected void launchSecondPass(ActionEvent event) {
+ if (sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedIndex() != -1) {
+ getSimulAction().runSensitivitySecondPass((String)sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedItem());
+ displaySensitivitySecondPass(event);
+ }
+ }
+
+ protected void displaySensitivitySecondPass(ActionEvent event) {
+ if (sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedIndex() != -1) {
+
+ try {
+ String selectedSimulationName = (String)sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedItem();
+ List<File> files = getSimulAction().getSensitivitySecondPassResults(selectedSimulationName);
+
+ String content = "";
+ for(File file : files) {
+ content += "Fichier " + file.getName() + "\n";
+ content += "------------------------------\n";
+ content += FileUtils.readFileToString(file) + "\n";
+ content += "\n";
+ }
+ sensitivitySecondPassUI.textAreaSensitivitySecondpassResult.setText(content);
+ } catch(IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't run second pass", e);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -23,117 +23,24 @@
#L%
-->
<Table>
- <import>
- java.util.ArrayList
- java.io.File
- java.io.IOException
- org.apache.commons.io.FileUtils
- fr.ifremer.isisfish.datastore.SimulationStorage
- fr.ifremer.isisfish.simulator.launcher.SimulationService
- fr.ifremer.isisfish.simulator.launcher.SimulationJob
- fr.ifremer.isisfish.simulator.launcher.SimulationServiceListener
- fr.ifremer.isisfish.ui.simulator.SimulAction
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <SensitivitySecondPassHandler id="handler" constructorParams='this' />
-<script><![CDATA[
- // declaration sépérée de la variable d'instance (jaxx)
- SimulationServiceListener simulationListener;
-
+ <script><![CDATA[
protected void $afterCompleteSetup() {
- // permet de rafaichir la liste les simulations
- // des qu'une simulation se termine
- simulationListener = new SimulationServiceListener() {
- @Override
- public void simulationStart(SimulationService simService, SimulationJob job) {
- }
-
- @Override
- public void simulationStop(SimulationService simService, SimulationJob job) {
- if (log.isDebugEnabled()) {
- log.debug("Refresh second pass UI simulations list");
- }
- GenericComboModel<String> model = (GenericComboModel)fieldSensitivitySimulationSelect.getModel();
- String simulationName = job.getId();
- if (simulationName.startsWith("as_")) {
- String masterSensitivityName = simulationName.substring(0, simulationName.lastIndexOf("_"));
- if (!model.containsElement(masterSensitivityName)) {
- model.addElement(masterSensitivityName);
- }
- }
- }
-
- @Override
- public void clearJobDone(SimulationService simService) {
- }
- };
- SimulationService.getService().addSimulationServiceListener(simulationListener);
+ handler.afterInit();
}
+ ]]></script>
- /**
- * Model de contenu de la liste des nom de simulations
- */
- public GenericComboModel<String> getSensitivitySimulationModel() {
- List<String> asNames = new ArrayList<String>();
- for (String simulationName : SimulationStorage.getSimulationNames()) {
- if (simulationName.startsWith("as_")) {
- String masterSensitivityName = simulationName.substring(0, simulationName.lastIndexOf("_"));
- if (!asNames.contains(masterSensitivityName)) {
- asNames.add(masterSensitivityName);
- }
- }
- }
-
- GenericComboModel<String> model = new GenericComboModel<>(asNames);
- return model;
- }
-
- protected SimulAction getSimulAction() {
- return getContextValue(SimulAction.class);
- }
-
- protected void launchSecondPass(ActionEvent event) {
- if (fieldSensitivitySimulationSelect.getSelectedIndex() != -1) {
- getSimulAction().runSensitivitySecondPass((String)fieldSensitivitySimulationSelect.getSelectedItem());
- displaySensitivitySecondPass(event);
- }
- }
-
- protected void displaySensitivitySecondPass(ActionEvent event) {
- if (fieldSensitivitySimulationSelect.getSelectedIndex() != -1) {
-
- try {
- String selectedSimulationName = (String)fieldSensitivitySimulationSelect.getSelectedItem();
- List<File> files = getSimulAction().getSensitivitySecondPassResults(selectedSimulationName);
-
- String content = "";
- for(File file : files) {
- content += "Fichier " + file.getName() + "\n";
- content += "------------------------------\n";
- content += FileUtils.readFileToString(file) + "\n";
- content += "\n";
- }
- textAreaSensitivitySecondpassResult.setText(content);
- } catch(IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't run second pass", e);
- }
- }
- }
- }
-
- ]]>
- </script>
<row>
<cell fill="horizontal" weightx="1.0">
- <JComboBox id="fieldSensitivitySimulationSelect" genericType="String" model='{getSensitivitySimulationModel()}' />
+ <JComboBox id="fieldSensitivitySimulationSelect" genericType="String" model='{handler.getSensitivitySimulationModel()}' />
</cell>
<cell fill="horizontal">
- <JButton id="runSecondPassButton" text='isisfish.sensitivity.secondpass' onActionPerformed='launchSecondPass(event)'
+ <JButton id="runSecondPassButton" text='isisfish.sensitivity.secondpass' onActionPerformed='handler.launchSecondPass(event)'
enabled="{fieldSensitivitySimulationSelect.getSelectedItem() != null}" />
</cell>
<cell fill="horizontal">
- <JButton id="displaySecondPassButton" text='isisfish.sensitivity.displaysecondpass' onActionPerformed='displaySensitivitySecondPass(event)'
+ <JButton id="displaySecondPassButton" text='isisfish.sensitivity.displaysecondpass' onActionPerformed='handler.displaySensitivitySecondPass(event)'
enabled="{fieldSensitivitySimulationSelect.getSelectedItem() != null}" />
</cell>
</row>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -1,130 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 Ifremer, CodeLutin, Chatellier Eric
- %%
- 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%
- -->
-<fr.ifremer.isisfish.ui.NavigationUI>
- <import>
- javax.swing.tree.DefaultTreeModel
- fr.ifremer.isisfish.datastore.RegionStorage
- fr.ifremer.isisfish.ui.WelcomePanelUI
- fr.ifremer.isisfish.ui.input.InputSaveVerifier
- fr.ifremer.isisfish.ui.simulator.SimulAction
- fr.ifremer.isisfish.simulator.sensitivity.FactorGroup
- fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeModel
- fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeCellRenderer
- fr.ifremer.isisfish.ui.sensitivity.model.FactorTree
- java.awt.event.ActionListener
- java.awt.event.ActionEvent
- </import>
-
- <SensitivityInputHandler id="handler" />
-
- <fr.ifremer.isisfish.entities.FisheryRegion id='fisheryRegion' javaBean='null'/>
-
- <script><![CDATA[
-protected SimulAction getSimulAction() {
- return getContextValue(SimulAction.class);
-}
-
-protected InputSaveVerifier getVerifier() {
- return getContextValue(InputSaveVerifier.class);
-}
-
-protected RegionStorage getRegionStorage() {
- return getContextValue(RegionStorage.class);
-}
-
-public void setTreeModel() {
- if (getFisheryRegion() != null) {
- getCardlayoutPrincipal().show(inputPanePrincipal,"normale");
- setContextValue(getFisheryRegion());
- getHandler().loadFisheryRegionTree(this);
- }
-}
-protected void setInfoText(String s) {
- WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
- root.setStatusMessage(s);
-}
-protected void regionNull() {
- getCardlayoutPrincipal().show(inputPanePrincipal,"none");
- DefaultTreeModel model = new DefaultTreeModel(null);
- fisheryRegionTree.setModel(model);
-}
-public void setFactorModel() {
- FactorGroup factorGroup = getSimulAction().getFactorGroup();
- FactorTreeModel model = new FactorTreeModel(factorGroup);
- factorsTree.setModel(model);
- getParentContainer(SensitivityUI.class).getSensitivityChooserUI().setFactorCardinalityTableModel();
-}
- ]]>
- </script>
- <JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="HORIZONTAL" constraints='BorderLayout.CENTER'>
- <JPanel layout='{new BorderLayout()}'>
- <JSplitPane oneTouchExpandable="true" dividerLocation="400" orientation="VERTICAL" constraints='BorderLayout.CENTER'>
- <JScrollPane>
- <javax.swing.tree.DefaultTreeSelectionModel id='fisheryRegionTreeSelectionModel'
- selectionMode='{javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION}'/>
- <JTree id="fisheryRegionTree" rootVisible="true" selectionRow='0'
- selectionModel='{getFisheryRegionTreeSelectionModel()}'
- model='{new DefaultTreeModel(null)}'
- onValueChanged="getHandler().nodeSelectionChanged(this, event)" />
- </JScrollPane>
- <Table>
- <row>
- <cell anchor='west'>
- <JButton icon="factors/dgroup.png" toolTipText="isisfish.sensitivity.newfactordgroup.tip"
- onActionPerformed="getHandler().addNewFactorGroup(this, false)"/>
- </cell>
- <cell anchor='west'>
- <JButton icon="factors/cgroup.png" toolTipText="isisfish.sensitivity.newfactorcgroup.tip"
- onActionPerformed="getHandler().addNewFactorGroup(this, true)"/>
- </cell>
- <cell anchor='west' weightx='1'>
- <JButton icon="script_go.png" toolTipText="isisfish.sensitivity.mexico.exporttoxml.tip"
- onActionPerformed="getHandler().exportFactorsToMexico(this)"/>
- </cell>
- </row>
- <row>
- <cell columns='3' fill="both" weightx='1.0' weighty='1.0'>
- <JScrollPane>
- <FactorTree id="factorsTree" constructorParams='this'
- rootVisible="true" selectionRow='0'
- model='{new FactorTreeModel(getSimulAction().getFactorGroup())}'
- cellRenderer='{new FactorTreeCellRenderer()}'
- onMouseClicked='getHandler().factorsTreeMouseClicked(this, event)'/>
- </JScrollPane>
- </cell>
- </row>
- </Table>
- </JSplitPane>
- </JPanel>
- <java.awt.CardLayout id='cardlayoutPrincipal'/>
- <JPanel id='inputPanePrincipal' layout='{getCardlayoutPrincipal()}'>
- <JPanel layout='{new BorderLayout()}' constraints='"none"'>
- <JLabel id='none' horizontalAlignment="0" text="isisfish.input.selectRegion" constraints='BorderLayout.CENTER'/>
- </JPanel>
- <jaxx.runtime.swing.CardLayout2 id='cardlayout'/>
- <JPanel id="inputPane" layout='{getCardlayout()}' constraints='"normale"'/>
- </JPanel>
- </JSplitPane>
-</fr.ifremer.isisfish.ui.NavigationUI>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -24,14 +24,6 @@
-->
<fr.ifremer.isisfish.ui.SimulationUI>
- <import>
- fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
- jaxx.runtime.context.JAXXInitialContext
- jaxx.runtime.JAXXContext
- </import>
-
- <SensitivityInputHandler id="handler" />
-
<script><![CDATA[
/**
@@ -72,18 +64,16 @@
@Override
public void refreshFactorTree() {
- sensitivityTabUI.setFactorModel();
+ sensitivityInputUI.getHandler().setFactorModel();
}
]]></script>
<JTabbedPane id="bodyTabbedPane">
<tab title='isisfish.params.title'>
- <fr.ifremer.isisfish.ui.simulator.ParamsUI id='paramsUI' sensitivity='true' regionStorage="{getRegionStorage()}"
- constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ <fr.ifremer.isisfish.ui.simulator.ParamsUI id='paramsUI' sensitivity='true' regionStorage="{getRegionStorage()}" constructorParams='this' />
</tab>
<tab title='isisfish.sensitivity.title' enabled="false">
- <SensitivityTabUI id="sensitivityTabUI"
- constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ <SensitivityInputUI id="sensitivityInputUI" constructorParams='this' />
</tab>
<tab title='isisfish.sensitivityChooser.title' enabled="false">
<SensitivityChooserUI id="sensitivityChooserUI" constructorParams='this'/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTransferHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTransferHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTransferHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -40,7 +40,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputUI;
/**
* Transfer handler used to transfer tasks in table.
@@ -59,15 +59,15 @@
private static Log log = LogFactory.getLog(FactorTransferHandler.class);
/** Associated ui */
- protected SensitivityTabUI sensitivityTabUI;
+ protected SensitivityInputUI sensitivityInputUI;
/**
* Constructor.
*
- * @param sensitivityTabUI associated ui
+ * @param sensitivityInputUI associated ui
*/
- public FactorTransferHandler(SensitivityTabUI sensitivityTabUI) {
- this.sensitivityTabUI = sensitivityTabUI;
+ public FactorTransferHandler(SensitivityInputUI sensitivityInputUI) {
+ this.sensitivityInputUI = sensitivityInputUI;
}
@Override
@@ -152,7 +152,7 @@
if (selectedFactorGroup != null) {
Object myObject = transferable.getTransferData(FactorTranferable.myData);
List<Factor> movedFactors = (List<Factor>) myObject;
- sensitivityTabUI.getHandler().moveFactor(sensitivityTabUI, selectedFactorGroup, movedFactors);
+ sensitivityInputUI.getHandler().moveFactor(selectedFactorGroup, movedFactors);
}
} catch (IOException e) {
if (log.isErrorEnabled()) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTree.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTree.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorTree.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -31,7 +31,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputUI;
/**
* Factor tree.
@@ -52,12 +52,12 @@
/**
* Constructor (add drag and drop).
*
- * @param sensitivityTabUI parent ui
+ * @param sensitivityInputUI parent ui
*/
- public FactorTree(SensitivityTabUI sensitivityTabUI) {
+ public FactorTree(SensitivityInputUI sensitivityInputUI) {
// enable drag n drop
setDragEnabled(true);
- setTransferHandler(new FactorTransferHandler(sensitivityTabUI));
+ setTransferHandler(new FactorTransferHandler(sensitivityInputUI));
}
/**
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java (from rev 4231, trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,882 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.sensitivity.wizard;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.text.JTextComponent;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEditor;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityContextable;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.simulator.sensitivity.Domain;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.types.RangeOfValues;
+import fr.ifremer.isisfish.types.TimeStep;
+import fr.ifremer.isisfish.types.TimeUnit;
+import fr.ifremer.isisfish.ui.SimulationUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
+import fr.ifremer.isisfish.ui.simulator.RuleChooser;
+import fr.ifremer.isisfish.ui.simulator.SimulAction;
+import fr.ifremer.isisfish.ui.widget.editor.MonthComponent;
+import fr.ifremer.isisfish.ui.widget.editor.StepComponent;
+
+/**
+ * Handler for all class in wizard packages.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FactorWizardHandler {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(FactorWizardHandler.class);
+
+ protected FactorWizardUI factorWizardUI;
+
+ public FactorWizardHandler(FactorWizardUI factorWizardUI) {
+ this.factorWizardUI = factorWizardUI;
+ }
+
+ protected void afterInit() {
+ factorWizardUI.addPropertyChangeListener(FactorWizardUI.PROPERTY_CONTINUE_SELECTED, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if ((Boolean)evt.getNewValue()) {
+ ((CardLayout)factorWizardUI.hidablePanel.getLayout()).show(factorWizardUI.hidablePanel, "continuousPanelContainer");
+ } else {
+ ((CardLayout)factorWizardUI.hidablePanel.getLayout()).show(factorWizardUI.hidablePanel, "discretePanelContainer");
+ }
+ }
+ });
+ }
+
+ /**
+ * Return opened topia context that need to be closed.
+ *
+ * There is several things in ugly jaxx context:
+ * <ul>
+ * <li>opened TopiaContext from SensitivityTabUI that is null in ParamUI
+ * <li>RegionStorage on SimulAction
+ * </ul>
+ *
+ * Use region storage here.
+ *
+ * @return opened topia context
+ * @throws TopiaException
+ */
+ protected TopiaContext getTopiaContext(FactorWizardUI factorWizardUI) throws TopiaException {
+ // RegionStorage object is common to ParamsUI
+ // and SensitivityTabUI and may be valued
+ RegionStorage regionStorage = factorWizardUI.getContextValue(RegionStorage.class);
+ TopiaContext context = regionStorage.getStorage().beginTransaction();
+ return context;
+ }
+
+ /**
+ * Initialize un nouveau wizard avec lorsque l'utilisateur clic sur
+ * un layer sont le sous composant accepte la mise en facteur.
+ *
+ * On recupere des info sur le type correspondant à la proprieté a mettre
+ * en facteur pour savoir le composant d'edition et s'il peut etre continue
+ * ou pas.
+ *
+ * @param factorWizardUI factorWizardUI
+ * @param bean bean in current ui
+ * @param property bean property to edit
+ */
+ public void initNewFactor(FactorWizardUI factorWizardUI, TopiaEntityContextable bean, String property) {
+
+ // path is topiaId#property
+ // ex : fwn#fsd#0.3425345#name
+ // for JAXX : cOrigine start with upper case
+ // for commons beanutils : must be lower case
+ String beanProperty = StringUtils.uncapitalize(property);
+ String path = bean.getTopiaId() + "#" + beanProperty;
+ factorWizardUI.setFactorPath(path);
+ factorWizardUI.getFactorNameField().setText(bean.toString() + "." + beanProperty);
+
+ // get value for pointed path
+ //TopiaContext topiaContext = factorWizardUI.getContextValue(TopiaContext.class);
+ //Class<?> classForPath = getPropertyClass(path, topiaContext);
+ // peut etre pas une bonne idée que ce soit basé sur les valeurs
+ // au lieu des types (mais pour RangeOfValues, pas evident)
+ try {
+ Object valueForPath = PropertyUtils.getProperty(bean, beanProperty);
+ boolean continuePossible = SensitivityUtils.canBeContinue(valueForPath);
+ boolean continueSelected = SensitivityUtils.isContinue(valueForPath);
+
+ // init panel
+ if (continuePossible) {
+ JComponent comp = getContinuousPanel(valueForPath, bean, property);
+ factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
+ }
+
+ // after, for binding on continuePossible, continueSelected to work
+ factorWizardUI.setContinuePossible(continuePossible);
+ factorWizardUI.setContinueSelected(continueSelected);
+ factorWizardUI.getContinueRadio().setSelected(continueSelected);
+ } catch (Exception ex) {
+ throw new IsisFishRuntimeException("Can't init wizard", ex);
+ }
+ }
+
+ /**
+ * Appelé suite a un double clic sur l'arbre des facteurs pour modifier un
+ * facteur.
+ *
+ * @param factorWizardUI view to init
+ * @param factor factor factor to edit
+ */
+ public void initExistingFactor(FactorWizardUI factorWizardUI, Factor factor) {
+
+ factorWizardUI.setEditingState(true);
+ String factorPath = factor.getPath();
+ Domain domain = factor.getDomain();
+ String factorName = factor.getName();
+ factorWizardUI.setFactorPath(factorPath);
+ factorWizardUI.getComment().setText(factor.getComment());
+
+ if (domain instanceof ContinuousDomain) {
+
+ ContinuousPanel comp = getNewContinuousComponent(factorWizardUI, factor.getPath());
+ comp.initWithFactor(factor);
+ factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
+
+ factorWizardUI.getContinueRadio().setSelected(true);
+ factorWizardUI.setContinueSelected(true);
+ factorWizardUI.setContinuePossible(true);
+ } else {
+
+ // un facteur pour être edité sans domain
+ // lors de la creation
+ if (domain != null) {
+ // restaure discrete domain
+ DiscreteDomain dDomain = (DiscreteDomain)domain;
+
+ int nb = dDomain.getValues().size();
+ factorWizardUI.getDiscretNumber().setText(String.valueOf(nb));
+ factorWizardUI.getTabPane().removeAll();
+
+ SortedMap<Object, Object> values = dDomain.getValues();
+ int i = 0;
+ for (Object o : values.values()) {
+ i++;
+ JComponent c = null;
+ if (o != null) {
+ c = getEditorWithValue(factorWizardUI, factor, dDomain, o);
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Null value in factor");
+ }
+ }
+ JScrollPane js = new JScrollPane(c);
+ String tabName = t("isisfish.sensitivity.discretevaluelabel", i);
+ factorWizardUI.getTabPane().addTab(tabName, js);
+ }
+ }
+
+ // init non selected continous panel
+ JComponent comp = getNewContinuousComponent(factorWizardUI, factor.getPath());
+ if (comp != null) {
+ factorWizardUI.setContinuePossible(true);
+ factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
+ }
+ }
+
+ factorWizardUI.getFactorNameField().setText(factorName);
+ }
+
+ /**
+ * Renvoie un componsant gaphique initialisé avec la valeur
+ * qui est enregistré dans le domain.
+ * Pour réédition d'un facteur existant (facteur discret).
+ *
+ * @param factorWizardUI context for context value (RegionStorage)
+ * @param value type to get editor
+ * @param factor factor for path value
+ * @param domain domain for domain type
+ * @return component ui component with value
+ */
+ protected JComponent getEditorWithValue(FactorWizardUI factorWizardUI, Factor factor, Domain domain, Object value) {
+
+ JComponent result = null;
+
+ if (Double.class.isAssignableFrom(value.getClass())) {
+ result = new JTextField();
+ ((JTextField)result).setText(String.valueOf(value));
+ }
+ else if (double.class.isAssignableFrom(value.getClass())) {
+ result = new JTextField();
+ ((JTextField)result).setText(String.valueOf(value));
+ }
+ else if (MatrixND.class.isAssignableFrom(value.getClass())) {
+ result = new MatrixPanelEditor();
+ ((MatrixPanelEditor)result).setMatrix((MatrixND)value);
+ }
+ else if (domain instanceof RuleDiscreteDomain) {
+ result = new RuleChooser(factorWizardUI);
+ ((RuleChooser)result).setRulesList((List<Rule>)value);
+ }
+ else if (domain instanceof EquationDiscreteDomain) {
+ String factorPath = factor.getPath();
+ if (factor.getPath().indexOf('#') != -1) {
+ String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
+ String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
+
+ // get bean in database
+ try {
+ TopiaContext topiaContext = getTopiaContext(factorWizardUI);
+ TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
+ Equation equation = (Equation)PropertyUtils.getProperty(entity, property);
+ topiaContext.closeContext();
+
+ // fill component
+ InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
+ ui.setAutoSaveModification(false);
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setText(t("isisfish.common.equation")); // can't get real name
+ ui.setClazz(value.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(entity); // set bean fire content modification event
+ ui.getEditor().setText((String)value);
+ ui.setActive(true);
+
+ result = ui;
+ } catch (Exception ex) {
+ throw new IsisFishRuntimeException("Can't restore initial factor database property", ex);
+ }
+ }
+ // TODO path with no # (normalement pas possible pour les equations)
+ }
+ else if (value instanceof TimeUnit) {
+ result = new JTextField();
+ ((JTextField)result).setText(String.valueOf(((TimeUnit)value).getTime()));
+ } else if (value instanceof TopiaEntity) {
+ RegionStorage regionStorage = factorWizardUI.getContextValue(RegionStorage.class);
+ TopiaContext context = null;
+ try {
+ context = regionStorage.getStorage().beginTransaction();
+ List list = context.findAll("from " + value.getClass().getName());
+ JComboBox c = new JComboBox<>(list.toArray());
+ c.setSelectedItem(value);
+ result = c;
+ } catch (TopiaException ex) {
+ throw new IsisFishRuntimeException("Can't get entity list", ex);
+ } finally {
+ if (context != null) {
+ try {
+ context.closeContext();
+ } catch (TopiaException ex) {
+ throw new IsisFishRuntimeException("Can't get entity list", ex);
+ }
+ }
+ }
+ } else if (value instanceof TimeStep) {
+ TimeStep timeStep = (TimeStep)value;
+ result = new StepComponent(timeStep.getMonth().getMonthNumber(), timeStep.getYear());
+ } else if (value instanceof Month) {
+ Month month = (Month)value;
+ result = MonthComponent.createMounthCombo(month.getMonthNumber());
+ } else if (value instanceof String) {
+ // valeur non typées ???
+ result = new JTextField();
+ ((JTextField)result).setText(String.valueOf(value));
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Editor for value " + value + " is " + result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Retourne le componant permettant de mettre en facteur continue
+ * une valeur.
+ *
+ * @param value value (must be continuable)
+ * @param bean bean (in case of equation)
+ * @param property bean property (in case of equation)
+ * @return component initialized
+ */
+ protected ContinuousPanel getContinuousPanel(Object value, TopiaEntityContextable bean, String property) {
+ ContinuousPanel result;
+
+ if (value instanceof RangeOfValues) {
+ RangeOfValues rangeOfValues = (RangeOfValues)value;
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ String values = rangeOfValues.getValues();
+ String min = "0";
+ //String max = "0";
+ if (values.matches("^\\ *[0-9]*\\ *\\-\\ *[0-9]*\\ *$")) {
+ int first = values.indexOf("-");
+ if (first != -1) {
+ min = values.substring(0, first);
+ //max = values.substring(first + 1);
+ }
+ }
+ //ui.init(min, max, min, null);
+ //result = ui;
+ result = new ContinuousDistributionPanel(min);
+ } else if (value instanceof Equation) {
+ Equation equation = (Equation)value;
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
+ ui.setSelectedEquation(equation);
+ ui.setText(t("isisfish.common.equation")); // can't get real name
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setClazz(equation.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(bean);
+ result = ui;
+ } else if (value instanceof MatrixND) {
+ MatrixND matrix = (MatrixND)value;
+ result = new ContinuousDistributionPanel(matrix.clone());
+ } else if (value instanceof TimeUnit) {
+ TimeUnit timeUnit = (TimeUnit)value;
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ //ui.init(String.valueOf(timeUnit.getTime()), String.valueOf(timeUnit.getTime()),
+ // String.valueOf(timeUnit.getTime()), null);
+ //result = ui;
+ result = new ContinuousDistributionPanel(String.valueOf(timeUnit.getTime()));
+ } else {
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ //ui.init(String.valueOf(value), String.valueOf(value), String.valueOf(value), null);
+ //result = ui;
+ result = new ContinuousDistributionPanel(String.valueOf(value));
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Component for " + value + " (" + bean + ", " + property + ")");
+ log.debug(" > " + result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Rafraichit l'assistant de facteur pour modifier le nombre de valeurs
+ * (onglet) d'un composant discret.
+ *
+ * @param factorWizardUI factorWizardUI
+ */
+ public void addTabs(FactorWizardUI factorWizardUI) {
+ String discreteNumber = factorWizardUI.getDiscretNumber().getText();
+ int nbTab = Integer.parseInt(discreteNumber);
+ int currentCount = factorWizardUI.getTabPane().getTabCount();
+
+ // remove useless tab
+ for (int tab = currentCount - 1; tab > nbTab -1 ; tab--) {
+ factorWizardUI.getTabPane().remove(tab);
+ }
+
+ // add new tabs
+ for (int tab = currentCount ; tab < nbTab ; tab++) {
+ JComponent c = getNewDiscreteComponent(factorWizardUI);
+ String tabName = t("isisfish.sensitivity.discretevaluelabel", tab);
+ factorWizardUI.getTabPane().addTab(tabName, c);
+ }
+
+ factorWizardUI.pack();
+ }
+
+ /**
+ * Return new discrete component inited with value defined by factor path.
+ *
+ * Le composant retourné est inclut dans un jscrollpane (sauf pour les
+ * matrices qui contient deja un jscrollpane)
+ *
+ * @param factorWizardUI factorWizardUI
+ * @return component copy
+ */
+ protected JComponent getNewDiscreteComponent(FactorWizardUI factorWizardUI) {
+
+ JComponent result = null;
+ String factorPath = factorWizardUI.getFactorPath();
+
+ try {
+ if (factorPath.indexOf('#') != -1) {
+ String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
+ String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
+
+ // get bean in database
+ TopiaContext topiaContext = getTopiaContext(factorWizardUI);
+ TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
+ Object value = PropertyUtils.getProperty(entity, property);
+
+ // init new jcomponent for value
+ if (value instanceof Number) {
+ result = new JTextField(String.valueOf(value));
+ } else if (value instanceof MatrixND) {
+ result = new MatrixPanelEditor();
+ MatrixND matrix = ((MatrixND)value).copy();
+ ((MatrixPanelEditor)result).setMatrix(matrix);
+ } else if (value instanceof RangeOfValues) {
+ RangeOfValues rangeOfValues = (RangeOfValues)value;
+ result = new JTextField(rangeOfValues.getValues());
+ } else if (value instanceof TimeUnit) {
+ TimeUnit timeUnit = (TimeUnit)value;
+ result = new JTextField(String.valueOf(timeUnit.getTime()));
+ } else if (value instanceof Equation) {
+ Equation equation = (Equation)value;
+ // fill component
+ InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
+ ui.setAutoSaveModification(false);
+ ui.setText(equation.getContent());
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setText(t("isisfish.common.equation")); // can't get real name
+ ui.setClazz(value.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(entity);
+ ui.setActive(true);
+ result = ui;
+ }
+
+ topiaContext.closeContext();
+
+ }
+ else {
+ // dans ce cas c'est des regles, pop de départ ou parametres de regles
+ // c'est un peu galere car le code n'a rien a voir avec le reste
+ // donc, c'est du cas par cas
+ if (factorPath.equals("parameters.rules")) {
+ result = new RuleChooser(factorWizardUI);
+ } else if (factorPath.startsWith("parameters.population.")) {
+ // la seule facon d'avoir les parametres ici est d'aller
+ // les chercher dans les parametres de simulation
+ Pattern pattern = Pattern.compile("^parameters\\.population\\.(\\w+)(\\.(.+)?)$");
+ Matcher matcher = pattern.matcher(factorPath);
+ if (matcher.matches()) {
+ String populationName = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("Loading population : " + populationName);
+ }
+ TopiaContext topiaContext = getTopiaContext(factorWizardUI);
+ Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName);
+ SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
+ MatrixND N = action.getSimulationParameter().getNumberOf(pop);
+ result = new MatrixPanelEditor();
+ ((MatrixPanelEditor)result).setMatrix(N.clone());
+ topiaContext.closeContext();
+ }
+ } else if (factorPath.startsWith("parameters.rule.")) {
+ Pattern pattern = Pattern.compile("^parameters\\.rule\\.(\\d+)\\.parameter\\.(\\w+)(\\..+)?$");
+ Matcher matcher = pattern.matcher(factorPath);
+ if (matcher.matches()) {
+ int ruleIndex = Integer.parseInt(matcher.group(1));
+ SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
+ Rule rule = action.getSimulationParameter().getRules().get(ruleIndex);
+ Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2));
+ Object value = RuleStorage.getParameterValue(rule, matcher.group(2));
+ result = getTypeDiscreteComponent(factorWizardUI, valueClazz, value);
+
+ } else {
+ // double...
+ result = new JTextField("0.0");
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find component for path " + factorPath);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ throw new IsisFishRuntimeException("Can't restore intial factor database property", ex);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Component for path " + factorPath + " is " + result);
+ }
+
+ // hack : si on met 2 fois un jscrollpane, rien ne s'affiche
+ if (!(result instanceof MatrixPanelEditor)) {
+ result = new JScrollPane(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Return new continuous component inited with value defined by factor path.
+ *
+ * @param factorWizardUI (to use topia context)
+ * @param factorPath factor path
+ * @return component initialized
+ */
+ protected ContinuousPanel getNewContinuousComponent(FactorWizardUI factorWizardUI, String factorPath) {
+ ContinuousPanel result = null;
+
+ try {
+ if (factorPath.indexOf('#') != -1) {
+ String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
+ String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
+
+ // get bean in database
+ TopiaContext topiaContext = getTopiaContext(factorWizardUI);
+ TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
+ Object value = PropertyUtils.getProperty(entity, property);
+
+ if (value instanceof RangeOfValues) {
+ RangeOfValues rangeOfValues = (RangeOfValues)value;
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ String values = rangeOfValues.getValues();
+ String min = "0";
+ String max = "0";
+ if (values.matches("^\\ *[0-9]*\\ *\\-\\ *[0-9]*\\ *$")) {
+ int first = values.indexOf("-");
+ if (first != -1) {
+ min = values.substring(0, first);
+ max = values.substring(first + 1);
+ }
+ }
+ result = new ContinuousDistributionPanel(min);
+ } else if (value instanceof Equation) {
+ Equation equation = (Equation)value;
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
+ ui.setSelectedEquation(equation);
+ ui.setText(t("isisfish.common.equation")); // can't get real name
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setClazz(equation.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(entity);
+ result = ui;
+ } else if (value instanceof MatrixND) {
+ MatrixND matrix = (MatrixND)value;
+ result = new ContinuousDistributionPanel(matrix.clone());
+ } else if (value instanceof TimeUnit) {
+ TimeUnit timeUnit = (TimeUnit)value;
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ //ui.init(String.valueOf(timeUnit.getTime()), String.valueOf(timeUnit.getTime()),
+ // String.valueOf(timeUnit.getTime()), null);
+ //result = ui;
+ result = new ContinuousDistributionPanel(String.valueOf(timeUnit.getTime()));
+ } else {
+ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
+ //ui.init(String.valueOf(value), String.valueOf(value), String.valueOf(value), null);
+ //result = ui;
+ result = new ContinuousDistributionPanel(String.valueOf(value));
+ }
+
+ topiaContext.closeContext();
+
+ } else {
+ if (factorPath.startsWith("parameters.population.")) {
+ // la seule facon d'avoir les parametres ici est d'aller
+ // les chercher dans les parametres de simulation
+ Pattern pattern = Pattern.compile("^parameters\\.population\\.(\\w+)(\\.(.+)?)$");
+ Matcher matcher = pattern.matcher(factorPath);
+ if (matcher.matches()) {
+ String populationName = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("Loading population : " + populationName);
+ }
+ TopiaContext topiaContext = getTopiaContext(factorWizardUI);
+ Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName);
+ SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
+ MatrixND N = action.getSimulationParameter().getNumberOf(pop);
+ result = new ContinuousDistributionPanel(N.clone());
+ topiaContext.closeContext();
+ }
+ } else if (factorPath.startsWith("parameters.rule.")) {
+ Pattern pattern = Pattern.compile("^parameters\\.rule\\.(\\d+)\\.parameter\\.(\\w+)(\\..+)?$");
+ Matcher matcher = pattern.matcher(factorPath);
+ if (matcher.matches()) {
+ int ruleIndex = Integer.parseInt(matcher.group(1));
+ SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
+ Rule rule = action.getSimulationParameter().getRules().get(ruleIndex);
+ Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2));
+ Object value = RuleStorage.getParameterValue(rule, matcher.group(2));
+ result = getTypeContinousComponent(factorWizardUI, valueClazz, value);
+
+ } else {
+ // double...
+ result = getContinuousPanel(0.0, null, null);
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find component for path " + factorPath);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ throw new IsisFishRuntimeException("Can't init wizard", ex);
+ }
+
+ return result;
+ }
+
+ /**
+ * Get new special component for typed parameters.
+ *
+ * @param factorWizardUI
+ * @param type
+ * @return rule discrete component
+ */
+ protected JComponent getTypeDiscreteComponent(FactorWizardUI factorWizardUI, Class type, Object value) {
+
+ JComponent result = null;
+
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+ try {
+ TopiaContext context = getTopiaContext(factorWizardUI);
+ List list = context.findAll("from " + type.getName());
+ JComboBox c = new JComboBox(list.toArray());
+ result = c;
+ context.closeContext();
+ } catch (TopiaException ex) {
+ throw new IsisFishRuntimeException("Can't get entity list", ex);
+ }
+ } else if (TimeStep.class.isAssignableFrom(type)) {
+ result = new StepComponent(0, 0);
+ } else if (Month.class.isAssignableFrom(type)) {
+ result = MonthComponent.createMounthCombo(0);
+ } else {
+ if (value != null) {
+ result = new JTextField(value.toString());
+ } else {
+ result = new JTextField();
+ }
+
+ }
+
+ return result;
+ }
+
+ /**
+ * Get new special component for typed parameters.
+ *
+ * @param factorWizardUI
+ * @param type type to get component
+ * @return rule discrete component
+ */
+ protected ContinuousPanel getTypeContinousComponent(FactorWizardUI factorWizardUI, Class type, Object value) {
+
+ ContinuousPanel result = null;
+
+ if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
+ if (value != null) {
+ result = new ContinuousDistributionPanel(value.toString());
+ } else {
+ result = new ContinuousDistributionPanel(0.0);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Save current factor.
+ *
+ * @param factorWizardUI factorWizardUI
+ */
+ public void save(FactorWizardUI factorWizardUI) {
+
+ // get continuous component if any
+ ContinuousPanel continuousPanel = null;
+ if (factorWizardUI.getContinuousPanelContainer().getComponentCount() > 0) {
+ continuousPanel = (ContinuousPanel)factorWizardUI.getContinuousPanelContainer().getComponent(0);
+ }
+
+ // first check is factor is valid
+ boolean factorValid = true;
+ if (continuousPanel != null) {
+ factorValid = continuousPanel.isFactorValid();
+ }
+ if (!factorValid) {
+ JOptionPane.showMessageDialog(factorWizardUI, t("isisfish.sensitivity.factor.notvalid"),
+ t("isisfish.sensitivity.title"), JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ // call specific method depending on continuous/discrete
+ if (factorWizardUI.getContinueRadio().isSelected()) {
+ saveContinue(factorWizardUI.getFactorNameField().getText(),
+ factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), continuousPanel,
+ factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState());
+ } else {
+ Component[] discreteComponents = factorWizardUI.getTabPane().getComponents();
+ saveDiscret(factorWizardUI.getFactorNameField().getText(),
+ factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), discreteComponents,
+ factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState());
+ }
+
+ // refresh factor list
+ factorWizardUI.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree();
+
+ // close window
+ factorWizardUI.dispose();
+ }
+
+ /**
+ * Save a continous factor.
+ *
+ * @param name factor name
+ * @param comment comment
+ * @param path factor path
+ * @param panel panel
+ * @param action action
+ * @param exist exist
+ */
+ protected void saveContinue(String name,
+ String comment, String path, ContinuousPanel panel,
+ SimulAction action, boolean exist) {
+ if (panel instanceof EquationContinuousPanelUI) {
+ try {
+ EquationContinuousPanelUI equationPanel = (EquationContinuousPanelUI) panel;
+ String property = StringUtils.uncapitalize(equationPanel.getBeanProperty()) + "Content";
+ TopiaEntityContextable bean = equationPanel.getBean();
+ TopiaContext topiaContext = bean.getTopiaContext();
+ PropertyUtils.setProperty(bean, property, equationPanel.getEditor().getEditor().getText());
+
+ // Save equation
+ bean.update();
+ topiaContext.commitTransaction();
+
+ List<Factor> factors = equationPanel.getFactors();
+ for (Factor factor : factors) {
+ factor.setName(name);
+ factor.setComment(comment);
+ factor.setPath(path);
+ action.addContinuousEquationFactor(factor, exist);
+ }
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't call method : ", ex);
+ }
+ }
+ } else if (panel instanceof ContinuousDistributionPanel) {
+ ContinuousDistributionPanel defaultPanel = (ContinuousDistributionPanel) panel;
+ ContinuousDomain domain = defaultPanel.generateDomain();
+ action.addContinuousFactor(name, comment, path, domain, exist);
+ }
+ }
+
+ /**
+ * Save a discret factor.
+ *
+ * @param name
+ * @param comment
+ * @param path
+ * @param components
+ * @param action
+ * @param exist
+ */
+ protected void saveDiscret(String name,
+ String comment, String path, Component[] components,
+ SimulAction action, boolean exist) {
+ List<Object> values = new ArrayList<Object>();
+
+ boolean ruleFactor = false;
+ boolean equationFactor = false;
+ for (Component component : components) {
+
+ if (component instanceof JScrollPane) {
+ component = ((JScrollPane) component).getViewport().getView();
+ }
+
+ // get internat component value
+ Object result = null;
+ if (component instanceof JTextComponent) {
+ result = ((JTextComponent) component).getText();
+ } else if (component instanceof MatrixPanelEditor) {
+ result = ((MatrixPanelEditor) component).getMatrix();
+ } else if (component instanceof InputOneEquationUI) {
+ result = ((InputOneEquationUI) component).getEditor().getText();
+ equationFactor = true;
+ } else if (component instanceof RuleChooser) {
+ result = ((RuleChooser)component).getRulesList();
+ ruleFactor = true;
+ } else if (component instanceof StepComponent) {
+ result = new TimeStep(((StepComponent)component).getSelectedValue());
+ } else if (component instanceof MonthComponent) {
+ result = new Month(((MonthComponent)component).getSelectedValue());
+ } else if (component instanceof JComboBox) {
+ // on suppose qu'il y a dedans des TopiaEntity
+ result = ((JComboBox)component).getSelectedItem();
+ }
+
+ values.add(result);
+ }
+
+ if (ruleFactor) {
+ action.addDiscreteRuleFactor(name, comment, path, values, exist);
+ } else if (equationFactor) {
+ action.addDiscreteEquationFactor(name, comment, path, values, exist);
+ } else {
+ action.addDiscreteFactor(name, comment, path, values, exist);
+ }
+ }
+
+ /**
+ * Remove current factor.
+ *
+ * @param factorWizardUI factorWizardUI
+ */
+ public void remove(FactorWizardUI factorWizardUI) {
+ factorWizardUI.getContextValue(SimulAction.class).removeFactor(factorWizardUI.getFactorPath());
+ factorWizardUI.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree();
+ factorWizardUI.dispose();
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardUI.jaxx 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardUI.jaxx 2015-05-22 16:10:26 UTC (rev 4233)
@@ -30,7 +30,7 @@
java.awt.CardLayout
</import>
- <SensitivityWizardHandler id="handler" />
+ <FactorWizardHandler id="handler" constructorParams='this' />
<Boolean id='continuePossible' javaBean='false'/>
@@ -41,19 +41,9 @@
<String id="factorPath" javaBean="null"/>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_CONTINUE_SELECTED, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ((Boolean)evt.getNewValue()) {
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "continuousPanelContainer");
- } else {
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "discretePanelContainer");
- }
- }
- });
-}
-
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
]]></script>
<Table constraints='BorderLayout.CENTER'>
<row>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -1,860 +0,0 @@
-/*
- * #%L
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2014 Ifremer, Codelutin, Chatellier Eric
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.sensitivity.wizard;
-
-import static org.nuiton.i18n.I18n.t;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.text.JTextComponent;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.math.matrix.gui.MatrixPanelEditor;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaEntityContextable;
-
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.RuleStorage;
-import fr.ifremer.isisfish.entities.Equation;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.rule.Rule;
-import fr.ifremer.isisfish.simulator.sensitivity.Domain;
-import fr.ifremer.isisfish.simulator.sensitivity.Factor;
-import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.types.RangeOfValues;
-import fr.ifremer.isisfish.types.TimeStep;
-import fr.ifremer.isisfish.types.TimeUnit;
-import fr.ifremer.isisfish.ui.SimulationUI;
-import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
-import fr.ifremer.isisfish.ui.simulator.RuleChooser;
-import fr.ifremer.isisfish.ui.simulator.SimulAction;
-import fr.ifremer.isisfish.ui.widget.editor.MonthComponent;
-import fr.ifremer.isisfish.ui.widget.editor.StepComponent;
-
-/**
- * Handler for all class in wizard packages.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SensitivityWizardHandler {
-
- /** Class logger. */
- private static Log log = LogFactory.getLog(SensitivityWizardHandler.class);
-
- /**
- * Return opened topia context that need to be closed.
- *
- * There is several things in ugly jaxx context:
- * <ul>
- * <li>opened TopiaContext from SensitivityTabUI that is null in ParamUI
- * <li>RegionStorage on SimulAction
- * </ul>
- *
- * Use region storage here.
- *
- * @return opened topia context
- * @throws TopiaException
- */
- protected TopiaContext getTopiaContext(FactorWizardUI factorWizardUI) throws TopiaException {
- // RegionStorage object is common to ParamsUI
- // and SensitivityTabUI and may be valued
- RegionStorage regionStorage = factorWizardUI.getContextValue(RegionStorage.class);
- TopiaContext context = regionStorage.getStorage().beginTransaction();
- return context;
- }
-
- /**
- * Initialize un nouveau wizard avec lorsque l'utilisateur clic sur
- * un layer sont le sous composant accepte la mise en facteur.
- *
- * On recupere des info sur le type correspondant à la proprieté a mettre
- * en facteur pour savoir le composant d'edition et s'il peut etre continue
- * ou pas.
- *
- * @param factorWizardUI factorWizardUI
- * @param bean bean in current ui
- * @param property bean property to edit
- */
- public void initNewFactor(FactorWizardUI factorWizardUI, TopiaEntityContextable bean, String property) {
-
- // path is topiaId#property
- // ex : fwn#fsd#0.3425345#name
- // for JAXX : cOrigine start with upper case
- // for commons beanutils : must be lower case
- String beanProperty = StringUtils.uncapitalize(property);
- String path = bean.getTopiaId() + "#" + beanProperty;
- factorWizardUI.setFactorPath(path);
- factorWizardUI.getFactorNameField().setText(bean.toString() + "." + beanProperty);
-
- // get value for pointed path
- //TopiaContext topiaContext = factorWizardUI.getContextValue(TopiaContext.class);
- //Class<?> classForPath = getPropertyClass(path, topiaContext);
- // peut etre pas une bonne idée que ce soit basé sur les valeurs
- // au lieu des types (mais pour RangeOfValues, pas evident)
- try {
- Object valueForPath = PropertyUtils.getProperty(bean, beanProperty);
- boolean continuePossible = SensitivityUtils.canBeContinue(valueForPath);
- boolean continueSelected = SensitivityUtils.isContinue(valueForPath);
-
- // init panel
- if (continuePossible) {
- JComponent comp = getContinuousPanel(valueForPath, bean, property);
- factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
- }
-
- // after, for binding on continuePossible, continueSelected to work
- factorWizardUI.setContinuePossible(continuePossible);
- factorWizardUI.setContinueSelected(continueSelected);
- factorWizardUI.getContinueRadio().setSelected(continueSelected);
- } catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't init wizard", ex);
- }
- }
-
- /**
- * Appelé suite a un double clic sur l'arbre des facteurs pour modifier un
- * facteur.
- *
- * @param factorWizardUI view to init
- * @param factor factor factor to edit
- */
- public void initExistingFactor(FactorWizardUI factorWizardUI, Factor factor) {
-
- factorWizardUI.setEditingState(true);
- String factorPath = factor.getPath();
- Domain domain = factor.getDomain();
- String factorName = factor.getName();
- factorWizardUI.setFactorPath(factorPath);
- factorWizardUI.getComment().setText(factor.getComment());
-
- if (domain instanceof ContinuousDomain) {
-
- ContinuousPanel comp = getNewContinuousComponent(factorWizardUI, factor.getPath());
- comp.initWithFactor(factor);
- factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
-
- factorWizardUI.getContinueRadio().setSelected(true);
- factorWizardUI.setContinueSelected(true);
- factorWizardUI.setContinuePossible(true);
- } else {
-
- // un facteur pour être edité sans domain
- // lors de la creation
- if (domain != null) {
- // restaure discrete domain
- DiscreteDomain dDomain = (DiscreteDomain)domain;
-
- int nb = dDomain.getValues().size();
- factorWizardUI.getDiscretNumber().setText(String.valueOf(nb));
- factorWizardUI.getTabPane().removeAll();
-
- SortedMap<Object, Object> values = dDomain.getValues();
- int i = 0;
- for (Object o : values.values()) {
- i++;
- JComponent c = null;
- if (o != null) {
- c = getEditorWithValue(factorWizardUI, factor, dDomain, o);
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Null value in factor");
- }
- }
- JScrollPane js = new JScrollPane(c);
- String tabName = t("isisfish.sensitivity.discretevaluelabel", i);
- factorWizardUI.getTabPane().addTab(tabName, js);
- }
- }
-
- // init non selected continous panel
- JComponent comp = getNewContinuousComponent(factorWizardUI, factor.getPath());
- if (comp != null) {
- factorWizardUI.setContinuePossible(true);
- factorWizardUI.getContinuousPanelContainer().add(comp, BorderLayout.CENTER);
- }
- }
-
- factorWizardUI.getFactorNameField().setText(factorName);
- }
-
- /**
- * Renvoie un componsant gaphique initialisé avec la valeur
- * qui est enregistré dans le domain.
- * Pour réédition d'un facteur existant (facteur discret).
- *
- * @param factorWizardUI context for context value (RegionStorage)
- * @param value type to get editor
- * @param factor factor for path value
- * @param domain domain for domain type
- * @return component ui component with value
- */
- protected JComponent getEditorWithValue(FactorWizardUI factorWizardUI, Factor factor, Domain domain, Object value) {
-
- JComponent result = null;
-
- if (Double.class.isAssignableFrom(value.getClass())) {
- result = new JTextField();
- ((JTextField)result).setText(String.valueOf(value));
- }
- else if (double.class.isAssignableFrom(value.getClass())) {
- result = new JTextField();
- ((JTextField)result).setText(String.valueOf(value));
- }
- else if (MatrixND.class.isAssignableFrom(value.getClass())) {
- result = new MatrixPanelEditor();
- ((MatrixPanelEditor)result).setMatrix((MatrixND)value);
- }
- else if (domain instanceof RuleDiscreteDomain) {
- result = new RuleChooser(factorWizardUI);
- ((RuleChooser)result).setRulesList((List<Rule>)value);
- }
- else if (domain instanceof EquationDiscreteDomain) {
- String factorPath = factor.getPath();
- if (factor.getPath().indexOf('#') != -1) {
- String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
- String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
-
- // get bean in database
- try {
- TopiaContext topiaContext = getTopiaContext(factorWizardUI);
- TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
- Equation equation = (Equation)PropertyUtils.getProperty(entity, property);
- topiaContext.closeContext();
-
- // fill component
- InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
- ui.setAutoSaveModification(false);
- ui.setFormuleCategory(equation.getCategory());
- ui.setText(t("isisfish.common.equation")); // can't get real name
- ui.setClazz(value.getClass());
- ui.setBeanProperty(property);
- ui.setBean(entity); // set bean fire content modification event
- ui.getEditor().setText((String)value);
- ui.setActive(true);
-
- result = ui;
- } catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't restore initial factor database property", ex);
- }
- }
- // TODO path with no # (normalement pas possible pour les equations)
- }
- else if (value instanceof TimeUnit) {
- result = new JTextField();
- ((JTextField)result).setText(String.valueOf(((TimeUnit)value).getTime()));
- } else if (value instanceof TopiaEntity) {
- RegionStorage regionStorage = factorWizardUI.getContextValue(RegionStorage.class);
- TopiaContext context = null;
- try {
- context = regionStorage.getStorage().beginTransaction();
- List list = context.findAll("from " + value.getClass().getName());
- JComboBox c = new JComboBox<>(list.toArray());
- c.setSelectedItem(value);
- result = c;
- } catch (TopiaException ex) {
- throw new IsisFishRuntimeException("Can't get entity list", ex);
- } finally {
- if (context != null) {
- try {
- context.closeContext();
- } catch (TopiaException ex) {
- throw new IsisFishRuntimeException("Can't get entity list", ex);
- }
- }
- }
- } else if (value instanceof TimeStep) {
- TimeStep timeStep = (TimeStep)value;
- result = new StepComponent(timeStep.getMonth().getMonthNumber(), timeStep.getYear());
- } else if (value instanceof Month) {
- Month month = (Month)value;
- result = MonthComponent.createMounthCombo(month.getMonthNumber());
- } else if (value instanceof String) {
- // valeur non typées ???
- result = new JTextField();
- ((JTextField)result).setText(String.valueOf(value));
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Editor for value " + value + " is " + result);
- }
-
- return result;
- }
-
- /**
- * Retourne le componant permettant de mettre en facteur continue
- * une valeur.
- *
- * @param value value (must be continuable)
- * @param bean bean (in case of equation)
- * @param property bean property (in case of equation)
- * @return component initialized
- */
- protected ContinuousPanel getContinuousPanel(Object value, TopiaEntityContextable bean, String property) {
- ContinuousPanel result;
-
- if (value instanceof RangeOfValues) {
- RangeOfValues rangeOfValues = (RangeOfValues)value;
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- String values = rangeOfValues.getValues();
- String min = "0";
- //String max = "0";
- if (values.matches("^\\ *[0-9]*\\ *\\-\\ *[0-9]*\\ *$")) {
- int first = values.indexOf("-");
- if (first != -1) {
- min = values.substring(0, first);
- //max = values.substring(first + 1);
- }
- }
- //ui.init(min, max, min, null);
- //result = ui;
- result = new ContinuousDistributionPanel(min);
- } else if (value instanceof Equation) {
- Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
- ui.setSelectedEquation(equation);
- ui.setText(t("isisfish.common.equation")); // can't get real name
- ui.setFormuleCategory(equation.getCategory());
- ui.setClazz(equation.getClass());
- ui.setBeanProperty(property);
- ui.setBean(bean);
- result = ui;
- } else if (value instanceof MatrixND) {
- MatrixND matrix = (MatrixND)value;
- result = new ContinuousDistributionPanel(matrix.clone());
- } else if (value instanceof TimeUnit) {
- TimeUnit timeUnit = (TimeUnit)value;
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- //ui.init(String.valueOf(timeUnit.getTime()), String.valueOf(timeUnit.getTime()),
- // String.valueOf(timeUnit.getTime()), null);
- //result = ui;
- result = new ContinuousDistributionPanel(String.valueOf(timeUnit.getTime()));
- } else {
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- //ui.init(String.valueOf(value), String.valueOf(value), String.valueOf(value), null);
- //result = ui;
- result = new ContinuousDistributionPanel(String.valueOf(value));
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Component for " + value + " (" + bean + ", " + property + ")");
- log.debug(" > " + result);
- }
-
- return result;
- }
-
- /**
- * Rafraichit l'assistant de facteur pour modifier le nombre de valeurs
- * (onglet) d'un composant discret.
- *
- * @param factorWizardUI factorWizardUI
- */
- public void addTabs(FactorWizardUI factorWizardUI) {
- String discreteNumber = factorWizardUI.getDiscretNumber().getText();
- int nbTab = Integer.parseInt(discreteNumber);
- int currentCount = factorWizardUI.getTabPane().getTabCount();
-
- // remove useless tab
- for (int tab = currentCount - 1; tab > nbTab -1 ; tab--) {
- factorWizardUI.getTabPane().remove(tab);
- }
-
- // add new tabs
- for (int tab = currentCount ; tab < nbTab ; tab++) {
- JComponent c = getNewDiscreteComponent(factorWizardUI);
- String tabName = t("isisfish.sensitivity.discretevaluelabel", tab);
- factorWizardUI.getTabPane().addTab(tabName, c);
- }
-
- factorWizardUI.pack();
- }
-
- /**
- * Return new discrete component inited with value defined by factor path.
- *
- * Le composant retourné est inclut dans un jscrollpane (sauf pour les
- * matrices qui contient deja un jscrollpane)
- *
- * @param factorWizardUI factorWizardUI
- * @return component copy
- */
- protected JComponent getNewDiscreteComponent(FactorWizardUI factorWizardUI) {
-
- JComponent result = null;
- String factorPath = factorWizardUI.getFactorPath();
-
- try {
- if (factorPath.indexOf('#') != -1) {
- String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
- String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
-
- // get bean in database
- TopiaContext topiaContext = getTopiaContext(factorWizardUI);
- TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
- Object value = PropertyUtils.getProperty(entity, property);
-
- // init new jcomponent for value
- if (value instanceof Number) {
- result = new JTextField(String.valueOf(value));
- } else if (value instanceof MatrixND) {
- result = new MatrixPanelEditor();
- MatrixND matrix = ((MatrixND)value).copy();
- ((MatrixPanelEditor)result).setMatrix(matrix);
- } else if (value instanceof RangeOfValues) {
- RangeOfValues rangeOfValues = (RangeOfValues)value;
- result = new JTextField(rangeOfValues.getValues());
- } else if (value instanceof TimeUnit) {
- TimeUnit timeUnit = (TimeUnit)value;
- result = new JTextField(String.valueOf(timeUnit.getTime()));
- } else if (value instanceof Equation) {
- Equation equation = (Equation)value;
- // fill component
- InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
- ui.setAutoSaveModification(false);
- ui.setText(equation.getContent());
- ui.setFormuleCategory(equation.getCategory());
- ui.setText(t("isisfish.common.equation")); // can't get real name
- ui.setClazz(value.getClass());
- ui.setBeanProperty(property);
- ui.setBean(entity);
- ui.setActive(true);
- result = ui;
- }
-
- topiaContext.closeContext();
-
- }
- else {
- // dans ce cas c'est des regles, pop de départ ou parametres de regles
- // c'est un peu galere car le code n'a rien a voir avec le reste
- // donc, c'est du cas par cas
- if (factorPath.equals("parameters.rules")) {
- result = new RuleChooser(factorWizardUI);
- } else if (factorPath.startsWith("parameters.population.")) {
- // la seule facon d'avoir les parametres ici est d'aller
- // les chercher dans les parametres de simulation
- Pattern pattern = Pattern.compile("^parameters\\.population\\.(\\w+)(\\.(.+)?)$");
- Matcher matcher = pattern.matcher(factorPath);
- if (matcher.matches()) {
- String populationName = matcher.group(1);
- if (log.isDebugEnabled()) {
- log.debug("Loading population : " + populationName);
- }
- TopiaContext topiaContext = getTopiaContext(factorWizardUI);
- Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName);
- SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
- MatrixND N = action.getSimulationParameter().getNumberOf(pop);
- result = new MatrixPanelEditor();
- ((MatrixPanelEditor)result).setMatrix(N.clone());
- topiaContext.closeContext();
- }
- } else if (factorPath.startsWith("parameters.rule.")) {
- Pattern pattern = Pattern.compile("^parameters\\.rule\\.(\\d+)\\.parameter\\.(\\w+)(\\..+)?$");
- Matcher matcher = pattern.matcher(factorPath);
- if (matcher.matches()) {
- int ruleIndex = Integer.parseInt(matcher.group(1));
- SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
- Rule rule = action.getSimulationParameter().getRules().get(ruleIndex);
- Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2));
- Object value = RuleStorage.getParameterValue(rule, matcher.group(2));
- result = getTypeDiscreteComponent(factorWizardUI, valueClazz, value);
-
- } else {
- // double...
- result = new JTextField("0.0");
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Can't find component for path " + factorPath);
- }
- }
- }
- } catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't restore intial factor database property", ex);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Component for path " + factorPath + " is " + result);
- }
-
- // hack : si on met 2 fois un jscrollpane, rien ne s'affiche
- if (!(result instanceof MatrixPanelEditor)) {
- result = new JScrollPane(result);
- }
-
- return result;
- }
-
- /**
- * Return new continuous component inited with value defined by factor path.
- *
- * @param factorWizardUI (to use topia context)
- * @param factorPath factor path
- * @return component initialized
- */
- protected ContinuousPanel getNewContinuousComponent(FactorWizardUI factorWizardUI, String factorPath) {
- ContinuousPanel result = null;
-
- try {
- if (factorPath.indexOf('#') != -1) {
- String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
- String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
-
- // get bean in database
- TopiaContext topiaContext = getTopiaContext(factorWizardUI);
- TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
- Object value = PropertyUtils.getProperty(entity, property);
-
- if (value instanceof RangeOfValues) {
- RangeOfValues rangeOfValues = (RangeOfValues)value;
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- String values = rangeOfValues.getValues();
- String min = "0";
- String max = "0";
- if (values.matches("^\\ *[0-9]*\\ *\\-\\ *[0-9]*\\ *$")) {
- int first = values.indexOf("-");
- if (first != -1) {
- min = values.substring(0, first);
- max = values.substring(first + 1);
- }
- }
- result = new ContinuousDistributionPanel(min);
- } else if (value instanceof Equation) {
- Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
- ui.setSelectedEquation(equation);
- ui.setText(t("isisfish.common.equation")); // can't get real name
- ui.setFormuleCategory(equation.getCategory());
- ui.setClazz(equation.getClass());
- ui.setBeanProperty(property);
- ui.setBean(entity);
- result = ui;
- } else if (value instanceof MatrixND) {
- MatrixND matrix = (MatrixND)value;
- result = new ContinuousDistributionPanel(matrix.clone());
- } else if (value instanceof TimeUnit) {
- TimeUnit timeUnit = (TimeUnit)value;
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- //ui.init(String.valueOf(timeUnit.getTime()), String.valueOf(timeUnit.getTime()),
- // String.valueOf(timeUnit.getTime()), null);
- //result = ui;
- result = new ContinuousDistributionPanel(String.valueOf(timeUnit.getTime()));
- } else {
- //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI();
- //ui.init(String.valueOf(value), String.valueOf(value), String.valueOf(value), null);
- //result = ui;
- result = new ContinuousDistributionPanel(String.valueOf(value));
- }
-
- topiaContext.closeContext();
-
- } else {
- if (factorPath.startsWith("parameters.population.")) {
- // la seule facon d'avoir les parametres ici est d'aller
- // les chercher dans les parametres de simulation
- Pattern pattern = Pattern.compile("^parameters\\.population\\.(\\w+)(\\.(.+)?)$");
- Matcher matcher = pattern.matcher(factorPath);
- if (matcher.matches()) {
- String populationName = matcher.group(1);
- if (log.isDebugEnabled()) {
- log.debug("Loading population : " + populationName);
- }
- TopiaContext topiaContext = getTopiaContext(factorWizardUI);
- Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName);
- SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
- MatrixND N = action.getSimulationParameter().getNumberOf(pop);
- result = new ContinuousDistributionPanel(N.clone());
- topiaContext.closeContext();
- }
- } else if (factorPath.startsWith("parameters.rule.")) {
- Pattern pattern = Pattern.compile("^parameters\\.rule\\.(\\d+)\\.parameter\\.(\\w+)(\\..+)?$");
- Matcher matcher = pattern.matcher(factorPath);
- if (matcher.matches()) {
- int ruleIndex = Integer.parseInt(matcher.group(1));
- SimulAction action = factorWizardUI.getContextValue(SimulAction.class);
- Rule rule = action.getSimulationParameter().getRules().get(ruleIndex);
- Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2));
- Object value = RuleStorage.getParameterValue(rule, matcher.group(2));
- result = getTypeContinousComponent(factorWizardUI, valueClazz, value);
-
- } else {
- // double...
- result = getContinuousPanel(0.0, null, null);
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Can't find component for path " + factorPath);
- }
- }
- }
- } catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't init wizard", ex);
- }
-
- return result;
- }
-
- /**
- * Get new special component for typed parameters.
- *
- * @param factorWizardUI
- * @param type
- * @return rule discrete component
- */
- protected JComponent getTypeDiscreteComponent(FactorWizardUI factorWizardUI, Class type, Object value) {
-
- JComponent result = null;
-
- if (TopiaEntity.class.isAssignableFrom(type)) {
- try {
- TopiaContext context = getTopiaContext(factorWizardUI);
- List list = context.findAll("from " + type.getName());
- JComboBox c = new JComboBox(list.toArray());
- result = c;
- context.closeContext();
- } catch (TopiaException ex) {
- throw new IsisFishRuntimeException("Can't get entity list", ex);
- }
- } else if (TimeStep.class.isAssignableFrom(type)) {
- result = new StepComponent(0, 0);
- } else if (Month.class.isAssignableFrom(type)) {
- result = MonthComponent.createMounthCombo(0);
- } else {
- if (value != null) {
- result = new JTextField(value.toString());
- } else {
- result = new JTextField();
- }
-
- }
-
- return result;
- }
-
- /**
- * Get new special component for typed parameters.
- *
- * @param factorWizardUI
- * @param type type to get component
- * @return rule discrete component
- */
- protected ContinuousPanel getTypeContinousComponent(FactorWizardUI factorWizardUI, Class type, Object value) {
-
- ContinuousPanel result = null;
-
- if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
- if (value != null) {
- result = new ContinuousDistributionPanel(value.toString());
- } else {
- result = new ContinuousDistributionPanel(0.0);
- }
- }
-
- return result;
- }
-
- /**
- * Save current factor.
- *
- * @param factorWizardUI factorWizardUI
- */
- public void save(FactorWizardUI factorWizardUI) {
-
- // get continuous component if any
- ContinuousPanel continuousPanel = null;
- if (factorWizardUI.getContinuousPanelContainer().getComponentCount() > 0) {
- continuousPanel = (ContinuousPanel)factorWizardUI.getContinuousPanelContainer().getComponent(0);
- }
-
- // first check is factor is valid
- boolean factorValid = true;
- if (continuousPanel != null) {
- factorValid = continuousPanel.isFactorValid();
- }
- if (!factorValid) {
- JOptionPane.showMessageDialog(factorWizardUI, t("isisfish.sensitivity.factor.notvalid"),
- t("isisfish.sensitivity.title"), JOptionPane.ERROR_MESSAGE);
- return;
- }
-
- // call specific method depending on continuous/discrete
- if (factorWizardUI.getContinueRadio().isSelected()) {
- saveContinue(factorWizardUI.getFactorNameField().getText(),
- factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), continuousPanel,
- factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState());
- } else {
- Component[] discreteComponents = factorWizardUI.getTabPane().getComponents();
- saveDiscret(factorWizardUI.getFactorNameField().getText(),
- factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), discreteComponents,
- factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState());
- }
-
- // refresh factor list
- factorWizardUI.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree();
-
- // close window
- factorWizardUI.dispose();
- }
-
- /**
- * Save a continous factor.
- *
- * @param name factor name
- * @param comment comment
- * @param path factor path
- * @param panel panel
- * @param action action
- * @param exist exist
- */
- protected void saveContinue(String name,
- String comment, String path, ContinuousPanel panel,
- SimulAction action, boolean exist) {
- if (panel instanceof EquationContinuousPanelUI) {
- try {
- EquationContinuousPanelUI equationPanel = (EquationContinuousPanelUI) panel;
- String property = StringUtils.uncapitalize(equationPanel.getBeanProperty()) + "Content";
- TopiaEntityContextable bean = equationPanel.getBean();
- TopiaContext topiaContext = bean.getTopiaContext();
- PropertyUtils.setProperty(bean, property, equationPanel.getEditor().getEditor().getText());
-
- // Save equation
- bean.update();
- topiaContext.commitTransaction();
-
- List<Factor> factors = equationPanel.getFactors();
- for (Factor factor : factors) {
- factor.setName(name);
- factor.setComment(comment);
- factor.setPath(path);
- action.addContinuousEquationFactor(factor, exist);
- }
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't call method : ", ex);
- }
- }
- } else if (panel instanceof ContinuousDistributionPanel) {
- ContinuousDistributionPanel defaultPanel = (ContinuousDistributionPanel) panel;
- ContinuousDomain domain = defaultPanel.generateDomain();
- action.addContinuousFactor(name, comment, path, domain, exist);
- }
- }
-
- /**
- * Save a discret factor.
- *
- * @param name
- * @param comment
- * @param path
- * @param components
- * @param action
- * @param exist
- */
- protected void saveDiscret(String name,
- String comment, String path, Component[] components,
- SimulAction action, boolean exist) {
- List<Object> values = new ArrayList<Object>();
-
- boolean ruleFactor = false;
- boolean equationFactor = false;
- for (Component component : components) {
-
- if (component instanceof JScrollPane) {
- component = ((JScrollPane) component).getViewport().getView();
- }
-
- // get internat component value
- Object result = null;
- if (component instanceof JTextComponent) {
- result = ((JTextComponent) component).getText();
- } else if (component instanceof MatrixPanelEditor) {
- result = ((MatrixPanelEditor) component).getMatrix();
- } else if (component instanceof InputOneEquationUI) {
- result = ((InputOneEquationUI) component).getEditor().getText();
- equationFactor = true;
- } else if (component instanceof RuleChooser) {
- result = ((RuleChooser)component).getRulesList();
- ruleFactor = true;
- } else if (component instanceof StepComponent) {
- result = new TimeStep(((StepComponent)component).getSelectedValue());
- } else if (component instanceof MonthComponent) {
- result = new Month(((MonthComponent)component).getSelectedValue());
- } else if (component instanceof JComboBox) {
- // on suppose qu'il y a dedans des TopiaEntity
- result = ((JComboBox)component).getSelectedItem();
- }
-
- values.add(result);
- }
-
- if (ruleFactor) {
- action.addDiscreteRuleFactor(name, comment, path, values, exist);
- } else if (equationFactor) {
- action.addDiscreteEquationFactor(name, comment, path, values, exist);
- } else {
- action.addDiscreteFactor(name, comment, path, values, exist);
- }
- }
-
- /**
- * Remove current factor.
- *
- * @param factorWizardUI factorWizardUI
- */
- public void remove(FactorWizardUI factorWizardUI) {
- factorWizardUI.getContextValue(SimulAction.class).removeFactor(factorWizardUI.getFactorPath());
- factorWizardUI.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree();
- factorWizardUI.dispose();
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -39,7 +39,7 @@
*
* @author Eric Chatellier
*/
-public class AdvancedParamsHandler extends SimulationTabHandler {
+public class AdvancedParamsHandler extends SimulatorTabHandler {
/** Class logger. */
private static final Log log = LogFactory.getLog(AdvancedParamsHandler.class);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -40,7 +40,7 @@
*
* @author Eric Chatellier
*/
-public class ExportHandler extends SimulationTabHandler {
+public class ExportHandler extends SimulatorTabHandler {
/** Class logger. */
private static final Log log = LogFactory.getLog(ExportHandler.class);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -59,11 +59,11 @@
import fr.ifremer.isisfish.ui.models.optimization.ExportObservationTableModel;
import fr.ifremer.isisfish.ui.models.optimization.ExportTableCellEditor;
import fr.ifremer.isisfish.ui.models.optimization.ExportTableCellRenderer;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputUI;
import fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
import fr.ifremer.isisfish.ui.widget.editor.FactorEditorListener;
-public class OptimizationHandler extends SimulationTabHandler {
+public class OptimizationHandler extends SimulatorTabHandler {
private static final Log log = LogFactory.getLog(OptimizationHandler.class);
@@ -184,7 +184,7 @@
public void actionPerformed(ActionEvent event) {
// init new sensitivity tav ui hierarchy
- final SensitivityTabUI sensitivityTabUI = new SensitivityTabUI(tabUI);
+ final SensitivityInputUI sensitivityTabUI = new SensitivityInputUI(tabUI);
sensitivityTabUI.setContextValue(new SensitivitySaveVerifier()); // prevent NPE
sensitivityTabUI.setContextValue(tabUI.getParentContainer(SimulationUI.class), "SimulationUI"); // prevent NPE
@@ -196,7 +196,7 @@
TopiaContext tx = regionStorage.getStorage().beginTransaction();
FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx);
sensitivityTabUI.setFisheryRegion(fisheryRegion);
- sensitivityTabUI.setTreeModel();
+ sensitivityTabUI.getHandler().setTreeModel();
} catch (Exception ex) {
throw new IsisFishRuntimeException("Can't init dialog tree", ex);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -60,7 +60,7 @@
*
* @author Eric Chatellier
*/
-public class ParamsHandler extends SimulationTabHandler {
+public class ParamsHandler extends SimulatorTabHandler {
/** Class logger. */
private static final Log log = LogFactory.getLog(ParamsHandler.class);
@@ -178,8 +178,8 @@
// and can't be closed because used in
TopiaContext tx = getSimulAction().getRegionStorage().getStorage().beginTransaction();
FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx);
- tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFisheryRegion(fisheryRegion);
- tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setTreeModel();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityInputUI().setFisheryRegion(fisheryRegion);
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityInputUI().getHandler().setTreeModel();
} catch (StorageException ex) {
if (log.isErrorEnabled()) {
log.error("Can't reload factors", ex);
@@ -193,9 +193,9 @@
}
protected void initSensitivityParams() {
if (tabUI.isSensitivity()) {
- tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().refreshSelectedSensitivityAnalysis();
- tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFactorModel();
- tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().setSensitivityExportListModel();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().getHandler().refreshSelectedSensitivityAnalysis();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityInputUI().getHandler().setFactorModel();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().getHandler().setSensitivityExportListModel();
tabUI.sensitivityOnlyKeepFirstResultCheckBox.setSelected(getSimulAction().getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst());
}
}
@@ -276,7 +276,7 @@
protected void setListSimulParamsStrategiesItems() {
List<Strategy> strategiesSelected = getSimulAction().getSimulationParameter().getStrategies();
- DefaultListModel listSimulParamsStrategiesModel = new DefaultListModel();
+ DefaultListModel<Strategy> listSimulParamsStrategiesModel = new DefaultListModel<Strategy>();
List<Strategy> strategies = getSimulAction().getStrategies();
for (Strategy s : strategies){
listSimulParamsStrategiesModel.addElement(s);
@@ -292,7 +292,7 @@
}
protected void setListSimulParamsPopulationsItems(){
List<Population> populationsSelected = getSimulAction().getSimulationParameter().getPopulations();
- DefaultListModel listSimulParamsPopulationsModel = new DefaultListModel();
+ DefaultListModel<Population> listSimulParamsPopulationsModel = new DefaultListModel<Population>();
List<Population> populations = getSimulAction().getPopulations();
for (Population p : populations){
listSimulParamsPopulationsModel.addElement(p);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -42,7 +42,7 @@
*
* @author Eric Chatellier
*/
-public class PlanHandler extends SimulationTabHandler {
+public class PlanHandler extends SimulatorTabHandler {
protected PlanUI tabUI;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -27,7 +27,7 @@
*
* @author Eric Chatellier
*/
-public class PreScriptsHandler extends SimulationTabHandler {
+public class PreScriptsHandler extends SimulatorTabHandler {
protected PreScriptsUI tabUI;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -36,7 +36,7 @@
*
* @author Eric Chatellier
*/
-public class ResultChoiceHandler extends SimulationTabHandler {
+public class ResultChoiceHandler extends SimulatorTabHandler {
protected ResultChoiceUI tabUI;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -102,8 +102,8 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
import fr.ifremer.isisfish.ui.SimulationUI;
import fr.ifremer.isisfish.ui.sensitivity.SensitivityChooserUI;
+import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardHandler;
import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI;
-import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.ScriptParameterDialog;
import jaxx.runtime.SwingUtil;
@@ -1233,7 +1233,7 @@
if (selectedFactor != null) {
FactorWizardUI wizard = new FactorWizardUI(paramsUI);
- SensitivityWizardHandler handler = wizard.getHandler();
+ FactorWizardHandler handler = wizard.getHandler();
handler.initExistingFactor(wizard, selectedFactor);
wizard.pack();
wizard.setLocationRelativeTo(paramsUI);
@@ -1288,7 +1288,7 @@
rule.getClass().getSimpleName(), paramName));
factor.setPath(factorPath);
FactorWizardUI factorWizardUI = new FactorWizardUI(ruleChooser);
- SensitivityWizardHandler handler = factorWizardUI.getHandler();
+ FactorWizardHandler handler = factorWizardUI.getHandler();
handler.initExistingFactor(factorWizardUI, factor);
factorWizardUI.pack();
factorWizardUI.setLocationRelativeTo(ruleChooser);
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -1,44 +0,0 @@
-package fr.ifremer.isisfish.ui.simulator;
-
-import fr.ifremer.isisfish.simulator.SimulationParameter;
-import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
-import fr.ifremer.isisfish.ui.CommonHandler;
-import jaxx.runtime.JAXXContext;
-
-/**
- * Handler common à tous les handler de chaque onglet de l'interface de simulation.
- *
- * @author Eric Chatellier
- */
-public abstract class SimulationTabHandler extends CommonHandler {
-
- // TODO might be something else, like SimulatorTabUI ?
- protected JAXXContext simulationUI;
-
- protected SimulationTabHandler(JAXXContext simulationUI) {
- this.simulationUI = simulationUI;
- }
-
- /**
- * Return simulation parameters from context.
- *
- * @return SimulationParameter
- */
- protected SimulationParameter getParameters() {
- return simulationUI.getContextValue(SimulationParameter.class);
- }
-
- /**
- * Return FactorGroup from context.
- *
- * @return FactorGroup
- */
- protected FactorGroup getFactorGroup() {
- return simulationUI.getContextValue(FactorGroup.class);
- }
-
- @Deprecated
- protected SimulAction getSimulAction() {
- return simulationUI.getContextValue(SimulAction.class);
- }
-}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java (from rev 4231, trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -0,0 +1,44 @@
+package fr.ifremer.isisfish.ui.simulator;
+
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
+import fr.ifremer.isisfish.ui.CommonHandler;
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Handler common à tous les handler de chaque onglet de l'interface de simulation.
+ *
+ * @author Eric Chatellier
+ */
+public abstract class SimulatorTabHandler extends CommonHandler {
+
+ // TODO might be something else, like SimulatorTabUI ?
+ protected JAXXContext simulationUI;
+
+ protected SimulatorTabHandler(JAXXContext simulationUI) {
+ this.simulationUI = simulationUI;
+ }
+
+ /**
+ * Return simulation parameters from context.
+ *
+ * @return SimulationParameter
+ */
+ protected SimulationParameter getParameters() {
+ return simulationUI.getContextValue(SimulationParameter.class);
+ }
+
+ /**
+ * Return FactorGroup from context.
+ *
+ * @return FactorGroup
+ */
+ protected FactorGroup getFactorGroup() {
+ return simulationUI.getContextValue(FactorGroup.class);
+ }
+
+ @Deprecated
+ protected SimulAction getSimulAction() {
+ return simulationUI.getContextValue(SimulAction.class);
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/widget/Interval.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/widget/Interval.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/widget/Interval.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -213,18 +213,6 @@
}
/**
- * Retourne une chaine XML qui represente l'objet.
- *
- * @deprecated since 20090414 (unused)
- * @return interval representation as xml
- */
- public String toXML() {
- return "<Interval min=\"" + getMin() + "\" max=\"" + getMax()
- + "\" first=\"" + getFirst() + "\" last=\"" + getLast()
- + "\"/>";
- }
-
- /**
* @return une iteration
*/
public Iterator<Integer> iterator() {
Modified: trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
===================================================================
--- trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-22 15:56:58 UTC (rev 4232)
+++ trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-22 16:10:26 UTC (rev 4233)
@@ -56,7 +56,7 @@
public void setUp() {
WelcomeUI frame = GuiActionRunner.execute(new GuiQuery<WelcomeUI>() {
protected WelcomeUI executeInEDT() {
- return new WelcomeUI();
+ return new WelcomeUI(new WelcomeContext());
}
});
mainWindow = new FrameFixture(frame);
1
0
Author: echatellier
Date: 2015-05-22 15:56:58 +0000 (Fri, 22 May 2015)
New Revision: 4232
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4232
Log:
Update hibernate & topia
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2015-05-21 13:11:05 UTC (rev 4231)
+++ trunk/pom.xml 2015-05-22 15:56:58 UTC (rev 4232)
@@ -539,8 +539,8 @@
<!-- Dependencies version -->
<jaxxVersion>2.24</jaxxVersion>
<eugeneVersion>2.14</eugeneVersion>
- <topiaVersion>2.9.5.3</topiaVersion>
- <hibernateVersion>4.3.9.Final</hibernateVersion>
+ <topiaVersion>2.9.5.5</topiaVersion>
+ <hibernateVersion>4.3.10.Final</hibernateVersion>
<nuitonI18nVersion>3.3</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
1
0
r4231 - in trunk/src/main/java/fr/ifremer/isisfish: . simulator/sensitivity ui ui/input ui/models/rule ui/script ui/script/model ui/sensitivity ui/sensitivity/wizard ui/simulator
by echatellier@users.forge.codelutin.com 21 May '15
by echatellier@users.forge.codelutin.com 21 May '15
21 May '15
Author: echatellier
Date: 2015-05-21 13:11:05 +0000 (Thu, 21 May 2015)
New Revision: 4231
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4231
Log:
Move script code to dedicated handler (simulator)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeContext.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContext.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
Modified:
trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityUtils.java
trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/script/model/ScriptTransferHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooser.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx
Modified: trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -78,6 +78,7 @@
import fr.ifremer.isisfish.datastore.SimulatorStorage;
import fr.ifremer.isisfish.simulator.launcher.SimulationMonitor;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
+import fr.ifremer.isisfish.ui.WelcomeContext;
import fr.ifremer.isisfish.ui.WelcomeTabUI;
import fr.ifremer.isisfish.ui.WelcomeUI;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
@@ -711,7 +712,8 @@
final SwingSession session = new SwingSession(sessionFile, true);
// lauch first UI (welcomeUI)
- WelcomeUI welcome = new WelcomeUI();
+ WelcomeContext welcomeContext = new WelcomeContext();
+ WelcomeUI welcome = new WelcomeUI(welcomeContext);
welcome.setTitle(t("isisfish.welcome.title", IsisConfig.getVersion()));
// Set to exit on close
welcome.setDefaultCloseOperation(WelcomeUI.DO_NOTHING_ON_CLOSE);
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityUtils.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityUtils.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityUtils.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -31,9 +31,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.persistence.TopiaEntity;
import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.RangeOfValues;
+import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.TimeUnit;
/**
@@ -172,4 +175,28 @@
}
return result;
}
+
+ /**
+ * Return if type can be defined as a factor.
+ *
+ * @param type type
+ * @return {@code true} if type can be defined as a factor
+ */
+ public static boolean canBeFactor(Class type) {
+ boolean result = false;
+
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+ result = true;
+ } else if (double.class.isAssignableFrom(type)) {
+ result = true;
+ } else if (Number.class.isAssignableFrom(type)) {
+ result = true;
+ } else if (TimeStep.class.isAssignableFrom(type)) {
+ result = true;
+ } else if (Month.class.isAssignableFrom(type)) {
+ result = true;
+ }
+
+ return result;
+ }
}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,163 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.tree.TreeModel;
+
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.entities.FisheryRegion;
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Observation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.Port;
+import fr.ifremer.isisfish.entities.SetOfVessels;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.entities.VesselType;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputContentUI;
+import fr.ifremer.isisfish.ui.input.cell.CellUI;
+import fr.ifremer.isisfish.ui.input.fisheryregion.FisheryRegionUI;
+import fr.ifremer.isisfish.ui.input.gear.GearUI;
+import fr.ifremer.isisfish.ui.input.metier.MetierUI;
+import fr.ifremer.isisfish.ui.input.observation.ObservationUI;
+import fr.ifremer.isisfish.ui.input.population.PopulationUI;
+import fr.ifremer.isisfish.ui.input.port.PortUI;
+import fr.ifremer.isisfish.ui.input.setofvessels.SetOfVesselsUI;
+import fr.ifremer.isisfish.ui.input.species.SpeciesUI;
+import fr.ifremer.isisfish.ui.input.strategy.StrategyUI;
+import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
+import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
+import fr.ifremer.isisfish.ui.input.triptype.TripTypeUI;
+import fr.ifremer.isisfish.ui.input.vesseltype.VesselTypeUI;
+import fr.ifremer.isisfish.ui.input.zone.ZoneUI;
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Handler for tree navigation related interfaces.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class NavigationHandler extends CommonHandler {
+
+ /**
+ * Cache pour n'instancier les ui qu'une seule fois
+ * et eviter que l'affichage saute pour l'utilsateur.
+ */
+ protected Map<Class<?>, InputContentUI<?>> uiInstanceCache = new HashMap<>();
+
+ /**
+ * Get ui that can display internalClass.
+ *
+ * @param internalClass internal class to get ui
+ * @return ui for class
+ * @throws Exception
+ */
+ protected InputContentUI<?> getUIInstanceForBeanClass(Class<?> internalClass, NavigationUI navigationUI) throws Exception {
+
+ Class<? extends InputContentUI<?>> uiClass = null;
+ if (FisheryRegion.class.isAssignableFrom(internalClass)) {
+ uiClass = FisheryRegionUI.class;
+ } else if (Cell.class.isAssignableFrom(internalClass)) {
+ uiClass = CellUI.class;
+ } else if (Gear.class.isAssignableFrom(internalClass)) {
+ uiClass = GearUI.class;
+ } else if (Metier.class.isAssignableFrom(internalClass)) {
+ uiClass = MetierUI.class;
+ } else if (Population.class.isAssignableFrom(internalClass)) {
+ uiClass = PopulationUI.class;
+ } else if (Port.class.isAssignableFrom(internalClass)) {
+ uiClass = PortUI.class;
+ } else if (SetOfVessels.class.isAssignableFrom(internalClass)) {
+ uiClass = SetOfVesselsUI.class;
+ } else if (Species.class.isAssignableFrom(internalClass)) {
+ uiClass = SpeciesUI.class;
+ } else if (Strategy.class.isAssignableFrom(internalClass)) {
+ uiClass = StrategyUI.class;
+ } else if (TripType.class.isAssignableFrom(internalClass)) {
+ uiClass = TripTypeUI.class;
+ } else if (VesselType.class.isAssignableFrom(internalClass)) {
+ uiClass = VesselTypeUI.class;
+ } else if (Zone.class.isAssignableFrom(internalClass)) {
+ uiClass = ZoneUI.class;
+ } else if (Observation.class.isAssignableFrom(internalClass)) {
+ uiClass = ObservationUI.class;
+ }
+
+ // use map to implement UI cache
+ InputContentUI<?> result = uiInstanceCache.get(uiClass);
+ if (result == null) {
+ Constructor<?> constructor = uiClass.getConstructor(JAXXContext.class);
+ result = (InputContentUI<?>)constructor.newInstance(navigationUI);
+
+ uiInstanceCache.put(uiClass, result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Change tree selection with new node id.
+ *
+ * Called by specific UI (CellUI to change node).
+ *
+ * @param inputUI context ui (to get context value tree helper...)
+ * @param nodeId node id to select
+ */
+ public void setTreeSelection(InputContentUI<?> inputUI, String nodeId) {
+ setTreeSelection(inputUI, null, nodeId);
+ }
+
+ /**
+ * Change tree selection with new node id.
+ *
+ * Called by specific UI (CellUI to change node).
+ *
+ * @param inputUI context ui (to get context value tree helper...)
+ * @param parentNodeId find node to select from this node
+ * @param nodeId node id to select
+ */
+ public void setTreeSelection(InputContentUI<?> inputUI, String parentNodeId, String nodeId) {
+ FisheryTreeHelper fisheryTreeHelper = inputUI.getContextValue(FisheryTreeHelper.class);
+ TreeModel fisheryTreeModel = inputUI.getContextValue(TreeModel.class);
+ FisheryTreeNode fromNode = (FisheryTreeNode)fisheryTreeModel.getRoot();
+ if (parentNodeId != null) {
+ fromNode = fisheryTreeHelper.findNode(fromNode, parentNodeId);
+ }
+ FisheryTreeNode newSelectNode = fisheryTreeHelper.findNode(fromNode, nodeId);
+ if (newSelectNode != null) {
+ fisheryTreeHelper.selectNode(newSelectNode);
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/NavigationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -25,13 +25,11 @@
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
-import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,13 +43,23 @@
/** Class logger. */
private static Log log = LogFactory.getLog(StatusBarHandler.class);
+ protected StatusBarUI statusBarUI;
+
/** Attribute used to remember screenshot last directory. */
protected JFileChooser screenshotFileChooser;
+ public StatusBarHandler(StatusBarUI statusBarUI) {
+ this.statusBarUI = statusBarUI;
+ }
+
+ public void afterInit() {
+
+ }
+
/**
* Ask user for screenshot save file and take screenshot to that file.
*/
- public void screenshot(Component parent) {
+ public void screenshot() {
if (screenshotFileChooser == null) {
screenshotFileChooser = new JFileChooser();
screenshotFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -66,6 +74,7 @@
}
// find parent
+ Component parent = statusBarUI;
while (!(parent instanceof WelcomeUI)) {
parent = parent.getParent();
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/StatusBarUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,10 +23,10 @@
#L%
-->
<Table>
- <StatusBarHandler id="handler" />
+ <StatusBarHandler id="handler" constructorParams="this" />
<script><![CDATA[
protected void $afterCompleteSetup() {
- //getHandler().postInit(this);
+ handler.afterInit();
}
/**
* Change status message and stop progress bar if running.
@@ -62,7 +62,7 @@
toolTipText="Stop the process" />
</cell> -->
<cell>
- <JLabel icon="camera.png" toolTipText="isisfish.status.screenshot" onMouseClicked="handler.screenshot(this)" />
+ <JLabel icon="camera.png" toolTipText="isisfish.status.screenshot" onMouseClicked="handler.screenshot()" />
</cell>
<cell fill="both">
<jaxx.runtime.swing.StatusMessagePanel />
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeContext.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeContext.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeContext.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,35 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui;
+
+import jaxx.runtime.context.JAXXInitialContext;
+
+public class WelcomeContext extends JAXXInitialContext {
+
+ protected WelcomeSaveVerifier verifier = new WelcomeSaveVerifier();
+
+ public WelcomeContext() {
+ add(verifier);
+ }
+
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeContext.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -40,10 +40,6 @@
import javax.swing.JFrame;
import javax.swing.ToolTipManager;
-import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.swing.config.ConfigUI;
-import jaxx.runtime.swing.config.ConfigUIHelper;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.widget.AboutFrame;
@@ -53,16 +49,18 @@
import fr.ifremer.isisfish.ui.config.RConfigHandler;
import fr.ifremer.isisfish.ui.config.RConfigUI;
import fr.ifremer.isisfish.ui.config.SSHLauncherConfigUI;
-import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
+import fr.ifremer.isisfish.ui.input.InputContext;
import fr.ifremer.isisfish.ui.input.InputUI;
import fr.ifremer.isisfish.ui.queue.QueueUI;
import fr.ifremer.isisfish.ui.result.ResultUI;
import fr.ifremer.isisfish.ui.script.ScriptUI;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityContext;
import fr.ifremer.isisfish.ui.sensitivity.SensitivityUI;
-import fr.ifremer.isisfish.ui.simulator.SimulAction;
import fr.ifremer.isisfish.ui.simulator.SimulUI;
+import fr.ifremer.isisfish.ui.simulator.SimulatorContext;
import fr.ifremer.isisfish.ui.vcs.VCSConfigUI;
+import jaxx.runtime.swing.config.ConfigUI;
+import jaxx.runtime.swing.config.ConfigUIHelper;
/**
* Welcome related ui handler.
@@ -78,8 +76,9 @@
/** Class logger. */
private static Log log = LogFactory.getLog(WelcomeHandler.class);
+ protected WelcomeUI welcomeUI;
+
protected Map<JFrame, WelcomePanelUI> allFrameOpened;
- protected WelcomeSaveVerifier verifier = new WelcomeSaveVerifier();
// URL alias
protected static final Map<String, String> URLSALIAS = new HashMap<String, String>();
@@ -92,10 +91,13 @@
URLSALIAS.put("TOPIA_API", "http://maven-site.nuiton.org/topia/topia-persistence/apidocs/index.html");
}
- public void postInit(WelcomeUI welcomeUI) {
- welcomeUI.setContextValue(verifier);
+ public WelcomeHandler(WelcomeUI welcomeUI) {
+ this.welcomeUI = welcomeUI;
+ }
+
+ public void afterInit() {
allFrameOpened = new HashMap<JFrame, WelcomePanelUI>();
- welcomeUI.getWelcomePanelUI().setContent(new WelcomeTabUI(new JAXXInitialContext().add(verifier)));
+ welcomeUI.getWelcomePanelUI().setContent(new WelcomeTabUI(welcomeUI));
// increase tooltip display time
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
@@ -105,8 +107,7 @@
protected void openFrame(WelcomeUI welcomeUI, Component c, String title) {
- JAXXInitialContext childContext = new JAXXInitialContext().add(verifier).add(this);
- WelcomePanelUI welcome = new WelcomePanelUI(childContext);
+ WelcomePanelUI welcome = new WelcomePanelUI(welcomeUI);
welcome.setContent(c);
JFrame frame = new JFrame(title);
@@ -132,10 +133,8 @@
* @param welcomeUI
*/
public void newSimulationFrame(WelcomeUI welcomeUI) {
- JAXXInitialContext context = new JAXXInitialContext();
- context.add(new SimulAction());
- context.add(this);
- SimulUI simulUI = new SimulUI(context);
+ SimulatorContext simulatorContext = new SimulatorContext(welcomeUI);
+ SimulUI simulUI = new SimulUI(simulatorContext);
openFrame(welcomeUI, simulUI, t("isisfish.simulation.title"));
}
@@ -152,7 +151,9 @@
* @param welcomeUI
*/
public void newInputFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new InputUI(new JAXXInitialContext().add(verifier).add(new InputSaveVerifier()).add(this)), t("isisfish.input.title"));
+ InputContext inputContext = new InputContext(welcomeUI);
+ InputUI inputUI = new InputUI(inputContext);
+ openFrame(welcomeUI, inputUI, t("isisfish.input.title"));
}
/**
@@ -168,7 +169,9 @@
* @param welcomeUI
*/
public void newSensitivityFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new SensitivityUI(new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(this)), t("isisfish.sensitivity.title"));
+ SensitivityContext sensitivityContext = new SensitivityContext(welcomeUI);
+ SensitivityUI sensitivityUI = new SensitivityUI(sensitivityContext);
+ openFrame(welcomeUI, sensitivityUI, t("isisfish.sensitivity.title"));
}
/**
@@ -184,6 +187,7 @@
* @param welcomeUI parent ui
*/
public void close(WelcomeUI welcomeUI) {
+ WelcomeSaveVerifier verifier = welcomeUI.getContextValue(WelcomeSaveVerifier.class);
if (verifier.allIsSaved()) {
welcomeUI.dispose();
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -24,11 +24,9 @@
-->
<JPanel layout='{new BorderLayout()}'>
<import>
- fr.ifremer.isisfish.ui.simulator.SimulAction
- jaxx.runtime.context.JAXXInitialContext
- fr.ifremer.isisfish.ui.input.InputSaveVerifier
- fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
- fr.ifremer.isisfish.ui.sensitivity.SensitivityInputHandler
+ fr.ifremer.isisfish.ui.input.InputContext
+ fr.ifremer.isisfish.ui.sensitivity.SensitivityContext
+ fr.ifremer.isisfish.ui.simulator.SimulatorContext
javax.swing.ImageIcon
</import>
@@ -46,16 +44,13 @@
</script>
<JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}' constraints="BorderLayout.CENTER">
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'>
- <fr.ifremer.isisfish.ui.input.InputUI id='inputUI'
- constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputSaveVerifier())' />
+ <fr.ifremer.isisfish.ui.input.InputUI id='inputUI' constructorParams='new InputContext(this)' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'>
- <fr.ifremer.isisfish.ui.simulator.SimulUI id='simulUI'
- constructorParams='new JAXXInitialContext().add(new SimulAction()).add(this)' />
+ <fr.ifremer.isisfish.ui.simulator.SimulUI id='simulUI' constructorParams='new SimulatorContext(this)' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/sensitivities.gif"))}'>
- <fr.ifremer.isisfish.ui.sensitivity.SensitivityUI id="sensitivityUI"
- constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(new SensitivityInputHandler()).add(this)' />
+ <fr.ifremer.isisfish.ui.sensitivity.SensitivityUI id="sensitivityUI" constructorParams='new SensitivityContext(this)' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/calc.gif"))}'>
<fr.ifremer.isisfish.ui.result.ResultUI />
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -24,11 +24,11 @@
-->
<JFrame width='874' height='736' resizable="true" layout='{new BorderLayout()}'>
- <WelcomeHandler id="handler" />
+ <WelcomeHandler id="handler" constructorParams="this" />
<script><![CDATA[
protected void $afterCompleteSetup() {
- getHandler().postInit(this);
+ getHandler().afterInit();
}
]]></script>
<JMenuBar>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContext.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContext.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContext.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,47 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.input;
+
+import fr.ifremer.isisfish.ui.WelcomeSaveVerifier;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+
+/**
+ * Ce contexte regroupe les élements qui servent à une hierachie d'interfaces Input.
+ *
+ * @author Eric Chatellier
+ */
+public class InputContext extends JAXXInitialContext {
+
+ public InputContext(JAXXContext parent) {
+ setParentContext(parent);
+
+ // add save verifier for this hierarchy
+ InputSaveVerifier inputSaveVerifier = new InputSaveVerifier();
+ add(inputSaveVerifier);
+
+ // this verifier is linked to global verifier
+ WelcomeSaveVerifier welcomeSaveVerifier = getContextValue(WelcomeSaveVerifier.class);
+ welcomeSaveVerifier.addSaveVerifier(inputSaveVerifier);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContext.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -31,9 +31,6 @@
import java.awt.event.ItemEvent;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
@@ -57,47 +54,22 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.StorageException;
-import fr.ifremer.isisfish.entities.Cell;
import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.entities.Gear;
-import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.entities.Observation;
import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.Port;
-import fr.ifremer.isisfish.entities.SetOfVessels;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.entities.SpeciesDAO;
-import fr.ifremer.isisfish.entities.Strategy;
-import fr.ifremer.isisfish.entities.TripType;
-import fr.ifremer.isisfish.entities.VesselType;
-import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.mexico.export.RegionExplorer;
import fr.ifremer.isisfish.mexico.export.RegionExport;
import fr.ifremer.isisfish.mexico.export.RegionExportFactorXML;
-import fr.ifremer.isisfish.ui.CommonHandler;
-import fr.ifremer.isisfish.ui.NavigationUI;
-import fr.ifremer.isisfish.ui.input.cell.CellUI;
-import fr.ifremer.isisfish.ui.input.fisheryregion.FisheryRegionUI;
-import fr.ifremer.isisfish.ui.input.gear.GearUI;
-import fr.ifremer.isisfish.ui.input.metier.MetierUI;
-import fr.ifremer.isisfish.ui.input.observation.ObservationUI;
-import fr.ifremer.isisfish.ui.input.population.PopulationUI;
-import fr.ifremer.isisfish.ui.input.port.PortUI;
-import fr.ifremer.isisfish.ui.input.setofvessels.SetOfVesselsUI;
-import fr.ifremer.isisfish.ui.input.species.SpeciesUI;
-import fr.ifremer.isisfish.ui.input.strategy.StrategyUI;
+import fr.ifremer.isisfish.ui.NavigationHandler;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeRenderer;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeSelectionModel;
import fr.ifremer.isisfish.ui.input.tree.loadors.PopulationsNodeLoador;
-import fr.ifremer.isisfish.ui.input.triptype.TripTypeUI;
-import fr.ifremer.isisfish.ui.input.vesseltype.VesselTypeUI;
-import fr.ifremer.isisfish.ui.input.zone.ZoneUI;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.vcs.VCSException;
-import jaxx.runtime.JAXXContext;
/**
* Main handler for fishery edition action.
@@ -115,16 +87,10 @@
* Last update : $Date$
* By : $Author$
*/
-public class InputHandler extends CommonHandler {
+public class InputHandler extends NavigationHandler {
/** Class logger. */
private static final Log log = LogFactory.getLog(InputHandler.class);
-
- /**
- * Cache pour n'instancier les ui qu'une seule fois
- * et eviter que l'affichage saute pour l'utilsateur.
- */
- protected Map<Class<?>, InputContentUI<?>> uiInstanceCache = new HashMap<>();
/**
* Post init ui.
@@ -153,8 +119,7 @@
inputUI.getCardlayoutPrincipal().show(inputUI.getInputPanePrincipal(), "none");
TreeModel model = new DefaultTreeModel(null);
inputUI.getFisheryRegionTree().setModel(model);
- }
- else {
+ } else {
FisheryRegion fisheryRegion = null;
RegionStorage regionStorage = null;
TopiaContext topiaContext = null;
@@ -564,90 +529,6 @@
}
/**
- * Get ui that can display internalClass.
- *
- * @param internalClass internal class to get ui
- * @return ui for class
- * @throws Exception
- */
- protected InputContentUI<?> getUIInstanceForBeanClass(Class<?> internalClass, NavigationUI navigationUI) throws Exception {
-
- Class<? extends InputContentUI<?>> uiClass = null;
- if (FisheryRegion.class.isAssignableFrom(internalClass)) {
- uiClass = FisheryRegionUI.class;
- } else if (Cell.class.isAssignableFrom(internalClass)) {
- uiClass = CellUI.class;
- } else if (Gear.class.isAssignableFrom(internalClass)) {
- uiClass = GearUI.class;
- } else if (Metier.class.isAssignableFrom(internalClass)) {
- uiClass = MetierUI.class;
- } else if (Population.class.isAssignableFrom(internalClass)) {
- uiClass = PopulationUI.class;
- } else if (Port.class.isAssignableFrom(internalClass)) {
- uiClass = PortUI.class;
- } else if (SetOfVessels.class.isAssignableFrom(internalClass)) {
- uiClass = SetOfVesselsUI.class;
- } else if (Species.class.isAssignableFrom(internalClass)) {
- uiClass = SpeciesUI.class;
- } else if (Strategy.class.isAssignableFrom(internalClass)) {
- uiClass = StrategyUI.class;
- } else if (TripType.class.isAssignableFrom(internalClass)) {
- uiClass = TripTypeUI.class;
- } else if (VesselType.class.isAssignableFrom(internalClass)) {
- uiClass = VesselTypeUI.class;
- } else if (Zone.class.isAssignableFrom(internalClass)) {
- uiClass = ZoneUI.class;
- } else if (Observation.class.isAssignableFrom(internalClass)) {
- uiClass = ObservationUI.class;
- }
-
- // use map to implement UI cache
- InputContentUI<?> result = uiInstanceCache.get(uiClass);
- if (result == null) {
- Constructor<?> constructor = uiClass.getConstructor(JAXXContext.class);
- result = (InputContentUI<?>)constructor.newInstance(navigationUI);
-
- uiInstanceCache.put(uiClass, result);
- }
-
- return result;
- }
-
- /**
- * Change tree selection with new node id.
- *
- * Called by specific UI (CellUI to change node).
- *
- * @param inputUI context ui (to get context value tree helper...)
- * @param nodeId node id to select
- */
- public void setTreeSelection(InputContentUI<?> inputUI, String nodeId) {
- setTreeSelection(inputUI, null, nodeId);
- }
-
- /**
- * Change tree selection with new node id.
- *
- * Called by specific UI (CellUI to change node).
- *
- * @param inputUI context ui (to get context value tree helper...)
- * @param parentNodeId find node to select from this node
- * @param nodeId node id to select
- */
- public void setTreeSelection(InputContentUI<?> inputUI, String parentNodeId, String nodeId) {
- FisheryTreeHelper fisheryTreeHelper = inputUI.getContextValue(FisheryTreeHelper.class);
- TreeModel fisheryTreeModel = inputUI.getContextValue(TreeModel.class);
- FisheryTreeNode fromNode = (FisheryTreeNode)fisheryTreeModel.getRoot();
- if (parentNodeId != null) {
- fromNode = fisheryTreeHelper.findNode(fromNode, parentNodeId);
- }
- FisheryTreeNode newSelectNode = fisheryTreeHelper.findNode(fromNode, nodeId);
- if (newSelectNode != null) {
- fisheryTreeHelper.selectNode(newSelectNode);
- }
- }
-
- /**
* Delete tree node referenced by parent, and auto select parent node.
*
* @param inputUI ui containing tree
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -36,28 +36,28 @@
<JMenuBar id="menu" constraints='BorderLayout.NORTH'>
<JMenu text="isisfish.common.region" id="menuRegion">
- <JMenuItem id="menuRegionImport" text="isisfish.input.menu.importRegion" onActionPerformed="getHandler().importRegion(this)" />
- <JMenuItem id="menuRegionImportRename" text="isisfish.input.menu.importRenameRegion" onActionPerformed="getHandler().importRegionAndRename(this)" />
- <JMenuItem text="isisfish.input.menu.importRegionSimulation" onActionPerformed="getHandler().importRegionFromSimulation(this)" enabled="false"/>
- <JMenuItem id="menuRegionExport" text="isisfish.input.menu.exportRegion" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().exportRegion(this)" />
- <JMenuItem id="menuRegionCopy" text="isisfish.input.menu.copyRegion" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().copyRegion(this)" />
+ <JMenuItem id="menuRegionImport" text="isisfish.input.menu.importRegion" onActionPerformed="handler.importRegion(this)" />
+ <JMenuItem id="menuRegionImportRename" text="isisfish.input.menu.importRenameRegion" onActionPerformed="handler.importRegionAndRename(this)" />
+ <JMenuItem text="isisfish.input.menu.importRegionSimulation" onActionPerformed="handler.importRegionFromSimulation(this)" enabled="false"/>
+ <JMenuItem id="menuRegionExport" text="isisfish.input.menu.exportRegion" enabled='{isRegionLoaded()}' onActionPerformed="handler.exportRegion(this)" />
+ <JMenuItem id="menuRegionCopy" text="isisfish.input.menu.copyRegion" enabled='{isRegionLoaded()}' onActionPerformed="handler.copyRegion(this)" />
<JSeparator/>
- <JMenuItem text="isisfish.input.menu.removeLocaly" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().removeRegion(this, false)" />
+ <JMenuItem text="isisfish.input.menu.removeLocaly" enabled='{isRegionLoaded()}' onActionPerformed="handler.removeRegion(this, false)" />
</JMenu>
<JMenu text="isisfish.input.menu.server">
- <JMenuItem text="isisfish.input.menu.addRegion" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().commitRegionInCVS(this)" />
- <JMenuItem text="isisfish.input.menu.commit" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().commitRegionInCVS(this)" />
+ <JMenuItem text="isisfish.input.menu.addRegion" enabled='{isRegionLoaded()}' onActionPerformed="handler.commitRegionInCVS(this)" />
+ <JMenuItem text="isisfish.input.menu.commit" enabled='{isRegionLoaded()}' onActionPerformed="handler.commitRegionInCVS(this)" />
<JSeparator/>
- <JMenuItem text="isisfish.input.menu.removeLocalyRemotely" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().removeRegion(this, true)" />
+ <JMenuItem text="isisfish.input.menu.removeLocalyRemotely" enabled='{isRegionLoaded()}' onActionPerformed="handler.removeRegion(this, true)" />
</JMenu>
<JMenu text="isisfish.input.menu.sensitivity">
- <JMenuItem text="isisfish.input.menu.sensitivity.export" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().exportRegionSensitivityFactors(this)" />
+ <JMenuItem text="isisfish.input.menu.sensitivity.export" enabled='{isRegionLoaded()}' onActionPerformed="handler.exportRegionSensitivityFactors(this)" />
</JMenu>
</JMenuBar>
<JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="HORIZONTAL" constraints='BorderLayout.CENTER'>
<JPanel layout='{new BorderLayout()}' minimumSize="{new java.awt.Dimension(0,0)}">
<org.jdesktop.swingx.JXComboBox id="fieldCurrentRegion" constraints='BorderLayout.NORTH'
- onItemStateChanged='getHandler().regionChange(this, event)'
+ onItemStateChanged='handler.regionChange(this, event)'
model='{new fr.ifremer.isisfish.ui.models.common.GenericComboModel<String>(fr.ifremer.isisfish.datastore.RegionStorage.getRegionNames())}'/>
<JPanel id="treePanel" name="treePanel" layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
<JScrollPane constraints='BorderLayout.CENTER'>
@@ -65,7 +65,7 @@
selectionMode='{javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION}'/>
<JTree id="fisheryRegionTree" selectionModel='{fisheryRegionTreeSelectionModel}'
rootVisible="true" selectionRow='0' model='{new javax.swing.tree.DefaultTreeModel(null)}' rowHeight="0"
- onValueChanged="getHandler().nodeSelectionChanged(this, event)" />
+ onValueChanged="handler.nodeSelectionChanged(this, event)" />
</JScrollPane>
</JPanel>
<Table constraints='BorderLayout.SOUTH'>
@@ -75,7 +75,7 @@
</cell>
<cell fill='horizontal'>
<JButton id="buttonNewRegion" text="isisfish.input.createNewRegion"
- onActionPerformed='getHandler().createNewRegion(this)' enabled='{getFieldNewRegion().getText().length() > 0}'/>
+ onActionPerformed='handler.createNewRegion(this)' enabled='{getFieldNewRegion().getText().length() > 0}'/>
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -42,7 +42,7 @@
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.rule.Rule;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputHandler;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
@@ -89,8 +89,7 @@
final String paramName = (String)value;
try {
Class paramType = RuleStorage.getParameterType(rule, paramName);
- SensitivityInputHandler handler = ruleChooser.getContextValue(SensitivityInputHandler.class);
- boolean canBeFactor = handler.canBeFactor(paramType);
+ boolean canBeFactor = SensitivityUtils.canBeFactor(paramType);
if (canBeFactor) {
JButton button = new JButton(Resource.getIcon("/icons/building_add.png"));
button.addActionListener(new ActionListener() {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellRenderer.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellRenderer.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellRenderer.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -38,7 +38,7 @@
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.rule.Rule;
-import fr.ifremer.isisfish.ui.sensitivity.SensitivityInputHandler;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
/**
@@ -79,8 +79,7 @@
String paramName = (String)value;
try {
Class paramType = RuleStorage.getParameterType(rule, paramName);
- SensitivityInputHandler handler = ruleChooser.getContextValue(SensitivityInputHandler.class);
- boolean canBeFactor = handler.canBeFactor(paramType);
+ boolean canBeFactor = SensitivityUtils.canBeFactor(paramType);
if (canBeFactor) {
comp = new JButton(Resource.getIcon("/icons/building_add.png"));
}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -1,1154 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2015 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.script;
-
-import static org.nuiton.i18n.I18n.t;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Desktop;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreePath;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.ZipUtil;
-
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.datastore.CodeSourceStorage;
-import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
-import fr.ifremer.isisfish.datastore.ExportStorage;
-import fr.ifremer.isisfish.datastore.FormuleStorage;
-import fr.ifremer.isisfish.datastore.JavaSourceStorage;
-import fr.ifremer.isisfish.datastore.ObjectiveStorage;
-import fr.ifremer.isisfish.datastore.OptimizationStorage;
-import fr.ifremer.isisfish.datastore.RuleStorage;
-import fr.ifremer.isisfish.datastore.ScriptStorage;
-import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
-import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
-import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
-import fr.ifremer.isisfish.datastore.SimulatorStorage;
-import fr.ifremer.isisfish.equation.Language;
-import fr.ifremer.isisfish.ui.WelcomePanelUI;
-import fr.ifremer.isisfish.ui.script.model.ScriptTree;
-import fr.ifremer.isisfish.ui.script.model.ScriptTreeModel;
-import fr.ifremer.isisfish.ui.util.ErrorHelper;
-import fr.ifremer.isisfish.util.CompileHelper;
-import fr.ifremer.isisfish.util.JavadocHelper;
-import fr.ifremer.isisfish.vcs.VCSException;
-import freemarker.cache.ClassTemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-
-/**
- * ScriptAction.
- *
- * Template are now loaded with freemarker.
- *
- * @author letellier
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class ScriptAction implements TreeSelectionListener, CaretListener {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(ScriptAction.class);
-
- /** Couleur de succes (vert leger). */
- protected static final Color COLOR_SUCCESS = new Color(210, 255, 210);
-
- /** Couleur d'echec (rouge leger). */
- protected static final Color COLOR_FAILURE = new Color(255, 210, 210);
-
- /** Storage for currently edited file. */
- protected CodeSourceStorage codeStorage;
-
- /** Freemarke configuration used to create new script (based on templates). */
- protected Configuration freemarkerConfiguration;
-
- /** UI managed by this action class. */
- protected ScriptUI scriptUI;
-
- /**
- * Constructeur.
- *
- * Init freemarker.
- *
- * @param scriptUI managed script UI
- */
- public ScriptAction(ScriptUI scriptUI) {
-
- this.scriptUI = scriptUI;
-
- freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_0);
- // needed to overwrite "Defaults to default system encoding."
- // fix encoding issue on some systems
- freemarkerConfiguration.setDefaultEncoding("utf-8");
- // specific template loader to get template from jars (classpath)
- ClassTemplateLoader templateLoader = new ClassTemplateLoader(ScriptAction.class, "/");
- freemarkerConfiguration.setTemplateLoader(templateLoader);
-
- }
-
- /**
- * Post init, must be called after ui building.
- */
- public void postInit() {
-
- ScriptTree scriptTree = this.scriptUI.getScriptTree();
-
- // add listeners
- scriptTree.addTreeSelectionListener(this);
- this.scriptUI.getEditor().addCaretListener(this);
-
- // expand official VCS tree node
- scriptTree.expandRow(0);
- }
-
- /**
- * Update script UI component actions buttons.
- */
- protected void setButton() {
-
- File selectedFile = scriptUI.getScriptTree().getSelectedFile();
-
- if (selectedFile != null) {
- scriptUI.setSingleFileSelected(selectedFile.isFile());
- scriptUI.setJavaFileSelected(selectedFile.getName().endsWith(".java"));
- }
- else {
- scriptUI.setSingleFileSelected(false);
- scriptUI.setJavaFileSelected(false);
- }
- }
-
- protected void setStatusMessage(String msg) {
- // FIXME remove all parent container reference
- WelcomePanelUI parentUI = scriptUI.getParentContainer(WelcomePanelUI.class);
- parentUI.setStatusMessage(msg);
- }
- protected void setStatusMessage(String msg, boolean running) {
- // FIXME remove all parent container reference
- WelcomePanelUI parentUI = scriptUI.getParentContainer(WelcomePanelUI.class);
- parentUI.setStatusMessage(msg, running);
- }
-
- /**
- * Make new script, and select it on tree.
- */
- public void newScript(ScriptUI view, MouseEvent event) {
- JPopupMenu menu = new JPopupMenu();
-
- // make a basic copy of already existing menu
- JMenu oldMenu = view.getScriptNewMenu();
- for (int i = 0; i < oldMenu.getItemCount(); i++) {
- JMenuItem oldMenuItem = (JMenuItem)oldMenu.getMenuComponent(i);
- JMenuItem miCopy = new JMenuItem();
- miCopy.setText(oldMenuItem.getText());
- miCopy.setIcon(oldMenuItem.getIcon());
- for (ActionListener l : oldMenuItem.getActionListeners()) {
- miCopy.addActionListener(l);
- }
- menu.add(miCopy);
- }
-
- menu.show((Component)event.getSource(), event.getX(), event.getY());
- }
-
- /**
- * Make new script, and select it on tree.
- *
- * @param scriptType script to make
- */
- public void newScript(ScriptMapping scriptType) {
-
- String equationModelType = "";
- String equationModelTypePath = "";
-
- // specific case for equation model
- if (scriptType.equals(ScriptMapping.Formule)) {
- List<String> values = FormuleStorage.getCategories();
- equationModelType = (String) JOptionPane.showInputDialog(scriptUI,
- t("isisfish.message.new.formule.category"),
- t("isisfish.message.new.formule.title"),
- JOptionPane.PLAIN_MESSAGE, null, values.toArray(), values.get(0));
- equationModelTypePath = equationModelType + File.separator;
- }
-
- // if user has not choose "cancel"
- if (equationModelType != null) {
- String fileName = JOptionPane.showInputDialog(t("isisfish.message.new.filename"));
- // user cancel
- if (!StringUtils.isEmpty(fileName)) {
- File scriptFile = newScript(equationModelTypePath + fileName, scriptType);
- // creation successful
- if (scriptFile != null) {
- ScriptTreeModel model = scriptUI.getScriptTreeModel();
- model.fileAdded(scriptFile);
- TreePath treePath = model.getTreePathFor(scriptFile);
- scriptUI.getScriptTree().setSelectionPath(treePath);
- }
- }
- }
- }
-
- /**
- * Creer un nouveau script, ici un script peut-etre un Script, un Simulator,
- * un Export.
- *
- * @param fileName full filename
- * @param scriptType le type que l'on souhaite Script, Simulator, ou Export.
- * @return created file or {@code null} if any error happen
- */
- protected File newScript(String fileName, ScriptMapping scriptType) {
-
- if (log.isDebugEnabled()) {
- log.debug("newScript called [" + scriptType + "]");
- }
-
- File scriptFile = null;
-
- try {
- // Vérifie qu'il n'y pas de caractères spéciaux. Seul les caractre
- // de a à z (majuscule ou minuscule) ainsi que les nombres sont
- // autorisés. + pour signifier qu'il doit y avoir
- // au moins 1 caractère.
- String realFilename;
- String category;
-
- int pos = fileName.lastIndexOf('/');
- if (pos != -1) {
- if (scriptType != ScriptMapping.Formule) {
- // interdit pour le moment ?
- String message = t("isisfish.error.invalid.file.name",
- fileName);
- Exception e = new RuntimeException(message);
- returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
- return null;
- }
- // il y a un sous type à traiter
- if (pos == fileName.length() - 1) {
- String message = t("isisfish.error.invalid.file.name",
- fileName);
- Exception e = new RuntimeException(message);
- returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
- return null;
- }
- realFilename = fileName
- .substring(fileName.lastIndexOf('/') + 1);
- category = fileName.substring(0, fileName.lastIndexOf('/'));
- } else {
- realFilename = fileName;
- category = "";
- }
- if (!realFilename.matches("[A-Z0-9_][a-zA-Z0-9_]*")) {
- String message = t("isisfish.error.invalid.file.name", fileName);
- Exception e = new RuntimeException(message);
- returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
- return null;
- }
- //TODO do test on category
- CodeSourceStorage script = null;
- switch (scriptType) {
- case CommunityFormule:
- script = FormuleStorage.createFormule(category, realFilename,
- Language.JAVA);
- break;
- case CommunitySimulationPlan:
- script = SimulationPlanStorage.createSimulationPlan(fileName, Location.COMMUNITY);
- break;
- case CommunityExport:
- case CommunityExportStep:
- script = ExportStorage.createExport(fileName, Location.COMMUNITY);
- break;
- case CommunityObjective:
- script = ObjectiveStorage.createObjective(fileName, Location.COMMUNITY);
- break;
- case CommunityOptimization:
- script = OptimizationStorage.createOptimization(fileName, Location.COMMUNITY);
- break;
- case CommunityRule:
- script = RuleStorage.createRule(fileName, Location.COMMUNITY);
- break;
- case CommunityScript:
- script = ScriptStorage.createScript(fileName, Location.COMMUNITY);
- break;
- case CommunitySimulator:
- script = SimulatorStorage.createSimulator(fileName, Location.COMMUNITY);
- break;
- case CommunitySensitivity:
- script = SensitivityAnalysisStorage.createSensitivityAnalysis(fileName, Location.COMMUNITY);
- break;
- case CommunitySensitivityExport:
- script = SensitivityExportStorage
- .createSensitivityExport(fileName, Location.COMMUNITY);
- break;
- default:
- if (log.isErrorEnabled()) {
- log.fatal("ScriptType unknown: " + scriptType);
- }
- }
-
- if (script.exists()) {
- // Message d'erreur si le fichier existe en local.
- String message = t("isisfish.error.file.already.exists", fileName);
- Exception e = new RuntimeException(message);
- returnError(t("isisfish.error.script.create", fileName, e
- .getMessage()), e);
- }
-
- String scriptTemplatePath = scriptType.getTemplatePath();
-
- if (scriptTemplatePath != null) {
-
- if (log.isDebugEnabled()) {
- log.debug("Parsing freemarker template located in "
- + scriptTemplatePath);
- }
-
- // get template
- Template template = freemarkerConfiguration
- .getTemplate(scriptTemplatePath);
-
- // context values
- Map<String, Object> root = new HashMap<String, Object>();
- root.put("name", realFilename);
- root.put("date", new Date());
- root.put("author", IsisFish.config.getUserName());
- root.put("email", IsisFish.config.getUserMail());
-
- // process template
- Writer out = new StringWriter();
- template.process(root, out);
- out.flush();
- script.setContent(out.toString());
- } else {
- throw new IsisFishRuntimeException("There is no templatePath");
- }
-
- codeStorage = script;
- scriptFile = script.getFile();
- } catch (Exception eee) {
- returnError(t("isisfish.error.script.create", fileName, eee
- .getMessage()), eee);
- }
-
- return scriptFile;
- }
-
- /**
- * Write error in log and display exception to user.
- *
- * @param s message
- * @param eee cause
- */
- protected void returnError(String s, Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(s, eee);
- }
- ErrorHelper.showErrorDialog(s, eee);
- }
-
- /*
- * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
- */
- @Override
- public void valueChanged(TreeSelectionEvent e) {
- if (e.getNewLeadSelectionPath() != null) {
- Object selectedNode = e.getNewLeadSelectionPath().getLastPathComponent();
- if (selectedNode instanceof File && ((File)selectedNode).isFile()) {
- File selectedFile = (File)selectedNode;
- // load file into current action codeStorage
- loadScript(selectedFile);
- scriptUI.getEditor().open(selectedFile);
- // force refresh
- scriptUI.getEditor().repaint();
- scriptUI.getEditor().validate();
-
- setButton();
- }
- else {
- scriptUI.getEditor().close();
- // force refresh
- scriptUI.getEditor().repaint();
- scriptUI.getEditor().validate();
-
- setButton();
- }
- }
- }
-
- /**
- * Load specified script in current action.
- *
- * TODO can we change this ?
- *
- * @param file file to load
- */
- public void loadScript(File file) {
- ScriptMapping mapping = ScriptMapping.getMappingFor(file);
- CodeSourceStorage script = null;
-
- try {
- switch (mapping) {
- case Formule:
- case CommunityFormule:
- String fullPath = file.getAbsolutePath();
- int lastIndexOf = fullPath.lastIndexOf('/');
- // in string .../aaa/bbb/ccc/ddd.java
- // get ccc
- String category = fullPath.substring(fullPath.lastIndexOf('/',
- lastIndexOf - 1) + 1, lastIndexOf);
- if (mapping.equals(ScriptMapping.Formule)) {
- script = FormuleStorage.getFormule(category, file.getName());
- } else {
- script = FormuleStorage.getCommunityFormule(category, file.getName());
- }
- break;
- case Rule:
- script = RuleStorage.getRule(file.getName(), Location.OFFICIAL);
- break;
- case Objective:
- script = ObjectiveStorage.getObjective(file.getName(), Location.OFFICIAL);
- break;
- case Optimization:
- script = OptimizationStorage.getOptimization(file.getName(), Location.OFFICIAL);
- break;
- case SimulationPlan:
- script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.OFFICIAL);
- break;
- case Export:
- case ExportStep:
- script = ExportStorage.getExport(file.getName(), Location.OFFICIAL);
- break;
- case Script:
- script = ScriptStorage.getScript(file.getName(), Location.OFFICIAL);
- break;
- case Simulator:
- script = SimulatorStorage.getSimulator(file.getName(), Location.OFFICIAL);
- break;
- case Sensitivity:
- script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.OFFICIAL);
- break;
- case SensitivityExport:
- script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.OFFICIAL);
- break;
- case CommunityObjective:
- script = ObjectiveStorage.getObjective(file.getName(), Location.COMMUNITY);
- break;
- case CommunityOptimization:
- script = OptimizationStorage.getOptimization(file.getName(), Location.COMMUNITY);
- break;
- case CommunityRule:
- script = RuleStorage.getRule(file.getName(), Location.COMMUNITY);
- break;
- case CommunitySimulationPlan:
- script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.COMMUNITY);
- break;
- case CommunityExport:
- case CommunityExportStep:
- script = ExportStorage.getExport(file.getName(), Location.COMMUNITY);
- break;
- case CommunityScript:
- script = ScriptStorage.getScript(file.getName(), Location.COMMUNITY);
- break;
- case CommunitySimulator:
- script = SimulatorStorage.getSimulator(file.getName(), Location.COMMUNITY);
- break;
- case CommunitySensitivity:
- script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.COMMUNITY);
- break;
- case CommunitySensitivityExport:
- script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.COMMUNITY);
- break;
- default:
- log.fatal("ScriptType unknown: " + file.getName());
- }
-
- //frame.setInfoText(t("isisfish.message.load.finished"));
- } catch (Exception eee) {
- returnError(t("isisfish.error.script.load", file.getAbsolutePath(),
- eee.getMessage()), eee);
-
- } finally {
- codeStorage = script;
- }
- }
-
- public boolean fileLoaded() {
- return codeStorage != null;
- }
-
- public boolean isJavaScript() {
- return JavaSourceStorage.class.isInstance(codeStorage);
- }
-
- /**
- * Save current editor test in current loaded codeStorage.
- */
- public void saveScript() {
- if (log.isDebugEnabled()) {
- log.debug("saveScript called on " + codeStorage.getName());
- }
-
- try {
- // setContent() or scriptUI.getEditor().save()
- // if setContent() only editor ask for t saving
- scriptUI.getEditor().save();
- String content = scriptUI.getEditor().getText();
- codeStorage.setContent(content, false);
-
- // notify tree to refresh
- ScriptTreeModel model = scriptUI.getScriptTreeModel();
- model.fileModified(codeStorage.getFile());
- } catch (Exception eee) {
- returnError(t("isisfish.error.script.save", codeStorage.getFile(),
- eee.getMessage()), eee);
- }
- setStatusMessage(t("isisfish.message.save.finished"));
- }
-
- /**
- * Save script, and display commit UI.
- */
- public void commitScript() {
-
- if (log.isDebugEnabled()) {
- log.debug("commitScript called for " + codeStorage.getName());
- }
-
- try {
- // save script before commit
- saveScript();
-
- String msg = JOptionPane.showInputDialog(t("isisfish.message.script.commit", codeStorage.getName()));
- if (msg == null) {
- setStatusMessage(t("isisfish.message.commit.cancelled"));
- } else {
- codeStorage.commit(msg);
- codeStorage.reload();
- setStatusMessage(t("isisfish.message.commit.finished"));
- }
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Error on script commit", ex);
- }
-
- // if vcs can't write
- ErrorHelper.showErrorDialog(ex.getMessage(), ex);
- }
- }
-
- /**
- * Exporte le(s) script(s) sélectionnés dans l'arbre.
- * <br>L'arbre doit avoir au moins un script de selectionnés
- */
- public void exportScript() {
-
- TreePath[] selectedFilesPath = scriptUI.getScriptTree().getSelectionPaths();
-
- // first step : acquire list of files required
- int prefixLength = IsisFish.config.getDatabaseDirectory()
- .getAbsolutePath().length() + 1;
- List<String> listFiles = extractFiles(prefixLength, selectedFilesPath);
-
- }
-
- protected static List<String> extractFiles(int prefixLength,
- TreePath[] selectedPaths) {
- List<String> result = new ArrayList<String>();
- List<File> dirFound = new ArrayList<File>();
- List<File> dirWithFileFound = new ArrayList<File>();
-
- for (TreePath selectedPath : selectedPaths) {
-
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath
- .getPathComponent(1);
- String moduleDisplayName = String.valueOf(node.getUserObject());
- File file = ScriptMapping.valueOf(moduleDisplayName).getModule();
- int nbPaths = selectedPath.getPathCount();
- if (nbPaths > 2)
- for (int i = 2; i < nbPaths; i++) {
- node = (DefaultMutableTreeNode) selectedPath
- .getPathComponent(i);
- String pathName = String.valueOf(node.getUserObject());
- file = new File(file, pathName);
- }
- if (file.isFile()) {
- File parentFile = file.getParentFile();
- if (!dirFound.contains(parentFile)) {
- dirFound.add(parentFile);
- }
- dirWithFileFound.add(parentFile);
- result.add(file.getAbsolutePath().substring(prefixLength));
- } else {
- // mark the file
- dirFound.add(file);
- }
- }
-
- // keep only user selected directories
- dirFound.removeAll(dirWithFileFound);
- dirWithFileFound.clear();
-
- if (!dirFound.isEmpty()) {
- List<File> listF = new ArrayList<File>();
- // there is some directories selected by user
- for (File dir : dirFound) {
- FileFilter filter = new FileFilter() {
- FileFilter excludeFilter = getScriptFileFilter();
-
- public boolean accept(File pathname) {
- return !excludeFilter.accept(pathname);
- }
- };
- listF.addAll(FileUtil.getFilteredElements(dir, filter, true));
- }
- for (File file : listF)
- result.add(file.getAbsolutePath().substring(prefixLength));
- listF.clear();
- }
- dirFound.clear();
- return result;
- }
-
- /**
- * Cut selection in current editor.
- */
- public void cut() {
- scriptUI.getEditor().cut();
- }
-
- /**
- * Copy selection in current editor.
- */
- public void copy() {
- scriptUI.getEditor().copy();
- }
-
- /**
- * Paste clipboard content in editor.
- */
- public void paste() {
- scriptUI.getEditor().paste();
- }
-
- protected static FileFilter scriptFileFilter;
-
- public static FileFilter getScriptFileFilter() {
- if (scriptFileFilter == null) {
- scriptFileFilter = new ScriptFileFilter(IsisFish.vcs);
- }
- return scriptFileFilter;
- }
-
- /**
- * Check script content.
- *
- * @return compilation success flag
- */
- public boolean checkScript() {
-
- boolean check = false;
-
- // can't compile formule
- if (codeStorage instanceof FormuleStorage) {
- return false;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("checkScript called");
- }
- // save script before compile
- saveScript();
-
- JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
- StringWriter result = new StringWriter();
- PrintWriter out = new PrintWriter(result);
- try {
- int compileResult = javaCode.compile(false, out);
-
- if (compileResult == 0) {
- check = true;
- }
- } catch (Exception eee) {
- eee.printStackTrace(out);
- }
- out.flush();
-
- if (check) {
- scriptUI.getActionLogArea().setText(
- t("isisfish.script.compilation.ok", result.toString()));
- scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
- } else {
- scriptUI.getActionLogArea().setText(
- t("isisfish.script.compilation.failed", result
- .toString()));
- scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
- }
-
- setStatusMessage(t("isisfish.message.check.finished"));
- return check;
- }
-
- /**
- * Check all scripts.
- */
- public void checkAllScripts() {
-
- setStatusMessage(t("isisfish.message.check.inprogress"), true);
-
- boolean allSuccess = true;
-
- // reste previous state
- scriptUI.getActionLogArea().setBackground(null);
- scriptUI.getActionLogArea().setText("");
-
- for (ScriptMapping scriptMapping : ScriptMapping.values()) {
- // normalement ne match pas les formules
- // le cas est différent pour les formules
- // le fichier java ne sont pas compilable sans la formule associée
- List<File> javaFiles = FileUtil.find(scriptMapping.getModule(), ".+\\.java$", false);
- for (File javaFile : javaFiles) {
- scriptUI.getActionLogArea().append(t("isisfish.script.compilingfile", javaFile));
-
- StringWriter result = new StringWriter();
- PrintWriter out = new PrintWriter(result);
- int compileResult = CompileHelper.compile(IsisFish.config.getDatabaseDirectory(), javaFile, IsisFish.config.getCompileDirectory(), out);
- out.flush();
-
- if (compileResult == 0) {
- scriptUI.getActionLogArea().append(t("isisfish.common.ok") + "\n");
- }
- else {
- scriptUI.getActionLogArea().append(t("isisfish.common.error") + ":\n");
- scriptUI.getActionLogArea().append(result.toString() + "\n");
- scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
- allSuccess = false;
- }
-
- // scroll down
- scriptUI.getActionLogArea().setCaretPosition(scriptUI.getActionLogArea().getText().length());
- }
- }
-
- // set final color
- if (allSuccess) {
- scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
- }
-
- setStatusMessage(t("isisfish.message.check.finished"));
- }
-
- /**
- * Call main method in current cod storage code.
- * Check script before call.
- */
- public void evaluateScript() {
-
- if (log.isDebugEnabled()) {
- log.debug("evaluateScript called");
- }
-
- try {
- if (checkScript()) {
- // reset area color
- scriptUI.getActionLogArea().setBackground(null);
-
- JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- PrintStream out = new PrintStream(result);
- PrintStream err = new PrintStream(result);
- PrintStream oldOut = System.out;
- PrintStream oldErr = System.err;
- System.setOut(out);
- System.setErr(err);
- Class<?> clazz = javaCode.getCodeClass();
- Method main = clazz.getMethod("main", String[].class);
- //noinspection RedundantArrayCreation
- main.invoke(null, new Object[] { new String[] {} });
- System.setOut(oldOut);
- System.setErr(oldErr);
- scriptUI.getActionLogArea().setText(result.toString());
- }
- } catch (Exception ex) {
- if (log.isDebugEnabled()) {
- log.debug("Error on script evaluation", ex);
- }
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- PrintStream out = new PrintStream(result);
- ex.printStackTrace(out);
- scriptUI.getActionLogArea().setText(result.toString());
- }
- setStatusMessage(t("isisfish.message.evaluation.finished"));
- }
-
- /**
- * Copy a single file to destination directory.
- *
- * @param src file to copy
- * @param path path of file to copy
- * @param suffix file suffix
- * @throws IOException if copy fail
- */
- protected void backup(File src, String path, String suffix)
- throws IOException {
-
- }
-
- /**
- * Scan archive for script, and return an array of new files and conflict files.
- *
- * @param source archive file
- * @param root database directory
- * @return an array [newFiles, conflictFiles]
- */
- protected static List<String>[] scanZip(File source, File root) {
-
- List<String> overwrittenFiles = new ArrayList<String>();
- List<String> newFiles = new ArrayList<String>();
-
- // ontain list of relative paths (to add or overwrite)
- try {
- ZipUtil.scan(source, root, newFiles, overwrittenFiles,
- getScriptFileFilter(), null, null);
- } catch (IOException e) {
- log.error("Can't scan zip (" + source + ")", e);
- throw new RuntimeException(e);
- }
-
- return new List[] { newFiles, overwrittenFiles };
- }
-
- /**
- * Delete a script
- *
- * @param deleteRemote {@code true} to remove in vcs too
- */
- public void deleteScript(boolean deleteRemote) {
-
- if (log.isDebugEnabled()) {
- log.debug("DeleteScript called");
- }
-
- String name = codeStorage.getName();
- int resp = JOptionPane.showConfirmDialog(scriptUI, t("isisfish.message.confirm.remove.script", name),
- null, JOptionPane.YES_NO_OPTION);
- if (resp == JOptionPane.YES_OPTION) {
- // stay in UI even if deleted
- scriptUI.getEditor().close();
-
- try {
- // TODO change this, need to be called before
- // effective deletion
- scriptUI.getScriptTreeModel().fileDeleted(codeStorage.getFile());
-
- //TODO desactive editor
- //TODO Review this because after delete fi file saw previously
- //TODO modified, it ask if we want to save, and then we have
- //TODO again the file in panel but not in tree panel ?
- codeStorage.delete(deleteRemote);
- if (codeStorage.getFile().exists()) {
- ErrorHelper.showErrorDialog(t("isisfish.error.script.delete", codeStorage
- .getFile()));
- }
- } catch (Exception eee) {
- returnError(t("isisfish.error.script.delete",
- codeStorage == null ? null : codeStorage.getFile(), eee
- .getMessage()), eee);
- }
- setStatusMessage(t("isisfish.message.delete.finished"));
- } else {
- setStatusMessage(t("isisfish.message.delete.canceled"));
- }
- }
-
- /**
- * Show diff between selected files and files server version.
- */
- public void diffScript() {
-
- if (log.isDebugEnabled()) {
- log.debug("Method diffScript called on " + codeStorage.getFile());
- }
-
- try {
- String result = null;
- if (IsisFish.vcs.isOnRemote(codeStorage.getFile())) {
- result = IsisFish.vcs.getDiff(codeStorage.getFile());
- } else {
- result = "File not on remote";
- }
- scriptUI.getActionLogArea().setText(result);
- } catch (VCSException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't get diff", e);
- }
- ErrorHelper.showErrorDialog(t("isisfish.vcs.vcssvn.diff.error"), e);
- }
- }
-
- /** enum to encapsulate a script module */
- protected enum ScriptMapping {
-
- Export(
- ExportStorage.getExportDirectory(),
- ExportStorage.EXPORT_TEMPLATE, true),
- ExportStep(
- ExportStorage.getExportDirectory(),
- ExportStorage.EXPORT_STEP_TEMPLATE, true),
- Rule(
- RuleStorage.getRuleDirectory(),
- RuleStorage.RULE_TEMPLATE, true),
- Objective(
- ObjectiveStorage.getObjectiveDirectory(),
- ObjectiveStorage.OBJECTIVE_TEMPLATE, true),
- Optimization(
- OptimizationStorage.getOptimizationDirectory(),
- OptimizationStorage.OPTIMIZATION_TEMPLATE, true),
- Script(
- ScriptStorage.getScriptDirectory(),
- ScriptStorage.SCRIPT_TEMPLATE, true),
- Sensitivity(
- SensitivityAnalysisStorage.getSensitivityAnalysisDirectory(),
- SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_TEMPLATE, true),
- SensitivityExport(
- SensitivityExportStorage.getSensitivityExportDirectory(),
- SensitivityExportStorage.SENSITIVITY_EXPORT_TEMPLATE, true),
- SimulationPlan(
- SimulationPlanStorage.getSimulationPlanDirectory(),
- SimulationPlanStorage.SIMULATION_PLAN_TEMPLATE, true),
- Simulator(
- SimulatorStorage.getSimulatorDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE, true),
- Formule(
- FormuleStorage.getFormuleDirectory(),
- FormuleStorage.FORMULE_TEMPLATE, true),
-
- CommunityExport(
- ExportStorage.getCommunityExportDirectory(),
- ExportStorage.EXPORT_TEMPLATE),
- CommunityExportStep(
- ExportStorage.getCommunityExportDirectory(),
- ExportStorage.EXPORT_STEP_TEMPLATE),
- CommunityObjective(
- ObjectiveStorage.getCommunityObjectiveDirectory(),
- ObjectiveStorage.OBJECTIVE_TEMPLATE, true),
- CommunityOptimization(
- OptimizationStorage.getCommunityOptimizationDirectory(),
- OptimizationStorage.OPTIMIZATION_TEMPLATE, true),
- CommunityRule(
- RuleStorage.getCommunityRuleDirectory(),
- RuleStorage.RULE_TEMPLATE),
- CommunityScript(
- ScriptStorage.getCommunityScriptDirectory(),
- ScriptStorage.SCRIPT_TEMPLATE),
- CommunitySensitivity(
- SensitivityAnalysisStorage.getCommunitySensitivityAnalysisDirectory(),
- SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_TEMPLATE),
- CommunitySensitivityExport(
- SensitivityExportStorage.getCommunitySensitivityExportDirectory(),
- SensitivityExportStorage.SENSITIVITY_EXPORT_TEMPLATE),
- CommunitySimulationPlan(
- SimulationPlanStorage.getCommunitySimulationPlanDirectory(),
- SimulationPlanStorage.SIMULATION_PLAN_TEMPLATE),
- CommunitySimulator(
- SimulatorStorage.getCommunitySimulatorDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
- CommunityFormule(
- FormuleStorage.getCommunityFormuleDirectory(),
- FormuleStorage.FORMULE_TEMPLATE);
-
- protected File module;
- protected String templatePath;
- protected boolean officialVCS;
-
- private ScriptMapping(File module, String templatePath) {
- this(module, templatePath, false);
- }
-
- private ScriptMapping(File module, String templatePath, boolean officialVCS) {
- this.module = module;
- this.templatePath = templatePath;
- this.officialVCS = officialVCS;
- }
-
- /**
- * Get script type for script path.
- *
- * @param file file to get type
- * @return ScriptMapping type
- */
- public static ScriptMapping getMappingFor(File file) {
-
- ScriptMapping result = null;
-
- // test if path starts with type begin path
-
- // don't forget last / for distinction begin
- // "sensitivity" and "sensitivityexport"
- for (ScriptMapping mapping : ScriptMapping.values()) {
- if (file.getAbsolutePath().startsWith(mapping.getModule().getAbsolutePath() + File.separator)) {
- result = mapping;
- }
- }
-
- return result;
- }
-
- public File getModule() {
- return module;
- }
-
- public String getTemplatePath() {
- return templatePath;
- }
-
- public boolean isOfficialVCS() {
- return officialVCS;
- }
- }
-
- /**
- * Generate javadoc and display output in UI.
- */
- public void generateScriptJavadoc() {
- setStatusMessage(t("isisfish.script.menu.javadocgenerating",
- IsisFish.config.getJavadocDirectory()), true);
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- File rootDatabase = IsisFish.config.getDatabaseDirectory();
- File javadocDirectory = IsisFish.config.getJavadocDirectory();
-
- StringWriter output = new StringWriter();
- PrintWriter out = new PrintWriter(output);
- int ok = JavadocHelper.generateJavadoc(rootDatabase,
- javadocDirectory, out);
-
- if (ok == 0) {
- scriptUI.getActionLogArea().setText(
- t("isisfish.script.javadoc.ok", output.toString()));
- // vert leger
- scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
- } else {
- scriptUI.getActionLogArea().setText(
- t("isisfish.script.compilation.failed", output
- .toString()));
- // rouge leger
- scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
- }
-
- setStatusMessage(t("isisfish.script.menu.javadocgenerated",
- IsisFish.config.getJavadocDirectory()));
- }
- });
- }
-
- /**
- * Open a browser displaying javadoc.
- */
- public void showScriptJavadoc() {
- try {
- // in faut ouvrir l'index, sinon, ca ouvre
- // un explorateur de fichier
- File indexFile = new File(IsisFish.config.getJavadocDirectory(),
- "index.html");
-
- URI uri = indexFile.toURI();
- Desktop.getDesktop().browse(uri);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't show script javadocs", e);
- }
- }
- }
-
- /*
- * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
- */
- @Override
- public void caretUpdate(CaretEvent e) {
- // selection pas vide si dot = mark
- scriptUI.setTextSelected(e.getDot() != e.getMark());
- }
-
- /**
- * Move files.
- * (called by drag and drop handler).
- *
- * @param directory directory to moves files to
- * @param filesToMove files to move to directory
- */
- public void moveFiles(File directory, Collection<File> filesToMove) {
-
- ScriptTreeModel model = scriptUI.getScriptTreeModel();
- for (File fileToMove : filesToMove) {
- model.fileDeleted(fileToMove);
- File destFile = new File(directory, fileToMove.getName());
- try {
- FileUtils.moveFile(fileToMove, destFile);
- } catch (IOException ex) {
- throw new IsisFishRuntimeException("Can't move file", ex);
- }
- model.fileAdded(destFile);
- }
- }
-}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,1163 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2006 - 2015 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.script;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Desktop;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.SwingWorker;
+import javax.swing.event.CaretEvent;
+import javax.swing.event.CaretListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.ZipUtil;
+
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.JavaSourceStorage;
+import fr.ifremer.isisfish.datastore.ObjectiveStorage;
+import fr.ifremer.isisfish.datastore.OptimizationStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
+import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+import fr.ifremer.isisfish.equation.Language;
+import fr.ifremer.isisfish.ui.WelcomePanelUI;
+import fr.ifremer.isisfish.ui.script.model.ScriptTree;
+import fr.ifremer.isisfish.ui.script.model.ScriptTreeModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+import fr.ifremer.isisfish.util.CompileHelper;
+import fr.ifremer.isisfish.util.JavadocHelper;
+import fr.ifremer.isisfish.vcs.VCSException;
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+
+/**
+ * ScriptAction.
+ *
+ * Template are now loaded with freemarker.
+ *
+ * @author letellier
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ScriptHandler implements TreeSelectionListener, CaretListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(ScriptHandler.class);
+
+ /** Couleur de succes (vert leger). */
+ protected static final Color COLOR_SUCCESS = new Color(210, 255, 210);
+
+ /** Couleur d'echec (rouge leger). */
+ protected static final Color COLOR_FAILURE = new Color(255, 210, 210);
+
+ /** Storage for currently edited file. */
+ protected CodeSourceStorage codeStorage;
+
+ /** Freemarke configuration used to create new script (based on templates). */
+ protected Configuration freemarkerConfiguration;
+
+ /** UI managed by this action class. */
+ protected ScriptUI scriptUI;
+
+ /**
+ * Constructeur.
+ *
+ * Init freemarker.
+ *
+ * @param scriptUI managed script UI
+ */
+ public ScriptHandler(ScriptUI scriptUI) {
+
+ this.scriptUI = scriptUI;
+
+ freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_0);
+ // needed to overwrite "Defaults to default system encoding."
+ // fix encoding issue on some systems
+ freemarkerConfiguration.setDefaultEncoding("utf-8");
+ // specific template loader to get template from jars (classpath)
+ ClassTemplateLoader templateLoader = new ClassTemplateLoader(ScriptHandler.class, "/");
+ freemarkerConfiguration.setTemplateLoader(templateLoader);
+
+ }
+
+ /**
+ * Post init, must be called after ui building.
+ */
+ public void afterInit() {
+
+ ScriptTree scriptTree = this.scriptUI.getScriptTree();
+
+ // add listeners
+ scriptTree.addTreeSelectionListener(this);
+ this.scriptUI.getEditor().addCaretListener(this);
+
+ // expand official VCS tree node
+ scriptTree.expandRow(0);
+ }
+
+ /**
+ * Update script UI component actions buttons.
+ */
+ protected void setButton() {
+
+ File selectedFile = scriptUI.getScriptTree().getSelectedFile();
+
+ if (selectedFile != null) {
+ scriptUI.setSingleFileSelected(selectedFile.isFile());
+ scriptUI.setJavaFileSelected(selectedFile.getName().endsWith(".java"));
+ } else {
+ scriptUI.setSingleFileSelected(false);
+ scriptUI.setJavaFileSelected(false);
+ }
+ }
+
+ protected void setStatusMessage(String msg) {
+ // FIXME remove all parent container reference
+ WelcomePanelUI parentUI = scriptUI.getParentContainer(WelcomePanelUI.class);
+ parentUI.setStatusMessage(msg);
+ }
+ protected void setStatusMessage(String msg, boolean running) {
+ // FIXME remove all parent container reference
+ WelcomePanelUI parentUI = scriptUI.getParentContainer(WelcomePanelUI.class);
+ parentUI.setStatusMessage(msg, running);
+ }
+
+ /**
+ * Make new script, and select it on tree.
+ */
+ public void newScript(MouseEvent event) {
+ JPopupMenu menu = new JPopupMenu();
+
+ // make a basic copy of already existing menu
+ JMenu oldMenu = scriptUI.getScriptNewMenu();
+ for (int i = 0; i < oldMenu.getItemCount(); i++) {
+ JMenuItem oldMenuItem = (JMenuItem)oldMenu.getMenuComponent(i);
+ JMenuItem miCopy = new JMenuItem();
+ miCopy.setText(oldMenuItem.getText());
+ miCopy.setIcon(oldMenuItem.getIcon());
+ for (ActionListener l : oldMenuItem.getActionListeners()) {
+ miCopy.addActionListener(l);
+ }
+ menu.add(miCopy);
+ }
+
+ menu.show((Component)event.getSource(), event.getX(), event.getY());
+ }
+
+ /**
+ * Make new script, and select it on tree.
+ *
+ * @param scriptType script to make
+ */
+ public void newScript(ScriptMapping scriptType) {
+
+ String equationModelType = "";
+ String equationModelTypePath = "";
+
+ // specific case for equation model
+ if (scriptType.equals(ScriptMapping.Formule)) {
+ List<String> values = FormuleStorage.getCategories();
+ equationModelType = (String) JOptionPane.showInputDialog(scriptUI,
+ t("isisfish.message.new.formule.category"),
+ t("isisfish.message.new.formule.title"),
+ JOptionPane.PLAIN_MESSAGE, null, values.toArray(), values.get(0));
+ equationModelTypePath = equationModelType + File.separator;
+ }
+
+ // if user has not choose "cancel"
+ if (equationModelType != null) {
+ String fileName = JOptionPane.showInputDialog(t("isisfish.message.new.filename"));
+ // user cancel
+ if (!StringUtils.isEmpty(fileName)) {
+ File scriptFile = newScript(equationModelTypePath + fileName, scriptType);
+ // creation successful
+ if (scriptFile != null) {
+ ScriptTreeModel model = scriptUI.getScriptTreeModel();
+ model.fileAdded(scriptFile);
+ TreePath treePath = model.getTreePathFor(scriptFile);
+ scriptUI.getScriptTree().setSelectionPath(treePath);
+ }
+ }
+ }
+ }
+
+ /**
+ * Creer un nouveau script, ici un script peut-etre un Script, un Simulator,
+ * un Export.
+ *
+ * @param fileName full filename
+ * @param scriptType le type que l'on souhaite Script, Simulator, ou Export.
+ * @return created file or {@code null} if any error happen
+ */
+ protected File newScript(String fileName, ScriptMapping scriptType) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("newScript called [" + scriptType + "]");
+ }
+
+ File scriptFile = null;
+
+ try {
+ // Vérifie qu'il n'y pas de caractères spéciaux. Seul les caractre
+ // de a à z (majuscule ou minuscule) ainsi que les nombres sont
+ // autorisés. + pour signifier qu'il doit y avoir
+ // au moins 1 caractère.
+ String realFilename;
+ String category;
+
+ int pos = fileName.lastIndexOf('/');
+ if (pos != -1) {
+ if (scriptType != ScriptMapping.Formule) {
+ // interdit pour le moment ?
+ String message = t("isisfish.error.invalid.file.name",
+ fileName);
+ Exception e = new RuntimeException(message);
+ returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
+ return null;
+ }
+ // il y a un sous type à traiter
+ if (pos == fileName.length() - 1) {
+ String message = t("isisfish.error.invalid.file.name",
+ fileName);
+ Exception e = new RuntimeException(message);
+ returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
+ return null;
+ }
+ realFilename = fileName
+ .substring(fileName.lastIndexOf('/') + 1);
+ category = fileName.substring(0, fileName.lastIndexOf('/'));
+ } else {
+ realFilename = fileName;
+ category = "";
+ }
+ if (!realFilename.matches("[A-Z0-9_][a-zA-Z0-9_]*")) {
+ String message = t("isisfish.error.invalid.file.name", fileName);
+ Exception e = new RuntimeException(message);
+ returnError(t("isisfish.error.script.create", fileName, e.getMessage()), e);
+ return null;
+ }
+ //TODO do test on category
+ CodeSourceStorage script = null;
+ switch (scriptType) {
+ case CommunityFormule:
+ script = FormuleStorage.createFormule(category, realFilename,
+ Language.JAVA);
+ break;
+ case CommunitySimulationPlan:
+ script = SimulationPlanStorage.createSimulationPlan(fileName, Location.COMMUNITY);
+ break;
+ case CommunityExport:
+ case CommunityExportStep:
+ script = ExportStorage.createExport(fileName, Location.COMMUNITY);
+ break;
+ case CommunityObjective:
+ script = ObjectiveStorage.createObjective(fileName, Location.COMMUNITY);
+ break;
+ case CommunityOptimization:
+ script = OptimizationStorage.createOptimization(fileName, Location.COMMUNITY);
+ break;
+ case CommunityRule:
+ script = RuleStorage.createRule(fileName, Location.COMMUNITY);
+ break;
+ case CommunityScript:
+ script = ScriptStorage.createScript(fileName, Location.COMMUNITY);
+ break;
+ case CommunitySimulator:
+ script = SimulatorStorage.createSimulator(fileName, Location.COMMUNITY);
+ break;
+ case CommunitySensitivity:
+ script = SensitivityAnalysisStorage.createSensitivityAnalysis(fileName, Location.COMMUNITY);
+ break;
+ case CommunitySensitivityExport:
+ script = SensitivityExportStorage
+ .createSensitivityExport(fileName, Location.COMMUNITY);
+ break;
+ default:
+ if (log.isErrorEnabled()) {
+ log.fatal("ScriptType unknown: " + scriptType);
+ }
+ }
+
+ if (script.exists()) {
+ // Message d'erreur si le fichier existe en local.
+ String message = t("isisfish.error.file.already.exists", fileName);
+ Exception e = new RuntimeException(message);
+ returnError(t("isisfish.error.script.create", fileName, e
+ .getMessage()), e);
+ }
+
+ String scriptTemplatePath = scriptType.getTemplatePath();
+
+ if (scriptTemplatePath != null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Parsing freemarker template located in "
+ + scriptTemplatePath);
+ }
+
+ // get template
+ Template template = freemarkerConfiguration
+ .getTemplate(scriptTemplatePath);
+
+ // context values
+ Map<String, Object> root = new HashMap<String, Object>();
+ root.put("name", realFilename);
+ root.put("date", new Date());
+ root.put("author", IsisFish.config.getUserName());
+ root.put("email", IsisFish.config.getUserMail());
+
+ // process template
+ Writer out = new StringWriter();
+ template.process(root, out);
+ out.flush();
+ script.setContent(out.toString());
+ } else {
+ throw new IsisFishRuntimeException("There is no templatePath");
+ }
+
+ codeStorage = script;
+ scriptFile = script.getFile();
+ } catch (Exception eee) {
+ returnError(t("isisfish.error.script.create", fileName, eee
+ .getMessage()), eee);
+ }
+
+ return scriptFile;
+ }
+
+ /**
+ * Write error in log and display exception to user.
+ *
+ * @param s message
+ * @param eee cause
+ */
+ protected void returnError(String s, Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(s, eee);
+ }
+ ErrorHelper.showErrorDialog(s, eee);
+ }
+
+ /*
+ * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
+ */
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ if (e.getNewLeadSelectionPath() != null) {
+ Object selectedNode = e.getNewLeadSelectionPath().getLastPathComponent();
+ if (selectedNode instanceof File && ((File)selectedNode).isFile()) {
+ File selectedFile = (File)selectedNode;
+ // load file into current action codeStorage
+ loadScript(selectedFile);
+ scriptUI.getEditor().open(selectedFile);
+ // force refresh
+ scriptUI.getEditor().repaint();
+ scriptUI.getEditor().validate();
+
+ setButton();
+ }
+ else {
+ scriptUI.getEditor().close();
+ // force refresh
+ scriptUI.getEditor().repaint();
+ scriptUI.getEditor().validate();
+
+ setButton();
+ }
+ }
+ }
+
+ /**
+ * Load specified script in current action.
+ *
+ * TODO can we change this ?
+ *
+ * @param file file to load
+ */
+ public void loadScript(File file) {
+ ScriptMapping mapping = ScriptMapping.getMappingFor(file);
+ CodeSourceStorage script = null;
+
+ try {
+ switch (mapping) {
+ case Formule:
+ case CommunityFormule:
+ String fullPath = file.getAbsolutePath();
+ int lastIndexOf = fullPath.lastIndexOf('/');
+ // in string .../aaa/bbb/ccc/ddd.java
+ // get ccc
+ String category = fullPath.substring(fullPath.lastIndexOf('/',
+ lastIndexOf - 1) + 1, lastIndexOf);
+ if (mapping.equals(ScriptMapping.Formule)) {
+ script = FormuleStorage.getFormule(category, file.getName());
+ } else {
+ script = FormuleStorage.getCommunityFormule(category, file.getName());
+ }
+ break;
+ case Rule:
+ script = RuleStorage.getRule(file.getName(), Location.OFFICIAL);
+ break;
+ case Objective:
+ script = ObjectiveStorage.getObjective(file.getName(), Location.OFFICIAL);
+ break;
+ case Optimization:
+ script = OptimizationStorage.getOptimization(file.getName(), Location.OFFICIAL);
+ break;
+ case SimulationPlan:
+ script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.OFFICIAL);
+ break;
+ case Export:
+ case ExportStep:
+ script = ExportStorage.getExport(file.getName(), Location.OFFICIAL);
+ break;
+ case Script:
+ script = ScriptStorage.getScript(file.getName(), Location.OFFICIAL);
+ break;
+ case Simulator:
+ script = SimulatorStorage.getSimulator(file.getName(), Location.OFFICIAL);
+ break;
+ case Sensitivity:
+ script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.OFFICIAL);
+ break;
+ case SensitivityExport:
+ script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.OFFICIAL);
+ break;
+ case CommunityObjective:
+ script = ObjectiveStorage.getObjective(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunityOptimization:
+ script = OptimizationStorage.getOptimization(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunityRule:
+ script = RuleStorage.getRule(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunitySimulationPlan:
+ script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunityExport:
+ case CommunityExportStep:
+ script = ExportStorage.getExport(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunityScript:
+ script = ScriptStorage.getScript(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunitySimulator:
+ script = SimulatorStorage.getSimulator(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunitySensitivity:
+ script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.COMMUNITY);
+ break;
+ case CommunitySensitivityExport:
+ script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.COMMUNITY);
+ break;
+ default:
+ log.fatal("ScriptType unknown: " + file.getName());
+ }
+
+ //frame.setInfoText(t("isisfish.message.load.finished"));
+ } catch (Exception eee) {
+ returnError(t("isisfish.error.script.load", file.getAbsolutePath(),
+ eee.getMessage()), eee);
+
+ } finally {
+ codeStorage = script;
+ }
+ }
+
+ public boolean fileLoaded() {
+ return codeStorage != null;
+ }
+
+ public boolean isJavaScript() {
+ return JavaSourceStorage.class.isInstance(codeStorage);
+ }
+
+ /**
+ * Save current editor test in current loaded codeStorage.
+ */
+ public void saveScript() {
+ if (log.isDebugEnabled()) {
+ log.debug("saveScript called on " + codeStorage.getName());
+ }
+
+ try {
+ // setContent() or scriptUI.getEditor().save()
+ // if setContent() only editor ask for t saving
+ scriptUI.getEditor().save();
+ String content = scriptUI.getEditor().getText();
+ codeStorage.setContent(content, false);
+
+ // notify tree to refresh
+ ScriptTreeModel model = scriptUI.getScriptTreeModel();
+ model.fileModified(codeStorage.getFile());
+ } catch (Exception eee) {
+ returnError(t("isisfish.error.script.save", codeStorage.getFile(),
+ eee.getMessage()), eee);
+ }
+ setStatusMessage(t("isisfish.message.save.finished"));
+ }
+
+ /**
+ * Save script, and display commit UI.
+ */
+ public void commitScript() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("commitScript called for " + codeStorage.getName());
+ }
+
+ try {
+ // save script before commit
+ saveScript();
+
+ String msg = JOptionPane.showInputDialog(t("isisfish.message.script.commit", codeStorage.getName()));
+ if (msg == null) {
+ setStatusMessage(t("isisfish.message.commit.cancelled"));
+ } else {
+ codeStorage.commit(msg);
+ codeStorage.reload();
+ setStatusMessage(t("isisfish.message.commit.finished"));
+ }
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error on script commit", ex);
+ }
+
+ // if vcs can't write
+ ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ }
+ }
+
+ /**
+ * Exporte le(s) script(s) sélectionnés dans l'arbre.
+ * <br>L'arbre doit avoir au moins un script de selectionnés
+ */
+ public void exportScript() {
+
+ TreePath[] selectedFilesPath = scriptUI.getScriptTree().getSelectionPaths();
+
+ // first step : acquire list of files required
+ int prefixLength = IsisFish.config.getDatabaseDirectory()
+ .getAbsolutePath().length() + 1;
+ List<String> listFiles = extractFiles(prefixLength, selectedFilesPath);
+
+ }
+
+ protected static List<String> extractFiles(int prefixLength,
+ TreePath[] selectedPaths) {
+ List<String> result = new ArrayList<String>();
+ List<File> dirFound = new ArrayList<File>();
+ List<File> dirWithFileFound = new ArrayList<File>();
+
+ for (TreePath selectedPath : selectedPaths) {
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath
+ .getPathComponent(1);
+ String moduleDisplayName = String.valueOf(node.getUserObject());
+ File file = ScriptMapping.valueOf(moduleDisplayName).getModule();
+ int nbPaths = selectedPath.getPathCount();
+ if (nbPaths > 2)
+ for (int i = 2; i < nbPaths; i++) {
+ node = (DefaultMutableTreeNode) selectedPath
+ .getPathComponent(i);
+ String pathName = String.valueOf(node.getUserObject());
+ file = new File(file, pathName);
+ }
+ if (file.isFile()) {
+ File parentFile = file.getParentFile();
+ if (!dirFound.contains(parentFile)) {
+ dirFound.add(parentFile);
+ }
+ dirWithFileFound.add(parentFile);
+ result.add(file.getAbsolutePath().substring(prefixLength));
+ } else {
+ // mark the file
+ dirFound.add(file);
+ }
+ }
+
+ // keep only user selected directories
+ dirFound.removeAll(dirWithFileFound);
+ dirWithFileFound.clear();
+
+ if (!dirFound.isEmpty()) {
+ List<File> listF = new ArrayList<File>();
+ // there is some directories selected by user
+ for (File dir : dirFound) {
+ FileFilter filter = new FileFilter() {
+ FileFilter excludeFilter = getScriptFileFilter();
+
+ public boolean accept(File pathname) {
+ return !excludeFilter.accept(pathname);
+ }
+ };
+ listF.addAll(FileUtil.getFilteredElements(dir, filter, true));
+ }
+ for (File file : listF)
+ result.add(file.getAbsolutePath().substring(prefixLength));
+ listF.clear();
+ }
+ dirFound.clear();
+ return result;
+ }
+
+ /**
+ * Cut selection in current editor.
+ */
+ public void cut() {
+ scriptUI.getEditor().cut();
+ }
+
+ /**
+ * Copy selection in current editor.
+ */
+ public void copy() {
+ scriptUI.getEditor().copy();
+ }
+
+ /**
+ * Paste clipboard content in editor.
+ */
+ public void paste() {
+ scriptUI.getEditor().paste();
+ }
+
+ protected static FileFilter scriptFileFilter;
+
+ public static FileFilter getScriptFileFilter() {
+ if (scriptFileFilter == null) {
+ scriptFileFilter = new ScriptFileFilter(IsisFish.vcs);
+ }
+ return scriptFileFilter;
+ }
+
+ /**
+ * Check script content.
+ *
+ * @return compilation success flag
+ */
+ public boolean checkScript() {
+
+ boolean check = false;
+
+ // can't compile formule
+ if (codeStorage instanceof FormuleStorage) {
+ return false;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("checkScript called");
+ }
+ // save script before compile
+ saveScript();
+
+ JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
+ try {
+ int compileResult = javaCode.compile(false, out);
+
+ if (compileResult == 0) {
+ check = true;
+ }
+ } catch (Exception eee) {
+ eee.printStackTrace(out);
+ }
+ out.flush();
+
+ if (check) {
+ scriptUI.getActionLogArea().setText(
+ t("isisfish.script.compilation.ok", result.toString()));
+ scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
+ } else {
+ scriptUI.getActionLogArea().setText(
+ t("isisfish.script.compilation.failed", result
+ .toString()));
+ scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
+ }
+
+ setStatusMessage(t("isisfish.message.check.finished"));
+ return check;
+ }
+
+ /**
+ * Check all scripts.
+ */
+ public void checkAllScripts() {
+ new SwingWorker<Void, Void>() {
+ public Void doInBackground() {
+ checkAllScripts();
+ return null;
+ }
+ }.execute();
+ }
+
+ protected void checkAllScriptsAsync() {
+
+ setStatusMessage(t("isisfish.message.check.inprogress"), true);
+
+ boolean allSuccess = true;
+
+ // reste previous state
+ scriptUI.getActionLogArea().setBackground(null);
+ scriptUI.getActionLogArea().setText("");
+
+ for (ScriptMapping scriptMapping : ScriptMapping.values()) {
+ // normalement ne match pas les formules
+ // le cas est différent pour les formules
+ // le fichier java ne sont pas compilable sans la formule associée
+ List<File> javaFiles = FileUtil.find(scriptMapping.getModule(), ".+\\.java$", false);
+ for (File javaFile : javaFiles) {
+ scriptUI.getActionLogArea().append(t("isisfish.script.compilingfile", javaFile));
+
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
+ int compileResult = CompileHelper.compile(IsisFish.config.getDatabaseDirectory(), javaFile, IsisFish.config.getCompileDirectory(), out);
+ out.flush();
+
+ if (compileResult == 0) {
+ scriptUI.getActionLogArea().append(t("isisfish.common.ok") + "\n");
+ }
+ else {
+ scriptUI.getActionLogArea().append(t("isisfish.common.error") + ":\n");
+ scriptUI.getActionLogArea().append(result.toString() + "\n");
+ scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
+ allSuccess = false;
+ }
+
+ // scroll down
+ scriptUI.getActionLogArea().setCaretPosition(scriptUI.getActionLogArea().getText().length());
+ }
+ }
+
+ // set final color
+ if (allSuccess) {
+ scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
+ }
+
+ setStatusMessage(t("isisfish.message.check.finished"));
+ }
+
+ /**
+ * Call main method in current cod storage code.
+ * Check script before call.
+ */
+ public void evaluateScript() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("evaluateScript called");
+ }
+
+ try {
+ if (checkScript()) {
+ // reset area color
+ scriptUI.getActionLogArea().setBackground(null);
+
+ JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ PrintStream out = new PrintStream(result);
+ PrintStream err = new PrintStream(result);
+ PrintStream oldOut = System.out;
+ PrintStream oldErr = System.err;
+ System.setOut(out);
+ System.setErr(err);
+ Class<?> clazz = javaCode.getCodeClass();
+ Method main = clazz.getMethod("main", String[].class);
+ //noinspection RedundantArrayCreation
+ main.invoke(null, new Object[] { new String[] {} });
+ System.setOut(oldOut);
+ System.setErr(oldErr);
+ scriptUI.getActionLogArea().setText(result.toString());
+ }
+ } catch (Exception ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("Error on script evaluation", ex);
+ }
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ PrintStream out = new PrintStream(result);
+ ex.printStackTrace(out);
+ scriptUI.getActionLogArea().setText(result.toString());
+ }
+ setStatusMessage(t("isisfish.message.evaluation.finished"));
+ }
+
+ /**
+ * Copy a single file to destination directory.
+ *
+ * @param src file to copy
+ * @param path path of file to copy
+ * @param suffix file suffix
+ * @throws IOException if copy fail
+ */
+ protected void backup(File src, String path, String suffix)
+ throws IOException {
+
+ }
+
+ /**
+ * Scan archive for script, and return an array of new files and conflict files.
+ *
+ * @param source archive file
+ * @param root database directory
+ * @return an array [newFiles, conflictFiles]
+ */
+ protected static List<String>[] scanZip(File source, File root) {
+
+ List<String> overwrittenFiles = new ArrayList<String>();
+ List<String> newFiles = new ArrayList<String>();
+
+ // ontain list of relative paths (to add or overwrite)
+ try {
+ ZipUtil.scan(source, root, newFiles, overwrittenFiles,
+ getScriptFileFilter(), null, null);
+ } catch (IOException e) {
+ log.error("Can't scan zip (" + source + ")", e);
+ throw new RuntimeException(e);
+ }
+
+ return new List[] { newFiles, overwrittenFiles };
+ }
+
+ /**
+ * Delete a script
+ *
+ * @param deleteRemote {@code true} to remove in vcs too
+ */
+ public void deleteScript(boolean deleteRemote) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("DeleteScript called");
+ }
+
+ String name = codeStorage.getName();
+ int resp = JOptionPane.showConfirmDialog(scriptUI, t("isisfish.message.confirm.remove.script", name),
+ null, JOptionPane.YES_NO_OPTION);
+ if (resp == JOptionPane.YES_OPTION) {
+ // stay in UI even if deleted
+ scriptUI.getEditor().close();
+
+ try {
+ // TODO change this, need to be called before
+ // effective deletion
+ scriptUI.getScriptTreeModel().fileDeleted(codeStorage.getFile());
+
+ //TODO desactive editor
+ //TODO Review this because after delete fi file saw previously
+ //TODO modified, it ask if we want to save, and then we have
+ //TODO again the file in panel but not in tree panel ?
+ codeStorage.delete(deleteRemote);
+ if (codeStorage.getFile().exists()) {
+ ErrorHelper.showErrorDialog(t("isisfish.error.script.delete", codeStorage
+ .getFile()));
+ }
+ } catch (Exception eee) {
+ returnError(t("isisfish.error.script.delete",
+ codeStorage == null ? null : codeStorage.getFile(), eee
+ .getMessage()), eee);
+ }
+ setStatusMessage(t("isisfish.message.delete.finished"));
+ } else {
+ setStatusMessage(t("isisfish.message.delete.canceled"));
+ }
+ }
+
+ /**
+ * Show diff between selected files and files server version.
+ */
+ public void diffScript() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Method diffScript called on " + codeStorage.getFile());
+ }
+
+ try {
+ String result = null;
+ if (IsisFish.vcs.isOnRemote(codeStorage.getFile())) {
+ result = IsisFish.vcs.getDiff(codeStorage.getFile());
+ } else {
+ result = "File not on remote";
+ }
+ scriptUI.getActionLogArea().setText(result);
+ } catch (VCSException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get diff", e);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.vcs.vcssvn.diff.error"), e);
+ }
+ }
+
+ /** enum to encapsulate a script module */
+ protected enum ScriptMapping {
+
+ Export(
+ ExportStorage.getExportDirectory(),
+ ExportStorage.EXPORT_TEMPLATE, true),
+ ExportStep(
+ ExportStorage.getExportDirectory(),
+ ExportStorage.EXPORT_STEP_TEMPLATE, true),
+ Rule(
+ RuleStorage.getRuleDirectory(),
+ RuleStorage.RULE_TEMPLATE, true),
+ Objective(
+ ObjectiveStorage.getObjectiveDirectory(),
+ ObjectiveStorage.OBJECTIVE_TEMPLATE, true),
+ Optimization(
+ OptimizationStorage.getOptimizationDirectory(),
+ OptimizationStorage.OPTIMIZATION_TEMPLATE, true),
+ Script(
+ ScriptStorage.getScriptDirectory(),
+ ScriptStorage.SCRIPT_TEMPLATE, true),
+ Sensitivity(
+ SensitivityAnalysisStorage.getSensitivityAnalysisDirectory(),
+ SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_TEMPLATE, true),
+ SensitivityExport(
+ SensitivityExportStorage.getSensitivityExportDirectory(),
+ SensitivityExportStorage.SENSITIVITY_EXPORT_TEMPLATE, true),
+ SimulationPlan(
+ SimulationPlanStorage.getSimulationPlanDirectory(),
+ SimulationPlanStorage.SIMULATION_PLAN_TEMPLATE, true),
+ Simulator(
+ SimulatorStorage.getSimulatorDirectory(),
+ SimulatorStorage.SIMULATOR_TEMPLATE, true),
+ Formule(
+ FormuleStorage.getFormuleDirectory(),
+ FormuleStorage.FORMULE_TEMPLATE, true),
+
+ CommunityExport(
+ ExportStorage.getCommunityExportDirectory(),
+ ExportStorage.EXPORT_TEMPLATE),
+ CommunityExportStep(
+ ExportStorage.getCommunityExportDirectory(),
+ ExportStorage.EXPORT_STEP_TEMPLATE),
+ CommunityObjective(
+ ObjectiveStorage.getCommunityObjectiveDirectory(),
+ ObjectiveStorage.OBJECTIVE_TEMPLATE, true),
+ CommunityOptimization(
+ OptimizationStorage.getCommunityOptimizationDirectory(),
+ OptimizationStorage.OPTIMIZATION_TEMPLATE, true),
+ CommunityRule(
+ RuleStorage.getCommunityRuleDirectory(),
+ RuleStorage.RULE_TEMPLATE),
+ CommunityScript(
+ ScriptStorage.getCommunityScriptDirectory(),
+ ScriptStorage.SCRIPT_TEMPLATE),
+ CommunitySensitivity(
+ SensitivityAnalysisStorage.getCommunitySensitivityAnalysisDirectory(),
+ SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_TEMPLATE),
+ CommunitySensitivityExport(
+ SensitivityExportStorage.getCommunitySensitivityExportDirectory(),
+ SensitivityExportStorage.SENSITIVITY_EXPORT_TEMPLATE),
+ CommunitySimulationPlan(
+ SimulationPlanStorage.getCommunitySimulationPlanDirectory(),
+ SimulationPlanStorage.SIMULATION_PLAN_TEMPLATE),
+ CommunitySimulator(
+ SimulatorStorage.getCommunitySimulatorDirectory(),
+ SimulatorStorage.SIMULATOR_TEMPLATE),
+ CommunityFormule(
+ FormuleStorage.getCommunityFormuleDirectory(),
+ FormuleStorage.FORMULE_TEMPLATE);
+
+ protected File module;
+ protected String templatePath;
+ protected boolean officialVCS;
+
+ private ScriptMapping(File module, String templatePath) {
+ this(module, templatePath, false);
+ }
+
+ private ScriptMapping(File module, String templatePath, boolean officialVCS) {
+ this.module = module;
+ this.templatePath = templatePath;
+ this.officialVCS = officialVCS;
+ }
+
+ /**
+ * Get script type for script path.
+ *
+ * @param file file to get type
+ * @return ScriptMapping type
+ */
+ public static ScriptMapping getMappingFor(File file) {
+
+ ScriptMapping result = null;
+
+ // test if path starts with type begin path
+
+ // don't forget last / for distinction begin
+ // "sensitivity" and "sensitivityexport"
+ for (ScriptMapping mapping : ScriptMapping.values()) {
+ if (file.getAbsolutePath().startsWith(mapping.getModule().getAbsolutePath() + File.separator)) {
+ result = mapping;
+ }
+ }
+
+ return result;
+ }
+
+ public File getModule() {
+ return module;
+ }
+
+ public String getTemplatePath() {
+ return templatePath;
+ }
+
+ public boolean isOfficialVCS() {
+ return officialVCS;
+ }
+ }
+
+ /**
+ * Generate javadoc and display output in UI.
+ */
+ public void generateScriptJavadoc() {
+ setStatusMessage(t("isisfish.script.menu.javadocgenerating",
+ IsisFish.config.getJavadocDirectory()), true);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ File rootDatabase = IsisFish.config.getDatabaseDirectory();
+ File javadocDirectory = IsisFish.config.getJavadocDirectory();
+
+ StringWriter output = new StringWriter();
+ PrintWriter out = new PrintWriter(output);
+ int ok = JavadocHelper.generateJavadoc(rootDatabase,
+ javadocDirectory, out);
+
+ if (ok == 0) {
+ scriptUI.getActionLogArea().setText(
+ t("isisfish.script.javadoc.ok", output.toString()));
+ // vert leger
+ scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
+ } else {
+ scriptUI.getActionLogArea().setText(
+ t("isisfish.script.compilation.failed", output
+ .toString()));
+ // rouge leger
+ scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
+ }
+
+ setStatusMessage(t("isisfish.script.menu.javadocgenerated",
+ IsisFish.config.getJavadocDirectory()));
+ }
+ });
+ }
+
+ /**
+ * Open a browser displaying javadoc.
+ */
+ public void showScriptJavadoc() {
+ try {
+ // in faut ouvrir l'index, sinon, ca ouvre
+ // un explorateur de fichier
+ File indexFile = new File(IsisFish.config.getJavadocDirectory(),
+ "index.html");
+
+ URI uri = indexFile.toURI();
+ Desktop.getDesktop().browse(uri);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't show script javadocs", e);
+ }
+ }
+ }
+
+ /*
+ * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
+ */
+ @Override
+ public void caretUpdate(CaretEvent e) {
+ // selection pas vide si dot = mark
+ scriptUI.setTextSelected(e.getDot() != e.getMark());
+ }
+
+ /**
+ * Move files.
+ * (called by drag and drop handler).
+ *
+ * @param directory directory to moves files to
+ * @param filesToMove files to move to directory
+ */
+ public void moveFiles(File directory, Collection<File> filesToMove) {
+
+ ScriptTreeModel model = scriptUI.getScriptTreeModel();
+ for (File fileToMove : filesToMove) {
+ model.fileDeleted(fileToMove);
+ File destFile = new File(directory, fileToMove.getName());
+ try {
+ FileUtils.moveFile(fileToMove, destFile);
+ } catch (IOException ex) {
+ throw new IsisFishRuntimeException("Can't move file", ex);
+ }
+ model.fileAdded(destFile);
+ }
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -30,7 +30,7 @@
import javax.swing.DefaultComboBoxModel;
-import fr.ifremer.isisfish.ui.script.ScriptAction.ScriptMapping;
+import fr.ifremer.isisfish.ui.script.ScriptHandler.ScriptMapping;
/**
* Model pour la liste des scripts disponibles.
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -24,16 +24,16 @@
-->
<JPanel layout='{new BorderLayout()}'>
- <ScriptAction id="scriptAction" javaBean="new ScriptAction(this)" />
+ <ScriptHandler id="handler" constructorParams="this" />
<import>
- javax.swing.SwingWorker
java.awt.Font
</import>
+
<script><![CDATA[
- protected void $afterCompleteSetup() {
- getScriptAction().postInit();
- }
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
]]></script>
<Boolean id="fileSelected" javaBean="false" />
@@ -46,63 +46,63 @@
<JMenu id="scriptTxtFile" text="isisfish.script.menu.file">
<JMenu id="scriptNewMenu" text="isisfish.script.menu.new" icon="script.png">
<JMenuItem id="miNewScript" text="isisfish.script.menu.txtNewScript"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityScript)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityScript)' icon="script.png" />
<JMenuItem id="miNewSimulator" text="isisfish.script.menu.txtNewSimulator"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunitySimulator)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunitySimulator)' icon="script.png" />
<JMenuItem id="miNewExport" text="isisfish.script.menu.txtNewExport"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityExport)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityExport)' icon="script.png" />
<JMenuItem id="miNewExportStep" text="isisfish.script.menu.txtNewExportStep"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityExportStep)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityExportStep)' icon="script.png" />
<JMenuItem id="miNewRule" text="isisfish.script.menu.txtNewRule"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityRule)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityRule)' icon="script.png" />
<JMenuItem id="miNewSImulationPlan" text="isisfish.script.menu.txtNewSimulationPlan"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunitySimulationPlan)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunitySimulationPlan)' icon="script.png" />
<JMenuItem id="miNewSensitivity" text="isisfish.script.menu.txtNewSensitivity"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunitySensitivity)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunitySensitivity)' icon="script.png" />
<JMenuItem id="miNewSensitivityExport" text="isisfish.script.menu.txtNewSensitivityExport"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunitySensitivityExport)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunitySensitivityExport)' icon="script.png" />
<JMenuItem text="isisfish.script.menu.txtNewObjective"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityObjective)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityObjective)' icon="script.png" />
<JMenuItem text="isisfish.script.menu.txtNewOptimization"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityOptimization)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityOptimization)' icon="script.png" />
<JMenuItem id="miNewEquationModel" text="isisfish.script.menu.txtNewEquationModel"
- onActionPerformed='getScriptAction().newScript(ScriptAction.ScriptMapping.CommunityFormule)' icon="script.png" />
+ onActionPerformed='handler.newScript(ScriptHandler.ScriptMapping.CommunityFormule)' icon="script.png" />
</JMenu>
<JMenuItem id="miSave" text="isisfish.script.menu.save"
- onActionPerformed="getScriptAction().saveScript()" icon="script_save.png" enabled='{isSingleFileSelected()}' />
+ onActionPerformed="handler.saveScript()" icon="script_save.png" enabled='{isSingleFileSelected()}' />
<JSeparator/>
<JMenuItem id="miDelete" text="isisfish.script.menu.deleteLocaly"
- onActionPerformed='getScriptAction().deleteScript(false)' icon="script_delete.png" enabled='{isSingleFileSelected()}' />
+ onActionPerformed='handler.deleteScript(false)' icon="script_delete.png" enabled='{isSingleFileSelected()}' />
</JMenu>
<JMenu id="scriptTxtEdit" text="isisfish.script.menu.edit">
<JMenuItem id="miCut" text="isisfish.script.menu.cut"
- onActionPerformed="getScriptAction().cut()" icon="cut.png" enabled='{isTextSelected()}' />
+ onActionPerformed="handler.cut()" icon="cut.png" enabled='{isTextSelected()}' />
<JMenuItem id="miCopy" text="isisfish.script.menu.copy"
- onActionPerformed="getScriptAction().copy()" icon="page_copy.png" enabled='{isTextSelected()}' />
+ onActionPerformed="handler.copy()" icon="page_copy.png" enabled='{isTextSelected()}' />
<JMenuItem id="miPaste" text="isisfish.script.menu.paste"
- onActionPerformed="getScriptAction().paste()" icon="page_paste.png" enabled='{isSingleFileSelected()}' />
+ onActionPerformed="handler.paste()" icon="page_paste.png" enabled='{isSingleFileSelected()}' />
</JMenu>
<JMenu id="scriptTxtVCS" text="isisfish.script.menu.txtVCS">
<JMenuItem id="miCommitVCS" text="isisfish.script.menu.commit" icon="database_go.png"
- onActionPerformed="getScriptAction().commitScript()" enabled='{isSingleFileSelected()}' />
+ onActionPerformed="handler.commitScript()" enabled='{isSingleFileSelected()}' />
<JMenuItem id="miDiffVCS" text="isisfish.script.menu.diff" accelerator="mnDiffVCS"
- onActionPerformed="getScriptAction().diffScript()" enabled='{isSingleFileSelected()}' />
+ onActionPerformed="handler.diffScript()" enabled='{isSingleFileSelected()}' />
<JSeparator/>
<JMenuItem id="miDeleteVCS" text="isisfish.script.menu.deleteLocalyServer"
- onActionPerformed='getScriptAction().deleteScript(true)' icon="database_delete.png"/>
+ onActionPerformed='handler.deleteScript(true)' icon="database_delete.png"/>
</JMenu>
<JMenu id="scriptTxtCode" text="isisfish.script.menu.code">
<JMenuItem id="miCheckSyntax" text="isisfish.script.menu.checkSyntax" icon="script_code_red.png"
- onActionPerformed="getScriptAction().checkScript()" enabled='{isJavaFileSelected()}' />
+ onActionPerformed="handler.checkScript()" enabled='{isJavaFileSelected()}' />
<JMenuItem id="miCheckAllSyntax" text="isisfish.script.menu.checkAllSyntax" icon="script_code_red.png"
- onActionPerformed="new SwingWorker<Void, Void>(){public Void doInBackground(){getScriptAction().checkAllScripts();return null;}}.execute()" />
+ onActionPerformed="handler.checkAllScripts()" />
<JMenuItem id="miEvaluate" text="isisfish.script.menu.evaluate" icon="script_gear.png"
- onActionPerformed="getScriptAction().evaluateScript()" enabled='{isJavaFileSelected()}' />
+ onActionPerformed="handler.evaluateScript()" enabled='{isJavaFileSelected()}' />
<JSeparator/>
<JMenuItem id="miGenerateJavadoc" text="isisfish.script.menu.javadocgenerate"
- onActionPerformed="getScriptAction().generateScriptJavadoc()"/>
+ onActionPerformed="handler.generateScriptJavadoc()"/>
<JMenuItem id="miShowJavadoc" text="isisfish.script.menu.javadocshow"
- onActionPerformed="getScriptAction().showScriptJavadoc()"/>
+ onActionPerformed="handler.showScriptJavadoc()"/>
</JMenu>
</JMenuBar>
@@ -110,23 +110,23 @@
<JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
<JPanel id="buttonBar" layout='{new GridLayout()}' constraints='BorderLayout.NORTH'>
<JButton id="buttonScriptNew" text="isisfish.script.newplus" toolTipText='isisfish.script.new.tooltip'
- onMousePressed='getScriptAction().newScript(this, event)' icon="script.png" />
+ onMousePressed='handler.newScript(event)' icon="script.png" />
<JButton id="buttonScriptSave" text="isisfish.script.save" toolTipText="isisfish.script.save.tooltip"
- enabled='{isSingleFileSelected()}' onActionPerformed='getScriptAction().saveScript()' icon="script_save.png" />
+ enabled='{isSingleFileSelected()}' onActionPerformed='handler.saveScript()' icon="script_save.png" />
<JButton id="buttonScriptExport" text="isisfish.script.export" toolTipText="isisfish.script.export.tooltip" enabled='false'
- onActionPerformed='getScriptAction().exportScript()' icon="page_white_compressed.png" />
+ onActionPerformed='handler.exportScript()' icon="page_white_compressed.png" />
<JButton id="buttonScriptCommit" text="isisfish.script.commit" toolTipText="isisfish.script.commit.tooltip" enabled='{isSingleFileSelected()}'
- onActionPerformed='getScriptAction().commitScript()' icon="database_go.png" />
+ onActionPerformed='handler.commitScript()' icon="database_go.png" />
<JButton id="buttonScriptCut" text="isisfish.script.cut" toolTipText="isisfish.script.cut.tooltip" enabled='{isTextSelected()}'
- onActionPerformed='getScriptAction().cut()' icon="cut.png" />
+ onActionPerformed='handler.cut()' icon="cut.png" />
<JButton id="buttonScriptCopy" text="isisfish.script.copy" toolTipText="isisfish.script.copy.tooltip" enabled='{isTextSelected()}'
- onActionPerformed='getScriptAction().copy()' icon="page_copy.png" />
+ onActionPerformed='handler.copy()' icon="page_copy.png" />
<JButton id="buttonScriptPaste" text="isisfish.script.paste" toolTipText="isisfish.script.paste.tooltip" enabled='{isSingleFileSelected()}'
- onActionPerformed='getScriptAction().paste()' icon="page_paste.png" />
+ onActionPerformed='handler.paste()' icon="page_paste.png" />
<JButton id="buttonScriptCheck" text="isisfish.script.check" toolTipText="isisfish.script.check.tooltip" enabled='{isJavaFileSelected()}'
- onActionPerformed='getScriptAction().checkScript()' icon="script_code_red.png" />
+ onActionPerformed='handler.checkScript()' icon="script_code_red.png" />
<JButton id="buttonScriptEval" text="isisfish.script.evaluate" toolTipText="isisfish.script.evaluate.tooltip" enabled='{isJavaFileSelected()}'
- onActionPerformed='getScriptAction().evaluateScript()' icon="script_gear.png" />
+ onActionPerformed='handler.evaluateScript()' icon="script_gear.png" />
</JPanel>
<JSplitPane oneTouchExpandable="true" dividerLocation="250" orientation="HORIZONTAL" constraints='BorderLayout.CENTER'>
<JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/model/ScriptTransferHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/model/ScriptTransferHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/model/ScriptTransferHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -151,7 +151,7 @@
if (directory != null) {
Object myObject = transferable.getTransferData(ScriptTranferable.myData);
List<File> movedFiles = (List<File>) myObject;
- scriptUI.getScriptAction().moveFiles(directory, movedFiles);
+ scriptUI.getHandler().moveFiles(directory, movedFiles);
}
} catch (IOException e) {
if (log.isErrorEnabled()) {
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,51 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.sensitivity;
+
+import fr.ifremer.isisfish.ui.WelcomeSaveVerifier;
+import fr.ifremer.isisfish.ui.simulator.SimulAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+
+/**
+ * Ce contexte regroupe les élements qui servent à une hierachie d'interfaces Sensitivity.
+ *
+ * @author Eric Chatellier
+ */
+public class SensitivityContext extends JAXXInitialContext {
+
+ public SensitivityContext(JAXXContext parent) {
+ setParentContext(parent);
+
+ // add save verifier for this hierarchy
+ SensitivitySaveVerifier sensitivitySaveVerifier = new SensitivitySaveVerifier();
+ add(sensitivitySaveVerifier);
+
+ // this verifier is linked to global verifier
+ WelcomeSaveVerifier welcomeSaveVerifier = getContextValue(WelcomeSaveVerifier.class);
+ welcomeSaveVerifier.addSaveVerifier(sensitivitySaveVerifier);
+
+ // FIXME remove this
+ add(new SimulAction());
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -32,12 +32,10 @@
import java.io.File;
import java.util.List;
-import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.event.TreeSelectionEvent;
-import javax.swing.text.JTextComponent;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
@@ -47,9 +45,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.gui.MatrixPanelEditor;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityContextable;
import org.nuiton.util.FileUtil;
@@ -59,18 +55,14 @@
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.types.TimeStep;
+import fr.ifremer.isisfish.ui.NavigationHandler;
import fr.ifremer.isisfish.ui.input.InputContentUI;
-import fr.ifremer.isisfish.ui.input.InputHandler;
-import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeRenderer;
import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI;
import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler;
-import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
/**
@@ -82,7 +74,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class SensitivityInputHandler extends InputHandler {
+public class SensitivityInputHandler extends NavigationHandler {
/** Class logger. */
private static Log log = LogFactory.getLog(SensitivityInputHandler.class);
@@ -313,37 +305,13 @@
}
}
- /**
- * Return if type can be defined as a factor.
- *
- * @param type type
- * @return {@code true} if type can be defined as a factor
- */
- public boolean canBeFactor(Class type) {
- boolean result = false;
-
- if (TopiaEntity.class.isAssignableFrom(type)) {
- result = true;
- } else if (double.class.isAssignableFrom(type)) {
- result = true;
- } else if (Number.class.isAssignableFrom(type)) {
- result = true;
- } else if (TimeStep.class.isAssignableFrom(type)) {
- result = true;
- } else if (Month.class.isAssignableFrom(type)) {
- result = true;
- }
-
- return result;
- }
-
- /**
+ /*
* Return value in swing component that could be next used into factor
* for discrete factor values.
*
* @param component component
* @return factor value
- */
+ *
protected Object getComponentValue(JComponent component) {
Object result = null;
if (component instanceof JTextComponent) {
@@ -360,7 +328,7 @@
}
return result;
- }
+ }*/
/**
* Export factors list to xml mexico file.
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,8 +23,6 @@
package fr.ifremer.isisfish.ui.sensitivity;
-import javax.swing.JOptionPane;
-
import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
/**
@@ -47,7 +45,7 @@
// qui sont passés ou des modifications d'equation
// on ne doit pas demander à l'utilisateur de sauver
// ou meme carrement sauver les modification
- return JOptionPane.YES_OPTION;
+ return YES_OPTION;
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -46,8 +46,8 @@
@Override
public void refresh() {
- paramsUI.refresh();
- advancedParamsUI.refresh();
+ paramsUI.getHandler().refresh();
+ advancedParamsUI.getHandler().refresh();
}
@Override
@@ -75,13 +75,14 @@
sensitivityTabUI.setFactorModel();
}
]]></script>
+
<JTabbedPane id="bodyTabbedPane">
<tab title='isisfish.params.title'>
<fr.ifremer.isisfish.ui.simulator.ParamsUI id='paramsUI' sensitivity='true' regionStorage="{getRegionStorage()}"
constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivity.title' enabled="false">
- <fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI id="sensitivityTabUI"
+ <SensitivityTabUI id="sensitivityTabUI"
constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivityChooser.title' enabled="false">
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -40,8 +40,6 @@
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;
-import jaxx.runtime.context.JAXXInitialContext;
-
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,144 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.DefaultTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * AdvancedParams UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class AdvancedParamsHandler extends SimulationTabHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(AdvancedParamsHandler.class);
+
+ protected AdvancedParamsUI tabUI;
+
+ protected AdvancedParamsHandler(AdvancedParamsUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+ /**
+ * Listener to enable/disable remove button.
+ */
+ tabUI.tableTagValues.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ tabUI.setRemove(tabUI.tableTagValues.getSelectedRow() != -1);
+ }
+ });
+
+ refresh();
+ }
+
+ public void refresh() {
+ tabUI.fieldSimulAdvParamsSimulatorSelect.setSelectedItem(tabUI.getContextValue(SimulAction.class).getSimulationParameter().getSimulatorName());
+ tabUI.fieldSimulationStatistique.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic());
+ tabUI.fieldSimulationCache.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().getUseCache());
+
+ tabUI.fieldSimulAdvParamsSimulLoggerError.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isSimulErrorLevel());
+ tabUI.fieldSimulAdvParamsSimulLoggerWarn.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isSimulWarnLevel());
+ tabUI.fieldSimulAdvParamsSimulLoggerInfo.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isSimulInfoLevel());
+ tabUI.fieldSimulAdvParamsSimulLoggerDebug.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isSimulDebugLevel());
+
+ tabUI.fieldSimulAdvParamsScriptLoggerError.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isScriptErrorLevel());
+ tabUI.fieldSimulAdvParamsScriptLoggerWarn.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isScriptWarnLevel());
+ tabUI.fieldSimulAdvParamsScriptLoggerInfo.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isScriptInfoLevel());
+ tabUI.fieldSimulAdvParamsScriptLoggerDebug.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isScriptDebugLevel());
+
+ tabUI.fieldSimulAdvParamsLibLoggerError.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isLibErrorLevel());
+ tabUI.fieldSimulAdvParamsLibLoggerWarn.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isLibWarnLevel());
+ tabUI.fieldSimulAdvParamsLibLoggerInfo.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isLibInfoLevel());
+ tabUI.fieldSimulAdvParamsLibLoggerDebug.setSelected(tabUI.getContextValue(SimulAction.class).getSimulationParameter().isLibDebugLevel());
+
+ setTableTagValues();
+ }
+
+ protected void addTagValue() {
+ tabUI.getContextValue(SimulAction.class).addTagValue(tabUI.fieldTag.getText(), tabUI.fieldValue.getText());
+ setTableTagValues();
+ valueChanged(true);
+ }
+
+ protected void removeTagValue() {
+ tabUI.getContextValue(SimulAction.class).removeTagValue(tabUI.tableTagValues.getValueAt(tabUI.tableTagValues.getSelectedRow(),0).toString());
+ setTableTagValues();
+ valueChanged(true);
+ }
+
+ protected void saveTagValues() {
+ if (tabUI.fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1) {
+ tabUI.getContextValue(SimulAction.class).saveTagValue(tabUI.fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
+ }
+ valueChanged(false);
+ }
+
+ protected void setSimulatorName() {
+ if (tabUI.fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1) {
+ tabUI.getContextValue(SimulAction.class).getSimulationParameter().setSimulatorName(tabUI.fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
+ valueChanged(true);
+ }
+ }
+
+ protected void setTableTagValues() {
+ Map<String, String> tagValues = tabUI.getContextValue(SimulAction.class).getSimulationParameter().getTagValue();
+
+ // TODO make a table model for it
+ String columnName[] = { t("isisfish.common.tag"), t("isisfish.common.value")};
+ if (tagValues != null) {
+ DefaultTableModel model = new DefaultTableModel(columnName, tagValues.size()) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+ };
+ //Set<Entry<String, String>> set = tagValues.entrySet();
+ int row = 0;
+ for (Iterator<String> it = tagValues.keySet().iterator(); it.hasNext();) {
+ String name = it.next();
+ model.setValueAt(name, row, 0);
+ model.setValueAt(tagValues.get(name), row, 1);
+ row++;
+ }
+ tabUI.tableTagValues.setModel(model);
+ }
+ }
+
+ protected void valueChanged(boolean b) {
+ tabUI.setChanged(b);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,120 +23,24 @@
#L%
-->
<Table>
+
+ <AdvancedParamsHandler id="handler" constructorParams="this" />
+
<Boolean id='ajout' javaBean='false'/>
<Boolean id='remove' javaBean='false'/>
<Boolean id='changed' javaBean='false'/>
<import>
static org.nuiton.i18n.I18n.t
- javax.swing.table.DefaultTableModel;
- java.util.Map.Entry;
- javax.swing.event.ListSelectionListener
- java.util.Set
- java.util.Iterator
javax.swing.DefaultComboBoxModel
- javax.swing.event.ListSelectionEvent
</import>
- <script><![CDATA[
-
+ <script><![CDATA[
protected void $afterCompleteSetup() {
- /**
- * Listener to enable/disable remove button.
- */
- tableTagValues.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- @Override
- public void valueChanged(ListSelectionEvent e) {
- setRemove(tableTagValues.getSelectedRow() != -1);
- }
- });
-
- refresh();
+ handler.afterInit();
}
-
- public void refresh() {
- fieldSimulAdvParamsSimulatorSelect.setSelectedItem(getContextValue(SimulAction.class).getSimulationParameter().getSimulatorName());
- fieldSimulationStatistique.setSelected(getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic());
- fieldSimulationCache.setSelected(getContextValue(SimulAction.class).getSimulationParameter().getUseCache());
+ ]]></script>
- fieldSimulAdvParamsSimulLoggerError.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isSimulErrorLevel());
- fieldSimulAdvParamsSimulLoggerWarn.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isSimulWarnLevel());
- fieldSimulAdvParamsSimulLoggerInfo.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isSimulInfoLevel());
- fieldSimulAdvParamsSimulLoggerDebug.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isSimulDebugLevel());
-
- fieldSimulAdvParamsScriptLoggerError.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isScriptErrorLevel());
- fieldSimulAdvParamsScriptLoggerWarn.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isScriptWarnLevel());
- fieldSimulAdvParamsScriptLoggerInfo.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isScriptInfoLevel());
- fieldSimulAdvParamsScriptLoggerDebug.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isScriptDebugLevel());
-
- fieldSimulAdvParamsLibLoggerError.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibErrorLevel());
- fieldSimulAdvParamsLibLoggerWarn.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibWarnLevel());
- fieldSimulAdvParamsLibLoggerInfo.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibInfoLevel());
- fieldSimulAdvParamsLibLoggerDebug.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibDebugLevel());
-
- setTableTagValues();
- }
-
- public AdvancedParamsUI(SimulAction action) {
- setContextValue(action);
- }
-
- protected void addTagValue() {
- getContextValue(SimulAction.class).addTagValue(fieldTag.getText(), fieldValue.getText());
- setTableTagValues();
- valueChanged(true);
- }
-
- protected void removeTagValue() {
- getContextValue(SimulAction.class).removeTagValue(tableTagValues.getValueAt(tableTagValues.getSelectedRow(),0).toString());
- setTableTagValues();
- valueChanged(true);
- }
-
- protected void saveTagValues() {
- if (fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1) {
- getContextValue(SimulAction.class).saveTagValue(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
- }
- valueChanged(false);
- }
-
- protected void setSimulatorName() {
- if (fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1) {
- getContextValue(SimulAction.class).getSimulationParameter().setSimulatorName(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
- valueChanged(true);
- }
- }
-
- protected void setTableTagValues() {
- Map<String, String> tagValues = getContextValue(SimulAction.class).getSimulationParameter().getTagValue();
-
- // TODO make a table model for it
- String columnName[] = { t("isisfish.common.tag"), t("isisfish.common.value")};
- if (tagValues != null) {
- DefaultTableModel model = new DefaultTableModel(columnName, tagValues.size()) {
- @Override
- public boolean isCellEditable(int row, int column) {
- return false;
- }
- };
- Set<Entry<String, String>> set = tagValues.entrySet();
- int row = 0;
- for (Iterator<String> it = tagValues.keySet().iterator(); it.hasNext();) {
- String name = it.next();
- model.setValueAt(name, row, 0);
- model.setValueAt(tagValues.get(name), row, 1);
- row++;
- }
- tableTagValues.setModel(model);
- }
- }
-
- protected void valueChanged(boolean b) {
- setChanged(b);
- }
-
- ]]>
- </script>
<row>
<cell fill="horizontal" rows="2">
<JLabel text="isisfish.advancedParams.simulatorUse"/>
@@ -145,7 +49,7 @@
<JComboBox id="fieldSimulAdvParamsSimulatorSelect"
genericType="String"
model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulatorNames().toArray())}'
- onActionPerformed='setSimulatorName()'/>
+ onActionPerformed='handler.setSimulatorName()'/>
</cell>
</row>
<row>
@@ -254,7 +158,7 @@
</row>
<row>
<cell columns="4" fill="horizontal" weightx="1.0">
- <JButton text="isisfish.common.add" enabled="{isAjout()}" onActionPerformed='addTagValue()'/>
+ <JButton text="isisfish.common.add" enabled="{isAjout()}" onActionPerformed='handler.addTagValue()'/>
</cell>
</row>
<row>
@@ -266,12 +170,12 @@
</row>
<row>
<cell columns="4" fill="horizontal" weightx="1.0">
- <JButton text="isisfish.common.remove" enabled="{isRemove()}" onActionPerformed='removeTagValue()'/>
+ <JButton text="isisfish.common.remove" enabled="{isRemove()}" onActionPerformed='handler.removeTagValue()'/>
</cell>
</row>
<row>
<cell columns="5" fill="horizontal">
- <JButton text="isisfish.common.saveNextSimulation" enabled="{isChanged()}" onActionPerformed='saveTagValues()'/>
+ <JButton text="isisfish.common.saveNextSimulation" enabled="{isChanged()}" onActionPerformed='handler.saveTagValues()'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,118 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.event.ListSelectionEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.ui.WelcomePanelUI;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Export UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class ExportHandler extends SimulationTabHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ExportHandler.class);
+
+ protected ExportUI tabUI;
+
+ protected ExportHandler(ExportUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+ refresh();
+ }
+
+ protected SimulAction getSimulAction() {
+ return tabUI.getContextValue(SimulAction.class);
+ }
+
+ public void refresh() {
+
+ // FIXME listen for export modification here
+
+ // fill export
+ setListSimulExportChooseModel();
+ }
+
+ protected void setListSimulExportChooseModel() {
+ java.util.List<String> availableExports = getSimulAction().getExportNames();
+ java.util.List<String> userExports = getSimulAction().getSimulationParameter().getExportNames();
+ // userExports = intersection(userExports,availableExports)
+ userExports.retainAll(availableExports);
+
+ GenericListModel<String> exportModel = new GenericListModel<String>(availableExports);
+ tabUI.listSimulExportChoose.setModel(exportModel);
+
+ for (String userExport : userExports) {
+ int index = availableExports.indexOf(userExport);
+ tabUI.listSimulExportChoose.addSelectionInterval(index, index);
+ }
+ }
+
+ protected void saveSimulationExports(ListSelectionEvent event) {
+ // Set exports (this can save empty list (not a big deal))
+ List<String> values = tabUI.listSimulExportChoose.getSelectedValuesList();
+ List<String> exportNames = new LinkedList<>();
+ for (String o : values) {
+ exportNames.add(o);
+ }
+ getSimulAction().getSimulationParameter().setExportNames(exportNames);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Set exports in simulation : " + exportNames);
+ }
+ }
+
+ protected void saveConfigExports() {
+ // Set exports (this can save empty list (not a big deal))
+ List<String> values = tabUI.listSimulExportChoose.getSelectedValuesList();
+ List<String> exportNames = new LinkedList<String>();
+ for (String o : values) {
+ exportNames.add(o);
+ }
+ getSimulAction().getSimulationParameter().setExportNames(exportNames);
+
+ getSimulAction().saveExport();
+ setInfoText(t("isisfish.export.saved"));
+ }
+
+ protected void setInfoText(String txt) {
+ // TODO remove getParentContainer use
+ WelcomePanelUI root = tabUI.getParentContainer(WelcomePanelUI.class);
+ root.setStatusMessage(txt);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,94 +23,27 @@
#L%
-->
<Table>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.ui.WelcomePanelUI;
- fr.ifremer.isisfish.ui.models.common.GenericListModel;
- javax.swing.event.ListSelectionEvent;
- java.util.LinkedList
- </import>
+ <ExportHandler id="handler" constructorParams="this" />
<script><![CDATA[
-
protected void $afterCompleteSetup() {
- refresh();
+ handler.afterInit();
}
+ ]]></script>
- protected SimulAction getSimulAction() {
- return getContextValue(SimulAction.class);
- }
-
- public void refresh() {
-
- // FIXME listen for export modification here
-
- // fill export
- setListSimulExportChooseModel();
- }
-
- protected void setListSimulExportChooseModel() {
- java.util.List<String> availableExports = getSimulAction().getExportNames();
- java.util.List<String> userExports = getSimulAction().getSimulationParameter().getExportNames();
- // userExports = intersection(userExports,availableExports)
- userExports.retainAll(availableExports);
-
- GenericListModel<String> exportModel = new GenericListModel<String>(availableExports);
- listSimulExportChoose.setModel(exportModel);
-
- for (String userExport : userExports) {
- int index = availableExports.indexOf(userExport);
- listSimulExportChoose.addSelectionInterval(index, index);
- }
- }
-
- protected void saveSimulationExports(ListSelectionEvent event) {
- // Set exports (this can save empty list (not a big deal))
- List<String> values = listSimulExportChoose.getSelectedValuesList();
- List<String> exportNames = new LinkedList<>();
- for (String o : values) {
- exportNames.add(o);
- }
- getSimulAction().getSimulationParameter().setExportNames(exportNames);
-
- if (log.isDebugEnabled()) {
- log.debug("Set exports in simulation : " + exportNames);
- }
- }
-
- protected void saveConfigExports() {
- // Set exports (this can save empty list (not a big deal))
- List<String> values = listSimulExportChoose.getSelectedValuesList();
- List<String> exportNames = new LinkedList<String>();
- for (String o : values) {
- exportNames.add(o);
- }
- getSimulAction().getSimulationParameter().setExportNames(exportNames);
-
- getSimulAction().saveExport();
- setInfoText(t("isisfish.export.saved"));
- }
-
- protected void setInfoText(String txt) {
- // TODO remove getParentContainer use
- WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
- root.setStatusMessage(txt);
- }
- ]]>
- </script>
<row>
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
<JList id="listSimulExportChoose" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
genericType="String"
cellRenderer='{new fr.ifremer.isisfish.ui.models.export.ExportNameListRenderer()}'
- onValueChanged='saveSimulationExports(event)' />
+ onValueChanged='handler.saveSimulationExports(event)' />
</JScrollPane>
</cell>
</row>
<row>
<cell fill="horizontal">
- <JButton text="isisfish.common.saveNextSimulation" onActionPerformed='saveConfigExports()'/>
+ <JButton text="isisfish.common.saveNextSimulation" onActionPerformed='handler.saveConfigExports()'/>
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -63,48 +63,55 @@
import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
import fr.ifremer.isisfish.ui.widget.editor.FactorEditorListener;
-public class OptimizationHandler {
+public class OptimizationHandler extends SimulationTabHandler {
private static final Log log = LogFactory.getLog(OptimizationHandler.class);
protected FactorEditorListener factorEditorListener;
- public void init(final OptimizationUI view) {
-
+ protected OptimizationUI tabUI;
+
+ public OptimizationHandler(OptimizationUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
}
+
+ public void afterInit() {
+ // model init
+ tabUI.getExportObservationTable().setModel(getExportObservationTableModel());
+ }
- public void refresh(OptimizationUI view) {
+ public void refresh() {
// get info
- SimulAction simulAction = view.getContextValue(SimulAction.class);
+ SimulAction simulAction = tabUI.getContextValue(SimulAction.class);
SimulationParameter param = simulAction.getSimulationParameter();
- RegionStorage regionStorage = view.getContextValue(RegionStorage.class);
+ RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class);
// refresh after simulation storage set
if (param.getObjective() != null) {
- view.getFieldObjectiveMethodSelect().setSelectedItem(ObjectiveStorage.getName(param.getObjective()));
+ tabUI.getFieldObjectiveMethodSelect().setSelectedItem(ObjectiveStorage.getName(param.getObjective()));
}
if (param.getOptimization() != null) {
- view.getFieldOptimizationMethodSelect().setSelectedItem(OptimizationStorage.getName(param.getOptimization()));
+ tabUI.getFieldOptimizationMethodSelect().setSelectedItem(OptimizationStorage.getName(param.getOptimization()));
}
// export/observation
- view.getExportObservationTable().setModel(getExportObservationTableModel(view));
+ tabUI.getExportObservationTable().setModel(getExportObservationTableModel());
// order matters
- view.getExportObservationTable().getColumnModel().getColumn(0).setCellRenderer(new ExportTableCellRenderer());
+ tabUI.getExportObservationTable().getColumnModel().getColumn(0).setCellRenderer(new ExportTableCellRenderer());
ExportTableCellEditor editor = new ExportTableCellEditor();
editor.setRegionStorage(regionStorage);
- view.getExportObservationTable().getColumnModel().getColumn(1).setCellEditor(editor);
- view.getExportObservationTable().getColumnModel().getColumn(1).setCellRenderer(new ExportTableCellRenderer());
+ tabUI.getExportObservationTable().getColumnModel().getColumn(1).setCellEditor(editor);
+ tabUI.getExportObservationTable().getColumnModel().getColumn(1).setCellRenderer(new ExportTableCellRenderer());
}
/**
* Get simulation parameter from ui context.
*
- * @param view view (ui context)
* @return simulation parameters
*/
- protected SimulationParameter getSimulationParameter(OptimizationUI view) {
- SimulAction simulAction = view.getContextValue(SimulAction.class);
+ protected SimulationParameter getSimulationParameter() {
+ SimulAction simulAction = tabUI.getContextValue(SimulAction.class);
SimulationParameter param = simulAction.getSimulationParameter();
return param;
}
@@ -115,7 +122,7 @@
* @return model
*/
public GenericComboModel<String> getObjectiveComboModel() {
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
for (String r : ObjectiveStorage.getObjectiveNames()) {
// there is some non java files in sensitivity directory
if (r.endsWith(".java")) {
@@ -125,19 +132,17 @@
}
}
- GenericComboModel<String> model = new GenericComboModel<String>(result);
+ GenericComboModel<String> model = new GenericComboModel<>(result);
return model;
}
/**
* Selection d'une méthode d'optimisation.
- *
- * @param view view
*/
- public void objectiveChanged(OptimizationUI view) {
- String objectiveName = (String)view.getFieldObjectiveMethodSelect().getSelectedItem();
- SimulationParameter param = getSimulationParameter(view);
- RegionStorage regionStorage = view.getContextValue(RegionStorage.class);
+ public void objectiveChanged() {
+ String objectiveName = (String)tabUI.getFieldObjectiveMethodSelect().getSelectedItem();
+ SimulationParameter param = getSimulationParameter();
+ RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class);
// creation new instance only when name change to not lose parameters value
Objective objective = param.getObjective();
@@ -158,37 +163,36 @@
// update model
ScriptParametersTableModel parametersTableModel = new ScriptParametersTableModel(objective);
- view.getSimulObjectiveMethodParam().setModel(parametersTableModel);
- view.getSimulObjectiveMethodParam().getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(objective));
+ tabUI.getSimulObjectiveMethodParam().setModel(parametersTableModel);
+ tabUI.getSimulObjectiveMethodParam().getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(objective));
ScriptParametersTableCellEditor editor = new ScriptParametersTableCellEditor(objective);
editor.setRegionStorage(regionStorage);
- editor.setFactorActionListener(getFactorActionListener(view));
- view.getSimulObjectiveMethodParam().getColumnModel().getColumn(1).setCellEditor(editor);
+ editor.setFactorActionListener(getFactorActionListener());
+ tabUI.getSimulObjectiveMethodParam().getColumnModel().getColumn(1).setCellEditor(editor);
}
}
/**
* Retourne une instance de action listener qui affichera l'interface de sélection d'un facteur.
*
- * @param view parent view
* @return action listener
*/
- protected FactorEditorListener getFactorActionListener(final OptimizationUI view) {
+ protected FactorEditorListener getFactorActionListener() {
if (factorEditorListener == null) {
factorEditorListener = new FactorEditorListener() {
public void actionPerformed(ActionEvent event) {
// init new sensitivity tav ui hierarchy
- final SensitivityTabUI sensitivityTabUI = new SensitivityTabUI(view);
+ final SensitivityTabUI sensitivityTabUI = new SensitivityTabUI(tabUI);
sensitivityTabUI.setContextValue(new SensitivitySaveVerifier()); // prevent NPE
- sensitivityTabUI.setContextValue(view.getParentContainer(SimulationUI.class), "SimulationUI"); // prevent NPE
+ sensitivityTabUI.setContextValue(tabUI.getParentContainer(SimulationUI.class), "SimulationUI"); // prevent NPE
// init region
// FIXME this transaction in never closed
// and can't be closed because used in
try {
- RegionStorage regionStorage = view.getContextValue(RegionStorage.class);
+ RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class);
TopiaContext tx = regionStorage.getStorage().beginTransaction();
FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx);
sensitivityTabUI.setFisheryRegion(fisheryRegion);
@@ -202,7 +206,7 @@
dialog.setTitle("Sélection d'un facteur");
dialog.add(sensitivityTabUI);
dialog.setSize(800, 600);
- dialog.setLocationRelativeTo(view);
+ dialog.setLocationRelativeTo(tabUI);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
@@ -240,19 +244,17 @@
}
}
- GenericComboModel<String> model = new GenericComboModel<String>(result);
+ GenericComboModel<String> model = new GenericComboModel<>(result);
return model;
}
/**
* Selection d'une méthode d'optimisation.
- *
- * @param view view
*/
- public void optimizationChanged(OptimizationUI view) {
- String optimizationName = (String)view.getFieldOptimizationMethodSelect().getSelectedItem();
- SimulationParameter param = getSimulationParameter(view);
- RegionStorage regionStorage = view.getContextValue(RegionStorage.class);
+ public void optimizationChanged() {
+ String optimizationName = (String)tabUI.getFieldOptimizationMethodSelect().getSelectedItem();
+ SimulationParameter param = getSimulationParameter();
+ RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class);
// creation new instance only when name change to not lose parameters value
Optimization optimization = param.getOptimization();
@@ -273,13 +275,13 @@
// update model
ScriptParametersTableModel parametersTableModel = new ScriptParametersTableModel(optimization);
- view.getSimulOptimizationMethodParam().setModel(parametersTableModel);
- view.getSimulOptimizationMethodParam().getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(optimization));
+ tabUI.getSimulOptimizationMethodParam().setModel(parametersTableModel);
+ tabUI.getSimulOptimizationMethodParam().getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(optimization));
ScriptParametersTableCellEditor editor = new ScriptParametersTableCellEditor(optimization);
editor.setRegionStorage(regionStorage);
- editor.setFactorActionListener(getFactorActionListener(view));
- view.getSimulOptimizationMethodParam().getColumnModel().getColumn(1).setCellEditor(editor);
+ editor.setFactorActionListener(getFactorActionListener());
+ tabUI.getSimulOptimizationMethodParam().getColumnModel().getColumn(1).setCellEditor(editor);
}
}
@@ -289,7 +291,7 @@
* @return model
*/
public ListModel<String> getExportListModel() {
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
for (String r : ExportStorage.getExportNames()) {
// there is some non java files in sensitivity directory
if (r.endsWith(".java")) {
@@ -306,11 +308,10 @@
/**
* ExportInfo model for combo box.
*
- * @param view view
* @return model
*/
- public ExportObservationTableModel getExportObservationTableModel(OptimizationUI view) {
- SimulationParameter param = getSimulationParameter(view);
+ public ExportObservationTableModel getExportObservationTableModel() {
+ SimulationParameter param = getSimulationParameter();
Map<ExportInfo, Observation> optimizationExportsObservations = param.getOptimizationExportsObservations();
ExportObservationTableModel model = new ExportObservationTableModel(optimizationExportsObservations);
return model;
@@ -318,16 +319,14 @@
/**
* Add selected export.
- *
- * @param view view
*/
- public void addExports(OptimizationUI view) {
+ public void addExports() {
// get elements
- SimulationParameter param = getSimulationParameter(view);
- ExportObservationTableModel tableModel = (ExportObservationTableModel)view.getExportObservationTable().getModel();
+ SimulationParameter param = getSimulationParameter();
+ ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel();
// add all selected exports
- List<String> selectedExports = view.getFieldExportList().getSelectedValuesList();
+ List<String> selectedExports = tabUI.getFieldExportList().getSelectedValuesList();
for (String selectedExport : selectedExports) {
try {
// create export instance
@@ -347,16 +346,14 @@
/**
* Remove selected exports in table.
- *
- * @param view view
*/
- public void removeExports(OptimizationUI view) {
+ public void removeExports() {
// get element
- SimulationParameter param = getSimulationParameter(view);
+ SimulationParameter param = getSimulationParameter();
Map<ExportInfo, Observation> optimizationExports = param.getOptimizationExportsObservations();
- ExportObservationTableModel tableModel = (ExportObservationTableModel)view.getExportObservationTable().getModel();
+ ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel();
- JTable table = view.getExportObservationTable();
+ JTable table = tabUI.getExportObservationTable();
int[] rows = table.getSelectedRows();
// reverse order
for (int i = rows.length - 1; i >= 0; i--) {
@@ -371,14 +368,12 @@
/**
* Clear all export in table.
- *
- * @param view view
*/
- public void clearExports(OptimizationUI view) {
+ public void clearExports() {
// get elements
- SimulationParameter param = getSimulationParameter(view);
+ SimulationParameter param = getSimulationParameter();
Map<ExportInfo, Observation> optimizationExports = param.getOptimizationExportsObservations();
- ExportObservationTableModel tableModel = (ExportObservationTableModel)view.getExportObservationTable().getModel();
+ ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel();
// clear
optimizationExports.clear();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,23 +23,15 @@
#L%
-->
<Table>
- <script><![CDATA[
- protected void $afterCompleteSetup() {
- handler.init(this);
- }
- // application will be refreshed by regionStorage change
- protected void regionStorageChanged() {
- //handler.refresh(this);
- }
+ <OptimizationHandler id="handler" constructorParams="this" />
- public void refresh() {
- handler.refresh(this);
- }
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
]]></script>
- <OptimizationHandler id="handler" javaBean='new OptimizationHandler()'/>
-
<!-- Objective choice and param -->
<row>
<cell fill="horizontal">
@@ -47,7 +39,7 @@
</cell>
<cell fill="horizontal" weightx="1.0" columns="2">
<JComboBox id="fieldObjectiveMethodSelect" genericType="String" model='{handler.getObjectiveComboModel()}'
- onActionPerformed='handler.objectiveChanged(this)'
+ onActionPerformed='handler.objectiveChanged()'
renderer="{new fr.ifremer.isisfish.ui.models.optimization.ObjectiveComboRenderer()}"/>
</cell>
</row>
@@ -66,7 +58,7 @@
</cell>
<cell fill="horizontal" weightx="1.0" columns="2">
<JComboBox id="fieldOptimizationMethodSelect" genericType="String" model='{handler.getOptimizationComboModel()}'
- onActionPerformed='handler.optimizationChanged(this)'
+ onActionPerformed='handler.optimizationChanged()'
renderer="{new fr.ifremer.isisfish.ui.models.optimization.OptimizationComboRenderer()}"/>
</cell>
</row>
@@ -97,26 +89,26 @@
<row>
<cell fill="horizontal">
<JButton id="addExportsButton" text="isisfish.common.add" enabled="false"
- onActionPerformed="handler.addExports(this)" />
+ onActionPerformed="handler.addExports()" />
</cell>
</row>
<row>
<cell fill="horizontal">
<JButton id="removeExportsButton" text="isisfish.common.remove" enabled="false"
- onActionPerformed="handler.removeExports(this)" />
+ onActionPerformed="handler.removeExports()" />
</cell>
</row>
<row>
<cell fill="horizontal">
<JButton id="clearExportsButton" text="isisfish.common.clear" enabled="false"
- onActionPerformed="handler.clearExports(this)" />
+ onActionPerformed="handler.clearExports()" />
</cell>
</row>
</Table>
</cell>
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
- <JTable id="exportObservationTable" model="{handler.getExportObservationTableModel(this)}" rowHeight='24' />
+ <JTable id="exportObservationTable" rowHeight='24' />
<ListSelectionModel id="exportObservationSelectionModel" initializer="exportObservationTable.getSelectionModel()"
onValueChanged='removeExportsButton.setEnabled(!exportObservationSelectionModel.isSelectionEmpty());clearExportsButton.setEnabled(exportObservationTable.getModel().getRowCount() > 0);' />
</JScrollPane>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,383 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.Cursor;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListModel;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.datastore.StorageChangeEvent;
+import fr.ifremer.isisfish.datastore.StorageChangeListener;
+import fr.ifremer.isisfish.datastore.StorageException;
+import fr.ifremer.isisfish.entities.FisheryRegion;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
+import fr.ifremer.isisfish.simulator.launcher.SimulationService;
+import fr.ifremer.isisfish.simulator.launcher.SimulationServiceListener;
+import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher;
+import fr.ifremer.isisfish.ui.SimulationUI;
+import fr.ifremer.isisfish.ui.WelcomePanelUI;
+import fr.ifremer.isisfish.ui.WelcomeTabUI;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.sensitivity.SensitivityUI;
+
+/**
+ * Params UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class ParamsHandler extends SimulationTabHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ParamsHandler.class);
+
+ protected ParamsUI tabUI;
+
+ // instances variables déclaration
+ protected SimulationServiceListener simulationListener;
+ protected StorageChangeListener regionStorageListener;
+
+ protected List<String> oldSimulNames = null;
+
+ protected ParamsHandler(ParamsUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+ regionStorageListener = new StorageChangeListener() {
+ @Override
+ public void versionDataChanged(StorageChangeEvent e) {
+ GenericComboModel<String> model = new GenericComboModel<String>(fr.ifremer.isisfish.datastore.RegionStorage.getRegionNames());
+ tabUI.fieldSimulParamsRegion.setModel(model);
+ }
+ };
+ RegionStorage.addStorageChangeListener(regionStorageListener);
+
+ simulationListener = new SimulationServiceListener() {
+ @Override
+ public void simulationStart(SimulationService simService, SimulationJob job) {
+
+ }
+
+ @Override
+ public void simulationStop(SimulationService simService, final SimulationJob job) {
+ final GenericComboModel<String> model = (GenericComboModel<String>)tabUI.fieldSimulParamsSelect.getModel();
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ model.addElement(job.getId());
+ }
+ });
+ }
+
+ @Override
+ public void clearJobDone(SimulationService simService) {
+
+ }
+ };
+ SimulationService.getService().addSimulationServiceListener(simulationListener);
+
+ // la gestion des regles est maintenant independante de SimulAction
+ // il faut faire la lié aux parametres de simulations
+ getSimulAction().getSimulationParameter().setRules(tabUI.ruleChooser.getRulesList());
+ }
+
+ public void refresh() {
+ if (getSimulAction().getSimulationStorage() != null) {
+ tabUI.fieldSimulParamsName.setText(getSimulAction().getSimulationStorage().getName());
+ }
+ tabUI.fieldSimulParamsDesc.setText(getSimulAction().getSimulationParameter().getDescription());
+ setListSimulParamsStrategiesItems();
+ setListSimulParamsPopulationsItems();
+ }
+
+ /**
+ * Called on user region selection change.
+ */
+ protected void regionChange() {
+ // le premier item est " " pour ne pas avoir de selection par defaut
+ final String selected = tabUI.fieldSimulParamsRegion.getSelectedItem().toString();
+ if (log.isDebugEnabled()) {
+ log.debug(" selected " + selected);
+ }
+ if(selected != null && !selected.trim().isEmpty()) {
+ tabUI.getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.loading.region"));
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getSimulAction().regionChange(tabUI, selected);
+ // FIXME fix this
+ if (!tabUI.isSensitivity()) {
+ tabUI.getParentContainer(SimulUI.class).refresh();
+ } else {
+ tabUI.getParentContainer(SensitivityUI.class).refresh();
+ }
+ setSensitivityTabRegion();
+ tabUI.getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.region.loaded"));
+ }
+ });
+ }
+ }
+
+ protected void initSimulationParams() {
+ if (!tabUI.isSensitivity()){
+ // prescript
+ String preScript = getSimulAction().getSimulationParameter().getPreScript();
+ tabUI.fieldUseSimulPreScripts.setSelected(preScript != null && !preScript.isEmpty());
+ tabUI.getParentContainer(SimulUI.class).getPreScriptUI().getFieldSimulPreScript().setText(preScript);
+
+ // simulation plan
+ tabUI.fieldSimulUseSimulationPlan.setSelected(getSimulAction().getSimulationParameter().getUseSimulationPlan());
+ tabUI.getParentContainer(SimulUI.class).getPlanUI().getHandler().refresh();
+
+ // optimization
+ tabUI.fieldSimulUseOptimization.setSelected(getSimulAction().getSimulationParameter().getUseOptimization());
+ tabUI.getParentContainer(SimulUI.class).getOptimizationUI().getHandler().refresh();
+
+ }
+ }
+
+ protected void setSensitivityTabRegion() {
+ if (tabUI.isSensitivity()) {
+ try {
+ // FIXME this transaction in never closed
+ // and can't be closed because used in
+ TopiaContext tx = getSimulAction().getRegionStorage().getStorage().beginTransaction();
+ FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx);
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFisheryRegion(fisheryRegion);
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setTreeModel();
+ } catch (StorageException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't reload factors", ex);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't reload factors", ex);
+ }
+ }
+ }
+ }
+ protected void initSensitivityParams() {
+ if (tabUI.isSensitivity()) {
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().refreshSelectedSensitivityAnalysis();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFactorModel();
+ tabUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().setSensitivityExportListModel();
+ tabUI.sensitivityOnlyKeepFirstResultCheckBox.setSelected(getSimulAction().getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst());
+ }
+ }
+
+ /*public void setSimulationParameter(SimulAction simulAction){
+ getSimulAction().setSimulationParameter(getSimulAction().getSimulationParameter());
+ }*/
+
+ protected void loadOldSimulation() {
+ final String selected = tabUI.fieldSimulParamsSelect.getSelectedItem().toString();
+ // le premier item est " " pour ne pas avoir de selection par defaut
+ if (selected != null && !selected.equals(" ")) {
+ tabUI.getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.loading.old.simulation"));
+ tabUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+
+ getSimulAction().loadOldSimulation(selected);
+ tabUI.fieldSimulParamsRegion.setSelectedItem(tabUI.getContextValue(SimulAction.class).getSimulationParameter().getRegionName());
+
+ // FIXME fix this
+ if (!tabUI.isSensitivity()) {
+ tabUI.getParentContainer(SimulUI.class).refresh();
+ } else {
+ tabUI.getParentContainer(SensitivityUI.class).refresh();
+ }
+
+ // mise a jour des années
+ tabUI.fieldSimulParamsNbMois.setText(String.valueOf(getSimulAction().getNumberOfMonths()));
+ initSimulationParams();
+ initSensitivityParams();
+
+ // regles
+ tabUI.ruleChooser.setRulesList(getSimulAction().getSimulationParameter().getRules());
+
+ tabUI.getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.old.simulation.loaded"));
+ tabUI.setCursor(Cursor.getDefaultCursor());
+ }
+ });
+ }
+ }
+
+ /**
+ * Lance la simulation.
+ */
+ protected void launchSimulation() {
+
+ if (!tabUI.isSensitivity()) {
+ getSimulAction().launchSimulation(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem());
+ } else {
+ getSimulAction().launchSimulationWithSensibility(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem());
+ }
+
+ // dans le cas d'une fenetre independante, il n'y a pas de ParentContainer
+ WelcomeTabUI parent = tabUI.getParentContainer(WelcomeTabUI.class);
+ if (parent != null) {
+ parent.setQueueTabSelection();
+ }
+ }
+ protected void enablePreScript() {
+ getSimulAction().getSimulationParameter().setUsePreScript(tabUI.fieldUseSimulPreScripts.isSelected());
+ SimulationUI simulationUI = tabUI.getParentContainer(SimulationUI.class);
+ simulationUI.setEnabledPrescriptTab(tabUI.fieldUseSimulPreScripts.isSelected());
+ }
+ protected void enableSimulationPlan() {
+ getSimulAction().getSimulationParameter().setUseSimulationPlan(tabUI.fieldSimulUseSimulationPlan.isSelected());
+ SimulationUI simulationUI = tabUI.getParentContainer(SimulationUI.class);
+ simulationUI.setEnabledSimulationPlanTab(tabUI.fieldSimulUseSimulationPlan.isSelected());
+ }
+
+ protected void enableOptimization() {
+ getSimulAction().getSimulationParameter().setUseOptimization(tabUI.fieldSimulUseOptimization.isSelected());
+ SimulationUI simulationUI = tabUI.getParentContainer(SimulationUI.class);
+ simulationUI.setEnabledOptimizationTab(tabUI.fieldSimulUseOptimization.isSelected());
+ }
+
+ protected void setListSimulParamsStrategiesItems() {
+ List<Strategy> strategiesSelected = getSimulAction().getSimulationParameter().getStrategies();
+ DefaultListModel listSimulParamsStrategiesModel = new DefaultListModel();
+ List<Strategy> strategies = getSimulAction().getStrategies();
+ for (Strategy s : strategies){
+ listSimulParamsStrategiesModel.addElement(s);
+ }
+ tabUI.listSimulParamsStrategies.setModel(listSimulParamsStrategiesModel);
+ if (listSimulParamsStrategiesModel.size() != 0) {
+ for (Strategy s : strategiesSelected){
+ int index = listSimulParamsStrategiesModel.indexOf(s);
+ tabUI.listSimulParamsStrategies.addSelectionInterval(index, index);
+ }
+ //strategySelected();
+ }
+ }
+ protected void setListSimulParamsPopulationsItems(){
+ List<Population> populationsSelected = getSimulAction().getSimulationParameter().getPopulations();
+ DefaultListModel listSimulParamsPopulationsModel = new DefaultListModel();
+ List<Population> populations = getSimulAction().getPopulations();
+ for (Population p : populations){
+ listSimulParamsPopulationsModel.addElement(p);
+ }
+ tabUI.listSimulParamsPopulations.setModel(listSimulParamsPopulationsModel);
+ if (listSimulParamsPopulationsModel.size() != 0) {
+ for (Population p : populationsSelected) {
+ int index = listSimulParamsPopulationsModel.indexOf(p);
+ tabUI.listSimulParamsPopulations.addSelectionInterval(index, index);
+ }
+ //getSimulAction().populationSelected(this);
+ }
+ }
+
+ protected void strategySelected(){
+ getSimulAction().setStrategies(tabUI.listSimulParamsStrategies.getSelectedValuesList());
+ }
+
+ protected ComboBoxModel<String> getSimulParamsSelectModel() {
+ return getSimulParamsSelectModel(false);
+ }
+
+ protected ComboBoxModel<String> getSimulParamsSelectModel(boolean force) {
+ List<String> items = getFilteredOldSimulatorNames(force);
+ GenericComboModel<String> result = new GenericComboModel<String>(items);
+ return result;
+ }
+
+ protected void resetFilter(){
+ resetOldSimulatorNames();
+ tabUI.fieldSimulParamsSelect.setModel(getSimulParamsSelectModel(false));
+ }
+
+ /**
+ * Return old simulations.
+ *
+ * @return old simulations
+ */
+ public List<String> getOldSimulationItem() {
+
+ //try {
+ oldSimulNames = new ArrayList<String>();
+
+ //FilterModel<SimulationProperties, String> filterModel;
+ // keep in context list of old simulation names (for filter process)
+ oldSimulNames.addAll(SimulationStorage.getSimulationNames());
+ // create filter model
+ //filterModel = SimulationFilterUtil.createFilterModel(oldSimulNames);
+ // to used directly model.getFilteredResult() in xml
+ // we must fill filterModel result with original items
+ //filterModel.selectAll();
+
+ // chatellier : Ajout d'une entrée vide pour forcer la sélection
+ // et que le changement lance un evenement sur la liste
+ // Add empty item after, otherwise, un " " directory
+ // will be created
+ oldSimulNames.add(0, " ");
+
+ return oldSimulNames;
+ /*} catch (ParseException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get old simulation item", e);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listoldsimulation"), e);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get old simulation item", e);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listoldsimulation"), e);
+ }
+ return null;*/
+ }
+
+ public List<String> getFilteredOldSimulatorNames(boolean force) {
+ if (oldSimulNames == null || force) {
+ oldSimulNames = getOldSimulationItem();
+ }
+ return oldSimulNames;
+ }
+
+ public void setOldSimulatorNames(List<String> sn) {
+ oldSimulNames = sn;
+ }
+
+ public void resetOldSimulatorNames() {
+ oldSimulNames = getOldSimulationItem();
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,296 +23,24 @@
#L%
-->
<Table>
+ <ParamsHandler id="handler" constructorParams="this" />
+
<fr.ifremer.isisfish.datastore.RegionStorage id="regionStorage" javaBean="null" />
<!-- ui state when editing -->
<Boolean id='sensitivity' javaBean='false' />
<import>
- static org.nuiton.i18n.I18n.t
- java.text.ParseException;
- fr.ifremer.isisfish.datastore.RegionStorage
- fr.ifremer.isisfish.datastore.StorageChangeEvent
- fr.ifremer.isisfish.datastore.StorageChangeListener
- fr.ifremer.isisfish.datastore.StorageException
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.Strategy
- fr.ifremer.isisfish.entities.FisheryRegion
- fr.ifremer.isisfish.ui.SimulationUI
- fr.ifremer.isisfish.ui.WelcomePanelUI
- fr.ifremer.isisfish.ui.WelcomeTabUI
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.sensitivity.SensitivityUI
- fr.ifremer.isisfish.ui.widget.FilterableComboBox
- fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher
- fr.ifremer.isisfish.simulator.launcher.SimulationService
- fr.ifremer.isisfish.simulator.launcher.SimulationJob
- fr.ifremer.isisfish.simulator.launcher.SimulationServiceListener
- org.nuiton.topia.TopiaException
- org.nuiton.topia.TopiaContext
- javax.swing.SwingUtilities
- javax.swing.DefaultComboBoxModel
- java.awt.CardLayout
- java.awt.Cursor
java.awt.Dimension
- java.io.IOException
- javax.swing.DefaultListModel
- javax.swing.ComboBoxModel
+ javax.swing.DefaultComboBoxModel
</import>
- <script><![CDATA[
-// instances variables déclaration
-SimulationServiceListener simulationListener;
-StorageChangeListener regionStorageListener;
-SimulAction simulAction = getContextValue(SimulAction.class);
-regionStorageListener = new StorageChangeListener() {
- @Override
- public void versionDataChanged(StorageChangeEvent e) {
- GenericComboModel<String> model = new GenericComboModel<String>(fr.ifremer.isisfish.datastore.RegionStorage.getRegionNames());
- fieldSimulParamsRegion.setModel(model);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
}
-};
-RegionStorage.addStorageChangeListener(regionStorageListener);
+ ]]></script>
-simulationListener = new SimulationServiceListener() {
- @Override
- public void simulationStart(SimulationService simService, SimulationJob job) {
-
- }
-
- @Override
- public void simulationStop(SimulationService simService, final SimulationJob job) {
- final GenericComboModel<String> model = (GenericComboModel<String>)fieldSimulParamsSelect.getModel();
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- model.addElement(job.getId());
- }
- });
- }
-
- @Override
- public void clearJobDone(SimulationService simService) {
-
- }
-}
-SimulationService.getService().addSimulationServiceListener(simulationListener);
-
-// la gestion des regles est maintenant independante de SimulAction
-// il faut faire la lié aux parametres de simulations
-simulAction.getSimulationParameter().setRules(ruleChooser.getRulesList());
-
-public void refresh() {
- if (simulAction.getSimulationStorage() != null) {
- fieldSimulParamsName.setText(simulAction.getSimulationStorage().getName());
- }
- fieldSimulParamsDesc.setText(simulAction.getSimulationParameter().getDescription());
- setListSimulParamsStrategiesItems();
- setListSimulParamsPopulationsItems();
-}
-
-/**
- * Called on user region selection change.
- */
-protected void regionChange() {
- // le premier item est " " pour ne pas avoir de selection par defaut
- final String selected = fieldSimulParamsRegion.getSelectedItem().toString();
- if (log.isDebugEnabled()) {
- log.debug(" selected " + selected);
- }
- if(selected != null && !selected.trim().isEmpty()) {
- getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.loading.region"));
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- simulAction.regionChange(ParamsUI.this, selected);
- // FIXME fix this
- if (!isSensitivity()) {
- getParentContainer(SimulUI.class).refresh();
- } else {
- getParentContainer(SensitivityUI.class).refresh();
- }
- setSensitivityTabRegion();
- getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.region.loaded"));
- }
- });
- }
-}
-
-protected void initSimulationParams() {
- if (!isSensitivity()){
- // prescript
- String preScript = simulAction.getSimulationParameter().getPreScript();
- fieldUseSimulPreScripts.setSelected(preScript != null && !preScript.isEmpty());
- getParentContainer(SimulUI.class).getPreScriptUI().getFieldSimulPreScript().setText(preScript);
-
- // simulation plan
- fieldSimulUseSimulationPlan.setSelected(simulAction.getSimulationParameter().getUseSimulationPlan());
- getParentContainer(SimulUI.class).getSensUI().refresh();
-
- // optimization
- fieldSimulUseOptimization.setSelected(simulAction.getSimulationParameter().getUseOptimization());
- getParentContainer(SimulUI.class).getOptimizationUI().refresh();
-
- }
-}
-
-protected void setSensitivityTabRegion() {
- if (isSensitivity()) {
- try {
- // FIXME this transaction in never closed
- // and can't be closed because used in
- TopiaContext tx = simulAction.getRegionStorage().getStorage().beginTransaction();
- FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx);
- getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFisheryRegion(fisheryRegion);
- getParentContainer(SensitivityUI.class).getSensitivityTabUI().setTreeModel();
- } catch (StorageException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't reload factors", ex);
- }
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't reload factors", ex);
- }
- }
- }
-}
-protected void initSensitivityParams() {
- if (isSensitivity()) {
- getParentContainer(SensitivityUI.class).getSensitivityChooserUI().refreshSelectedSensitivityAnalysis();
- getParentContainer(SensitivityUI.class).getSensitivityTabUI().setFactorModel();
- getParentContainer(SensitivityUI.class).getSensitivityChooserUI().setSensitivityExportListModel();
- sensitivityOnlyKeepFirstResultCheckBox.setSelected(simulAction.getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst());
- }
-}
-
-public void setSimulationParameter(SimulAction simulAction){
- simulAction.setSimulationParameter(simulAction.getSimulationParameter());
-}
-
-protected void loadOldSimulation() {
- final String selected = fieldSimulParamsSelect.getSelectedItem().toString();
- // le premier item est " " pour ne pas avoir de selection par defaut
- if (selected != null && !selected.equals(" ")) {
- getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.loading.old.simulation"));
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
-
- simulAction.loadOldSimulation(selected);
- fieldSimulParamsRegion.setSelectedItem(getContextValue(SimulAction.class).getSimulationParameter().getRegionName());
-
- // FIXME fix this
- if (!isSensitivity()) {
- getParentContainer(SimulUI.class).refresh();
- } else {
- getParentContainer(SensitivityUI.class).refresh();
- }
-
- // mise a jour des années
- fieldSimulParamsNbMois.setText(String.valueOf(simulAction.getNumberOfMonths()));
- initSimulationParams();
- initSensitivityParams();
-
- // regles
- ruleChooser.setRulesList(simulAction.getSimulationParameter().getRules());
-
- getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.old.simulation.loaded"));
- setCursor(Cursor.getDefaultCursor());
- }
- });
- }
-}
-
-/**
- * Lance la simulation.
- */
-protected void launchSimulation() {
-
- if (!isSensitivity()) {
- simulAction.launchSimulation(fieldSimulParamsName.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem());
- }
- else {
- simulAction.launchSimulationWithSensibility(fieldSimulParamsName.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem());
- }
-
- // dans le cas d'une fenetre independante, il n'y a pas de ParentContainer
- WelcomeTabUI parent = getParentContainer(WelcomeTabUI.class);
- if (parent != null) {
- parent.setQueueTabSelection();
- }
-}
-protected void enablePreScript() {
- simulAction.getSimulationParameter().setUsePreScript(fieldUseSimulPreScripts.isSelected());
- SimulationUI simulationUI = getParentContainer(SimulationUI.class);
- simulationUI.setEnabledPrescriptTab(fieldUseSimulPreScripts.isSelected());
-}
-protected void enableSimulationPlan() {
- simulAction.getSimulationParameter().setUseSimulationPlan(fieldSimulUseSimulationPlan.isSelected());
- SimulationUI simulationUI = getParentContainer(SimulationUI.class);
- simulationUI.setEnabledSimulationPlanTab(fieldSimulUseSimulationPlan.isSelected());
-}
-
-protected void enableOptimization() {
- simulAction.getSimulationParameter().setUseOptimization(fieldSimulUseOptimization.isSelected());
- SimulationUI simulationUI = getParentContainer(SimulationUI.class);
- simulationUI.setEnabledOptimizationTab(fieldSimulUseOptimization.isSelected());
-}
-
-protected void setListSimulParamsStrategiesItems() {
- List<Strategy> strategiesSelected = simulAction.getSimulationParameter().getStrategies();
- DefaultListModel listSimulParamsStrategiesModel = new DefaultListModel();
- java.util.List<Strategy> strategies = simulAction.getStrategies();
- for (Strategy s : strategies){
- listSimulParamsStrategiesModel.addElement(s);
- }
- listSimulParamsStrategies.setModel(listSimulParamsStrategiesModel);
- if (listSimulParamsStrategiesModel.size() != 0) {
- for (Strategy s : strategiesSelected){
- int index = listSimulParamsStrategiesModel.indexOf(s);
- listSimulParamsStrategies.addSelectionInterval(index, index);
- }
- //strategySelected();
- }
-}
-protected void setListSimulParamsPopulationsItems(){
- List<Population> populationsSelected = simulAction.getSimulationParameter().getPopulations();
- DefaultListModel listSimulParamsPopulationsModel = new DefaultListModel();
- List<Population> populations = simulAction.getPopulations();
- for (Population p : populations){
- listSimulParamsPopulationsModel.addElement(p);
- }
- listSimulParamsPopulations.setModel(listSimulParamsPopulationsModel);
- if (listSimulParamsPopulationsModel.size() != 0) {
- for (Population p : populationsSelected) {
- int index = listSimulParamsPopulationsModel.indexOf(p);
- listSimulParamsPopulations.addSelectionInterval(index, index);
- }
- //simulAction.populationSelected(this);
- }
-}
-
-protected void strategySelected(){
- simulAction.setStrategies(listSimulParamsStrategies.getSelectedValuesList());
-}
-
-protected ComboBoxModel<String> getSimulParamsSelectModel() {
- return getSimulParamsSelectModel(false);
-}
-
-protected ComboBoxModel<String> getSimulParamsSelectModel(boolean force) {
- List<String> items = simulAction.getFilteredOldSimulatorNames(force);
- GenericComboModel<String> result = new GenericComboModel<String>(items);
- return result;
-}
-
-protected void resetFilter(){
- simulAction.resetOldSimulatorNames();
- fieldSimulParamsSelect.setModel(getSimulParamsSelectModel(false));
-}
- ]]>
- </script>
<row>
<cell fill="horizontal" weightx="1.0">
<Table>
@@ -321,10 +49,10 @@
<JLabel text="isisfish.params.loadOldSimulation" />
</cell>
<cell fill="horizontal" weightx="1.0">
- <FilterableComboBox id="fieldSimulParamsSelect"
+ <fr.ifremer.isisfish.ui.widget.FilterableComboBox id="fieldSimulParamsSelect"
genericType="String"
- model='{getSimulParamsSelectModel()}'
- onActionPerformed='loadOldSimulation()' />
+ model='{handler.getSimulParamsSelectModel()}'
+ onActionPerformed='handler.loadOldSimulation()' />
</cell>
</row>
</Table>
@@ -352,8 +80,8 @@
<JTextField id="fieldSimulParamsName" />
<javax.swing.text.Document
javaBean="fieldSimulParamsName.getDocument()"
- onInsertUpdate='simulAction.setName(fieldSimulParamsName.getText())'
- onRemoveUpdate='simulAction.setName(fieldSimulParamsName.getText())' />
+ onInsertUpdate='getContextValue(SimulAction.class).setName(fieldSimulParamsName.getText())'
+ onRemoveUpdate='getContextValue(SimulAction.class).setName(fieldSimulParamsName.getText())' />
</cell>
</row>
</Table>
@@ -368,7 +96,7 @@
<JComboBox id="fieldSimulParamsRegion" genericType="String"
model='{new fr.ifremer.isisfish.ui.models.common.GenericComboModel<String>(fr.ifremer.isisfish.datastore.RegionStorage.getRegionNames())}'
selectedItem='{getContextValue(SimulAction.class).getSimulationParameter().getRegionName()}'
- onActionPerformed='regionChange()' />
+ onActionPerformed='handler.regionChange()' />
</cell>
</row>
</Table>
@@ -384,11 +112,11 @@
weighty="0.3">
<JScrollPane>
<JTextArea id="fieldSimulParamsDesc"
- text='{simulAction.getSimulationParameter().getDescription()}' />
+ text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' />
<javax.swing.text.Document
javaBean="fieldSimulParamsDesc.getDocument()"
- onInsertUpdate='simulAction.getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())'
- onRemoveUpdate='simulAction.getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())' />
+ onInsertUpdate='getContextValue(SimulAction.class).getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())'
+ onRemoveUpdate='getContextValue(SimulAction.class).getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())' />
</JScrollPane>
</cell>
</row>
@@ -404,11 +132,11 @@
<cell fill="both" weightx="1.0">
<JTextField
id="fieldSimulParamsNbMois"
- text='{String.valueOf(simulAction.getSimulationParameter().getNumberOfMonths())}' />
+ text='{String.valueOf(getContextValue(SimulAction.class).getSimulationParameter().getNumberOfMonths())}' />
<javax.swing.text.Document
javaBean="fieldSimulParamsNbMois.getDocument()"
- onInsertUpdate='simulAction.setNumberOfMonths(fieldSimulParamsNbMois.getText())'
- onRemoveUpdate='simulAction.setNumberOfMonths(fieldSimulParamsNbMois.getText())' />
+ onInsertUpdate='getContextValue(SimulAction.class).setNumberOfMonths(fieldSimulParamsNbMois.getText())'
+ onRemoveUpdate='getContextValue(SimulAction.class).setNumberOfMonths(fieldSimulParamsNbMois.getText())' />
</cell>
</row>
</Table>
@@ -438,7 +166,7 @@
genericType="fr.ifremer.isisfish.entities.Strategy"
selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{new jaxx.runtime.swing.OneClicListSelectionModel(listSimulParamsStrategies.getSelectionModel(), listSimulParamsStrategies.getModel())}"
- onValueChanged='strategySelected()'
+ onValueChanged='handler.strategySelected()'
enabled="{getRegionStorage() != null}" />
</JScrollPane>
</cell>
@@ -449,7 +177,7 @@
genericType="fr.ifremer.isisfish.entities.Population"
selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{new jaxx.runtime.swing.OneClicListSelectionModel(listSimulParamsPopulations.getSelectionModel(), listSimulParamsPopulations.getModel())}"
- onValueChanged='simulAction.populationSelected(this)'
+ onValueChanged='getContextValue(SimulAction.class).populationSelected(this)'
enabled="{getRegionStorage() != null}" />
</JScrollPane>
</cell>
@@ -457,7 +185,7 @@
<row>
<cell fill="both" weighty="1" columns="2">
<JPanel id="populationEffectivesPanel"
- layout="{new CardLayout()}">
+ layout="{new java.awt.CardLayout()}">
<JLabel text="isisfish.params.nopopulation"
horizontalAlignment="center"
border="{BorderFactory.createEtchedBorder()}"
@@ -483,7 +211,7 @@
<cell anchor="north">
<JButton id="addRuleFactorButton"
icon='{SwingUtil.createImageIcon("building_add.png")}'
- onActionPerformed="simulAction.addFactorWithComponent(this, ruleChooser)"
+ onActionPerformed="getContextValue(SimulAction.class).addFactorWithComponent(this, ruleChooser)"
visible="{isSensitivity()}"
enabled="{getRegionStorage() != null}" />
</cell>
@@ -503,32 +231,32 @@
<cell fill="horizontal" weightx="1">
<JCheckBox text="isisfish.params.usePreSimulationScript"
id="fieldUseSimulPreScripts"
- selected='{simulAction.getSimulationParameter().getUsePreScript()}'
+ selected='{getContextValue(SimulAction.class).getSimulationParameter().getUsePreScript()}'
visible='{!isSensitivity()}'
- onItemStateChanged='enablePreScript()' />
+ onItemStateChanged='handler.enablePreScript()' />
</cell>
<cell fill="horizontal" weightx="1">
<JCheckBox text="isisfish.params.useSimulationPlan"
id="fieldSimulUseSimulationPlan"
- selected='{simulAction.getSimulationParameter().getUseSimulationPlan()}'
+ selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseSimulationPlan()}'
visible='{!isSensitivity()}'
- onItemStateChanged='enableSimulationPlan()'
+ onItemStateChanged='handler.enableSimulationPlan()'
enabled="{getRegionStorage() != null}" />
</cell>
<cell fill="horizontal" weightx="1">
<JCheckBox text="isisfish.params.useOptimization"
id="fieldSimulUseOptimization"
- selected='{simulAction.getSimulationParameter().getUseOptimization()}'
+ selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseOptimization()}'
visible='{!isSensitivity()}'
- onItemStateChanged='enableOptimization()'
+ onItemStateChanged='handler.enableOptimization()'
enabled="{getRegionStorage() != null}" />
</cell>
<cell fill="horizontal" weightx="1">
<JCheckBox text="isisfish.params.sensitivityOnlyKeepFirstResult"
id="sensitivityOnlyKeepFirstResultCheckBox"
- selected='{simulAction.getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst()}'
+ selected='{getContextValue(SimulAction.class).getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst()}'
visible='{isSensitivity()}'
- onItemStateChanged='simulAction.getSimulationParameter().setSensitivityAnalysisOnlyKeepFirst(sensitivityOnlyKeepFirstResultCheckBox.isSelected())'
+ onItemStateChanged='getContextValue(SimulAction.class).getSimulationParameter().setSensitivityAnalysisOnlyKeepFirst(sensitivityOnlyKeepFirstResultCheckBox.isSelected())'
enabled="{getRegionStorage() != null}" />
</cell>
</row>
@@ -545,12 +273,12 @@
<cell fill="horizontal" weightx="0.4">
<JComboBox id="comboSelLauncher"
genericType="fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher"
- model='{new DefaultComboBoxModel(simulAction.getSimulationLauncher().toArray())}' />
+ model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulationLauncher().toArray())}' />
</cell>
<cell fill="horizontal" weightx="0.4">
<JButton id="buttonSimulParamsSimulate"
text="isisfish.common.simulate"
- onActionPerformed='launchSimulation()'
+ onActionPerformed='handler.launchSimulation()'
enabled="{getRegionStorage() != null}" />
</cell>
<cell fill="horizontal" weightx="0.2">
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,144 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import java.util.List;
+
+import javax.swing.table.DefaultTableModel;
+
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
+import fr.ifremer.isisfish.datastore.StorageChangeEvent;
+import fr.ifremer.isisfish.datastore.StorageChangeListener;
+import fr.ifremer.isisfish.simulator.SimulationPlan;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer;
+import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel;
+
+/**
+ * Plan UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class PlanHandler extends SimulationTabHandler {
+
+ protected PlanUI tabUI;
+
+ protected StorageChangeListener simulationPlanStorageListener;
+
+ protected PlanHandler(PlanUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+ simulationPlanStorageListener = new StorageChangeListener() {
+ @Override
+ public void versionDataChanged(StorageChangeEvent e) {
+ refresh();
+ }
+ };
+ SimulationPlanStorage.addStorageChangeListener(simulationPlanStorageListener);
+
+ // model init
+ tabUI.fieldSimulParamsSimulationPlansSelect.setModel(getSimulationPlansComboModel());
+ tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
+ }
+
+ public void refresh() {
+ // simulation plans names list
+ tabUI.fieldSimulParamsSimulationPlansSelect.setModel(getSimulationPlansComboModel());
+ // simulation simulation plans instance
+ tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
+ }
+
+ /**
+ * Refresh simulation plan names list.
+ */
+ protected GenericComboModel<String> getSimulationPlansComboModel() {
+ List<String> simulationPlanNames = tabUI.simulAction.getSimulationPlanNames();
+ GenericComboModel<String> model = new GenericComboModel<>(simulationPlanNames);
+ return model;
+ }
+
+ /**
+ * Refresh simulation simulation plan list.
+ */
+ protected GenericListModel<SimulationPlan> getSimulationSimulationPlansListModel() {
+ List<SimulationPlan> simulationPlans = tabUI.simulAction.getParamSimulationPlans();
+ GenericListModel<SimulationPlan> model = new GenericListModel<>(simulationPlans);
+ return model;
+ }
+
+ protected void addSimulationPlan() {
+ String selectedSimulationPlanName = (String)tabUI.fieldSimulParamsSimulationPlansSelect.getSelectedItem();
+ tabUI.simulAction.addSimulationPlan(tabUI, selectedSimulationPlanName);
+ tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
+ setSimulationPlanButtons();
+ }
+
+ protected void removeSimulationPlan() {
+ SimulationPlan selectedSimulationPlan = (SimulationPlan)tabUI.listSimulParamsSimulationPlansList.getSelectedValue();
+ tabUI.simulAction.removeSimulationPlan(selectedSimulationPlan);
+ tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
+ setSimulationPlanButtons();
+ }
+
+ protected void clearSimulationPlan() {
+ tabUI.simulAction.clearSimulationPlans();
+ tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
+ setSimulationPlanButtons();
+ }
+
+ protected void setSimulationPlanButtons() {
+ if (tabUI.getContextValue(SimulAction.class).getParamSimulationPlans().isEmpty()) {
+ tabUI.buttonSimulParamsSimulationPlansClear.setEnabled(false);
+ tabUI.buttonSimulParamsSimulationPlansRemove.setEnabled(false);
+ } else {
+ if (tabUI.listSimulParamsSimulationPlansList.getSelectedIndex() != -1) {
+ tabUI.buttonSimulParamsSimulationPlansRemove.setEnabled(true);
+ } else {
+ tabUI.buttonSimulParamsSimulationPlansRemove.setEnabled(false);
+ }
+ tabUI.buttonSimulParamsSimulationPlansClear.setEnabled(true);
+ }
+ setSimulParamsSimulationPlans();
+ }
+
+ protected void setSimulParamsSimulationPlans() {
+ SimulationPlan selectedSimulationPlan = (SimulationPlan)tabUI.listSimulParamsSimulationPlansList.getSelectedValue();
+ if (selectedSimulationPlan != null) {
+ ScriptParametersTableModel model = new ScriptParametersTableModel(selectedSimulationPlan);
+ tabUI.simulParamsSimulationPlans.setModel(model);
+ ScriptParametersTableCellEditor cellEditor = new ScriptParametersTableCellEditor(selectedSimulationPlan);
+ cellEditor.setRegionStorage(tabUI.getContextValue(RegionStorage.class));
+ tabUI.simulParamsSimulationPlans.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(selectedSimulationPlan));
+ tabUI.simulParamsSimulationPlans.getColumnModel().getColumn(1).setCellEditor(cellEditor);
+ } else {
+ // clear table
+ tabUI.simulParamsSimulationPlans.setModel(new DefaultTableModel());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,92 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
+ %%
+ 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%
+ -->
+<Table>
+ <PlanHandler id="handler" constructorParams="this" />
+
+ <import>
+ java.awt.Dimension
+ </import>
+
+ <SimulAction id='simulAction' javaBean='getContextValue(SimulAction.class)' />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
+ ]]></script>
+
+ <row>
+ <cell columns="2" fill="horizontal" weightx="1.0">
+ <JComboBox id="fieldSimulParamsSimulationPlansSelect"
+ genericType="String"
+ renderer='{new fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanComboRenderer()}' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="0.5">
+ <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
+ <JList id="listSimulParamsSimulationPlansList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
+ genericType="fr.ifremer.isisfish.simulator.SimulationPlan"
+ onValueChanged='handler.setSimulationPlanButtons()'
+ cellRenderer='{new fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanListRenderer()}'/>
+ </JScrollPane>
+ </cell>
+ <cell fill="both" weightx="0.5">
+ <Table name="isisfish.sens.title">
+ <row>
+ <cell fill="both" weightx="1.0">
+ <JButton id="buttonSimulParamsSimulationPlansAdd" text="isisfish.common.add"
+ onActionPerformed='handler.addSimulationPlan()'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1.0">
+ <JButton id="buttonSimulParamsSimulationPlansRemove" text="isisfish.common.remove"
+ onActionPerformed='handler.removeSimulationPlan()' enabled='false'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1.0">
+ <JButton id="buttonSimulParamsSimulationPlansClear" text="isisfish.common.clear"
+ onActionPerformed='handler.clearSimulationPlan()' enabled='false'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2" fill="both" weightx="1.0" weighty="1.0">
+ <JScrollPane>
+ <JTable id="simulParamsSimulationPlans" rowHeight='24' name="isisfish.sens.planParameters"/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2" fill="horizontal" weightx="1.0">
+ <JButton text="isisfish.sens.backParameter" onActionPerformed='getParentContainer(fr.ifremer.isisfish.ui.SimulationUI.class).selectParametersTab()'/>
+ </cell>
+ </row>
+</Table>
+
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,50 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+/**
+ * Prescript UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class PreScriptsHandler extends SimulationTabHandler {
+
+ protected PreScriptsUI tabUI;
+
+ protected PreScriptsHandler(PreScriptsUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+
+ }
+
+ protected void save() {
+ tabUI.getContextValue(SimulAction.class).getSimulationParameter().setPreScript(tabUI.fieldSimulPreScript.getText());
+ }
+
+ public void refresh() {
+
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,28 +23,20 @@
#L%
-->
<JPanel layout='{new BorderLayout()}'>
- <script><![CDATA[
- public PreScriptsUI(SimulAction action) {
- setContextValue(action);
- }
- protected void save() {
- getContextValue(SimulAction.class).getSimulationParameter().setPreScript(fieldSimulPreScript.getText());
- }
+ <PreScriptsHandler id="handler" constructorParams="this" />
- protected void refresh() {
-
- }
-
- /*protected void backParameter() {
- SimulUI simul = getParentContainer(SimulUI.class);
- simul.selTab(0);
- }*/
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.afterInit();
+ }
]]></script>
+
<org.fife.ui.rtextarea.RTextScrollPane constraints='BorderLayout.CENTER'>
- <org.fife.ui.rsyntaxtextarea.RSyntaxTextArea id="fieldSimulPreScript" onFocusLost='save()'
+ <org.fife.ui.rsyntaxtextarea.RSyntaxTextArea id="fieldSimulPreScript" onFocusLost='handler.save()'
syntaxEditingStyle="{org.fife.ui.rsyntaxtextarea.SyntaxConstants.SYNTAX_STYLE_JAVA}" />
</org.fife.ui.rtextarea.RTextScrollPane>
+
<JButton constraints='BorderLayout.SOUTH' text="isisfish.preScript.backParameter"
onActionPerformed='getParentContainer(fr.ifremer.isisfish.ui.SimulationUI.class).selectParametersTab()'/>
</JPanel>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,89 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.util.List;
+
+import javax.swing.event.ListSelectionEvent;
+
+import fr.ifremer.isisfish.ui.WelcomePanelUI;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Result choice UI handler.
+ *
+ * @author Eric Chatellier
+ */
+public class ResultChoiceHandler extends SimulationTabHandler {
+
+ protected ResultChoiceUI tabUI;
+
+ public ResultChoiceHandler(ResultChoiceUI tabUI) {
+ super(tabUI);
+ this.tabUI = tabUI;
+ }
+
+ protected void afterInit() {
+ refresh();
+ }
+
+ public void refresh() {
+
+ // FIXME listen for result name modification
+
+ setListSimulResultChooseModel();
+ }
+
+ protected void setListSimulResultChooseModel() {
+
+ List<String> availableResults = getSimulAction().getResultNames();
+ List<String> userResults = getSimulAction().getDefaultResultNames();
+ // userResults = intersection(userResults,availableResult)
+ userResults.retainAll(availableResults);
+
+ GenericListModel<String> resultModel = new GenericListModel<>(availableResults);
+ tabUI.listResultNames.setModel(resultModel);
+
+ for (String userResult : userResults) {
+ int index = availableResults.indexOf(userResult);
+ tabUI.listResultNames.addSelectionInterval(index, index);
+ }
+ }
+
+ protected void saveParametersResultNames(ListSelectionEvent event) {
+ tabUI.getContextValue(SimulAction.class).saveParametersResultNames(tabUI.listResultNames.getSelectedValuesList());
+ }
+
+ protected void saveConfigResultNames() {
+ tabUI.getContextValue(SimulAction.class).saveConfigurationResultNames(tabUI.listResultNames.getSelectedValuesList());
+ setStatusMessage(t("isisfish.resultChoice.saved"));
+ }
+
+ protected void setStatusMessage(String txt) {
+ // TODO remove getParentContainer use
+ WelcomePanelUI root = tabUI.getParentContainer(WelcomePanelUI.class);
+ root.setStatusMessage(txt);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,69 +23,22 @@
#L%
-->
<JPanel layout='{new BorderLayout()}'>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.ui.WelcomePanelUI
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- javax.swing.event.ListSelectionEvent
- </import>
- <script><![CDATA[
-
+ <ResultChoiceHandler id="handler" constructorParams="this" />
+
+ <script><![CDATA[
protected void $afterCompleteSetup() {
- refresh();
+ handler.afterInit();
}
+ ]]></script>
- public void refresh() {
-
- // FIXME listen for result name modification
-
- setListSimulResultChooseModel();
- }
-
- protected SimulAction getSimulAction() {
- return getContextValue(SimulAction.class);
- }
-
- protected void setListSimulResultChooseModel() {
-
- List<String> availableResults = getSimulAction().getResultNames();
- List<String> userResults = getSimulAction().getDefaultResultNames();
- // userResults = intersection(userResults,availableResult)
- userResults.retainAll(availableResults);
-
- GenericListModel<String> resultModel = new GenericListModel<>(availableResults);
- listResultNames.setModel(resultModel);
-
- for (String userResult : userResults) {
- int index = availableResults.indexOf(userResult);
- listResultNames.addSelectionInterval(index, index);
- }
- }
-
- protected void saveParametersResultNames(ListSelectionEvent event) {
- getContextValue(SimulAction.class).saveParametersResultNames(listResultNames.getSelectedValuesList());
- }
-
- protected void saveConfigResultNames() {
- getContextValue(SimulAction.class).saveConfigurationResultNames(listResultNames.getSelectedValuesList());
- setStatusMessage(t("isisfish.resultChoice.saved"));
- }
-
- protected void setStatusMessage(String txt) {
- // TODO remove getParentContainer use
- WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
- root.setStatusMessage(txt);
- }
- ]]>
- </script>
<JLabel text="isisfish.resultChoice.save" horizontalAlignment="center" constraints='BorderLayout.NORTH'/>
<JScrollPane constraints='BorderLayout.CENTER'>
<JList id="listResultNames" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
genericType="String"
cellRenderer='{new fr.ifremer.isisfish.ui.models.result.ResultListRenderer()}'
- onValueChanged='saveParametersResultNames(event)' />
+ onValueChanged='handler.saveParametersResultNames(event)' />
</JScrollPane>
- <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation" onActionPerformed='saveConfigResultNames()'/>
+ <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation" onActionPerformed='handler.saveConfigResultNames()'/>
</JPanel>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooser.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooser.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooser.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -25,6 +25,8 @@
@param : Region storage (context)
-->
<Table>
+ <RuleChooserHandler id="handler" constructorParams="this" />
+
<!-- Rules collection managed by current ui instance. -->
<java.util.List genericType='fr.ifremer.isisfish.rule.Rule' id="rulesList" javaBean='new java.util.ArrayList<fr.ifremer.isisfish.rule.Rule>()'/>
@@ -33,35 +35,9 @@
<Boolean id="showFactorColumn" javaBean="false" />
- <RuleChooserHandler id="handler" />
-
- <import>
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.List
- fr.ifremer.isisfish.rule.Rule
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel
- </import>
-
<script><![CDATA[
protected void $afterCompleteSetup() {
- // Manage rule list change
- addPropertyChangeListener(PROPERTY_RULES_LIST, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- selectedRulesListModel.setElementList(new ArrayList<Rule>());
- } else {
- List<Rule> rules = (List<Rule>)evt.getNewValue();
- selectedRulesListModel.setElementList(rules);
- }
- }
- });
-
- // fix colums size for buttons
- if (isShowFactorColumn()) {
- SwingUtil.fixTableColumnWidth(selectedRuleParameterTable, 2, 30);
- }
+ handler.afterInit();
}
]]></script>
@@ -88,7 +64,7 @@
</JScrollPane>
</cell>
<cell fill='horizontal'>
- <JButton id="addRulesButton" text="isisfish.common.add" enabled="false" onActionPerformed='handler.addSelectedRules(this)'/>
+ <JButton id="addRulesButton" text="isisfish.common.add" enabled="false" onActionPerformed='handler.addSelectedRules()'/>
</cell>
<cell fill="both" rows="3" weightx="1" weighty="1">
<JScrollPane enabled="{isActive()}">
@@ -96,20 +72,20 @@
<JList id="selectedRulesList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
genericType="fr.ifremer.isisfish.rule.Rule" model='{selectedRulesListModel}'
cellRenderer='{new fr.ifremer.isisfish.ui.models.rule.RuleListCellRenderer()}'
- onValueChanged='removeRuleButton.setEnabled(selectedRulesList.getSelectedIndex() != -1);clearRulesButton.setEnabled(selectedRulesList.getSelectedIndex() != -1);handler.displayRuleParameters(this)' />
+ onValueChanged='removeRuleButton.setEnabled(selectedRulesList.getSelectedIndex() != -1);clearRulesButton.setEnabled(selectedRulesList.getSelectedIndex() != -1);handler.displayRuleParameters()' />
</JScrollPane>
</cell>
</row>
<row>
<cell fill='horizontal'>
<JButton id="removeRuleButton" text="isisfish.common.remove"
- enabled="false" onActionPerformed='handler.removeSelectedRules(this)'/>
+ enabled="false" onActionPerformed='handler.removeSelectedRules()'/>
</cell>
</row>
<row>
<cell fill='horizontal' anchor="north">
<JButton id="clearRulesButton" text="isisfish.common.clear"
- enabled="false" onActionPerformed='handler.clearAllRules(this)'/>
+ enabled="false" onActionPerformed='handler.clearAllRules()'/>
</cell>
</row>
<row weightx="2" weighty="2" columns="3">
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -23,6 +23,9 @@
package fr.ifremer.isisfish.ui.simulator;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.List;
import fr.ifremer.isisfish.IsisFishException;
@@ -36,6 +39,7 @@
import fr.ifremer.isisfish.ui.models.rule.RuleParametersFactorTableCellEditor;
import fr.ifremer.isisfish.ui.models.rule.RuleParametersFactorTableCellRenderer;
import fr.ifremer.isisfish.ui.widget.editor.ScriptParameterDialog;
+import jaxx.runtime.SwingUtil;
/**
* Handler for {@link RuleChooser class}.
@@ -48,12 +52,36 @@
*/
public class RuleChooserHandler {
+ protected RuleChooser ruleChooser;
+
+ public RuleChooserHandler(RuleChooser ruleChooser) {
+ this.ruleChooser = ruleChooser;
+ }
+
+ protected void afterInit() {
+
+ // Manage rule list change
+ ruleChooser.addPropertyChangeListener(RuleChooser.PROPERTY_RULES_LIST, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ ruleChooser.selectedRulesListModel.setElementList(new ArrayList<Rule>());
+ } else {
+ List<Rule> rules = (List<Rule>)evt.getNewValue();
+ ruleChooser.selectedRulesListModel.setElementList(rules);
+ }
+ }
+ });
+
+ // fix colums size for buttons
+ if (ruleChooser.isShowFactorColumn()) {
+ SwingUtil.fixTableColumnWidth(ruleChooser.selectedRuleParameterTable, 2, 30);
+ }
+ }
+
/**
* Get new instance for selected rules names and add it to {@code rulesList} list.
- *
- * @param ruleChooser rule chooser ui
*/
- protected void addSelectedRules(RuleChooser ruleChooser) {
+ protected void addSelectedRules() {
List<String> availableRuleValues = ruleChooser.getAvailableRuleList().getSelectedValuesList();
for (String availableRuleName : availableRuleValues) {
try {
@@ -74,10 +102,8 @@
/**
* Remove selected rules for selected rules list.
- *
- * @param ruleChooser rule chooser ui
*/
- protected void removeSelectedRules(RuleChooser ruleChooser) {
+ protected void removeSelectedRules() {
SimulAction simulAction = ruleChooser.getContextValue(SimulAction.class);
List<Rule> selectedRuleValues = ruleChooser.getSelectedRulesList().getSelectedValuesList();
for (Rule selectedRuleValue : selectedRuleValues) {
@@ -99,10 +125,8 @@
/**
* Clear selected rule list.
- *
- * @param ruleChooser rule chooser ui
*/
- protected void clearAllRules(RuleChooser ruleChooser) {
+ protected void clearAllRules() {
// condition pour savoir si on est dans l'instance principal
// de définition d'une simulation (hack)
if (ruleChooser.isShowFactorColumn()) {
@@ -120,10 +144,8 @@
/**
* Display parameters table form single selected list.
- *
- * @param ruleChooser rule chooser ui
*/
- protected void displayRuleParameters(RuleChooser ruleChooser) {
+ protected void displayRuleParameters() {
Rule selectedRule = (Rule)ruleChooser.getSelectedRulesList().getSelectedValue();
if (selectedRule != null) {
ruleChooser.getSelectedRuleParameterTableModel().setScript(selectedRule);
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -1,187 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
- %%
- 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%
- -->
-<Table>
- <import>
- java.awt.Dimension
- javax.swing.table.DefaultTableModel
- fr.ifremer.isisfish.datastore.SimulationPlanStorage
- fr.ifremer.isisfish.datastore.StorageChangeEvent
- fr.ifremer.isisfish.datastore.StorageChangeListener
- fr.ifremer.isisfish.simulator.SimulationPlan
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanComboRenderer
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanListRenderer
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer
- fr.ifremer.isisfish.datastore.RegionStorage
- </import>
- <SimulAction id='simulAction' javaBean='getContextValue(SimulAction.class)' />
-
- <script><![CDATA[
-
- // to be notified of storage change event
- StorageChangeListener simulationPlanStorageListener;
-
- protected void $afterCompleteSetup() {
- simulationPlanStorageListener = new StorageChangeListener() {
- @Override
- public void versionDataChanged(StorageChangeEvent e) {
- refresh();
- }
- };
- SimulationPlanStorage.addStorageChangeListener(simulationPlanStorageListener);
- }
-
- public void refresh() {
- // simulation plans names list
- fieldSimulParamsSimulationPlansSelect.setModel(getSimulationPlansComboModel());
- // simulation simulation plans instance
- listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
- }
-
- /**
- * Refresh simulation plan names list.
- */
- protected GenericComboModel<String> getSimulationPlansComboModel() {
- List<String> simulationPlanNames = simulAction.getSimulationPlanNames();
- GenericComboModel<String> model = new GenericComboModel<>(simulationPlanNames);
- return model;
- }
-
- /**
- * Refresh simulation simulation plan list.
- */
- protected GenericListModel<SimulationPlan> getSimulationSimulationPlansListModel() {
- List<SimulationPlan> simulationPlans = simulAction.getParamSimulationPlans();
- GenericListModel<SimulationPlan> model = new GenericListModel<>(simulationPlans);
- return model;
- }
-
- protected void addSimulationPlan() {
- String selectedSimulationPlanName = (String)fieldSimulParamsSimulationPlansSelect.getSelectedItem();
- simulAction.addSimulationPlan(this, selectedSimulationPlanName);
- listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
- setSimulationPlanButtons();
- }
-
- protected void removeSimulationPlan() {
- SimulationPlan selectedSimulationPlan = (SimulationPlan)listSimulParamsSimulationPlansList.getSelectedValue();
- simulAction.removeSimulationPlan(selectedSimulationPlan);
- listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
- setSimulationPlanButtons();
- }
-
- protected void clearSimulationPlan() {
- simulAction.clearSimulationPlans();
- listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel());
- setSimulationPlanButtons();
- }
-
- protected void setSimulationPlanButtons() {
- if (getContextValue(SimulAction.class).getParamSimulationPlans().isEmpty()) {
- buttonSimulParamsSimulationPlansClear.setEnabled(false);
- buttonSimulParamsSimulationPlansRemove.setEnabled(false);
- } else {
- if (listSimulParamsSimulationPlansList.getSelectedIndex() != -1) {
- buttonSimulParamsSimulationPlansRemove.setEnabled(true);
- } else {
- buttonSimulParamsSimulationPlansRemove.setEnabled(false);
- }
- buttonSimulParamsSimulationPlansClear.setEnabled(true);
- }
- setSimulParamsSimulationPlans();
- }
-
- protected void setSimulParamsSimulationPlans() {
- SimulationPlan selectedSimulationPlan = (SimulationPlan)listSimulParamsSimulationPlansList.getSelectedValue();
- if (selectedSimulationPlan != null) {
- ScriptParametersTableModel model = new ScriptParametersTableModel(selectedSimulationPlan);
- simulParamsSimulationPlans.setModel(model);
- ScriptParametersTableCellEditor cellEditor = new ScriptParametersTableCellEditor(selectedSimulationPlan);
- cellEditor.setRegionStorage(getContextValue(RegionStorage.class));
- simulParamsSimulationPlans.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(selectedSimulationPlan));
- simulParamsSimulationPlans.getColumnModel().getColumn(1).setCellEditor(cellEditor);
- } else {
- // clear table
- simulParamsSimulationPlans.setModel(new DefaultTableModel());
- }
- }
- ]]>
- </script>
- <row>
- <cell columns="2" fill="horizontal" weightx="1.0">
- <JComboBox id="fieldSimulParamsSimulationPlansSelect" model='{getSimulationPlansComboModel()}'
- genericType="String"
- renderer='{new SimulationPlanComboRenderer()}' />
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="0.5">
- <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="listSimulParamsSimulationPlansList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
- genericType="fr.ifremer.isisfish.simulator.SimulationPlan"
- onValueChanged='setSimulationPlanButtons()' model='{getSimulationSimulationPlansListModel()}'
- cellRenderer='{new SimulationPlanListRenderer()}'/>
- </JScrollPane>
- </cell>
- <cell fill="both" weightx="0.5">
- <Table name="isisfish.sens.title">
- <row>
- <cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsSimulationPlansAdd" text="isisfish.common.add"
- onActionPerformed='addSimulationPlan()'/>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsSimulationPlansRemove" text="isisfish.common.remove"
- onActionPerformed='removeSimulationPlan()' enabled='false'/>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsSimulationPlansClear" text="isisfish.common.clear"
- onActionPerformed='clearSimulationPlan()' enabled='false'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row>
- <cell columns="2" fill="both" weightx="1.0" weighty="1.0">
- <JScrollPane>
- <JTable id="simulParamsSimulationPlans" rowHeight='24' name="isisfish.sens.planParameters"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell columns="2" fill="horizontal" weightx="1.0">
- <JButton text="isisfish.sens.backParameter" onActionPerformed='getParentContainer(fr.ifremer.isisfish.ui.SimulationUI.class).selectParametersTab()'/>
- </cell>
- </row>
-</Table>
-
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -135,7 +135,6 @@
protected RegionStorage regionStorage = null;
protected SimulationStorage simulStorage = null;
- protected List<String> oldSimulNames = null;
protected String simulName = null;
/**
@@ -504,61 +503,6 @@
return SimulatorStorage.getSimulatorNames();
}
- /**
- * Return old simulations.
- *
- * @return old simulations
- */
- public List<String> getOldSimulationItem() {
-
- //try {
- oldSimulNames = new ArrayList<String>();
-
- //FilterModel<SimulationProperties, String> filterModel;
- // keep in context list of old simulation names (for filter process)
- oldSimulNames.addAll(SimulationStorage.getSimulationNames());
- // create filter model
- //filterModel = SimulationFilterUtil.createFilterModel(oldSimulNames);
- // to used directly model.getFilteredResult() in xml
- // we must fill filterModel result with original items
- //filterModel.selectAll();
-
- // chatellier : Ajout d'une entrée vide pour forcer la sélection
- // et que le changement lance un evenement sur la liste
- // Add empty item after, otherwise, un " " directory
- // will be created
- oldSimulNames.add(0, " ");
-
- return oldSimulNames;
- /*} catch (ParseException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't get old simulation item", e);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listoldsimulation"), e);
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't get old simulation item", e);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listoldsimulation"), e);
- }
- return null;*/
- }
-
- public List<String> getFilteredOldSimulatorNames(boolean force) {
- if (oldSimulNames == null || force) {
- oldSimulNames = getOldSimulationItem();
- }
- return oldSimulNames;
- }
-
- public void setOldSimulatorNames(List<String> sn) {
- oldSimulNames = sn;
- }
-
- public void resetOldSimulatorNames() {
- oldSimulNames = getOldSimulationItem();
- }
-
/*
************
* AdvancedParameterUI
@@ -651,12 +595,12 @@
return param.getSimulationPlans();
}
- public void addSimulationPlan(SensUI sensUI, String name) {
+ public void addSimulationPlan(PlanUI planUI, String name) {
try {
SimulationPlan sp = SimulationPlanStorage.getSimulationPlan(name).getNewInstance();
// add it after autoconfiguration (if enabled)
- sp = (SimulationPlan)ScriptParameterDialog.displayConfigurationFrame(sensUI, sp);
+ sp = (SimulationPlan)ScriptParameterDialog.displayConfigurationFrame(planUI, sp);
if (sp != null) {
getSimulationParameter().addSimulationPlan(sp);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2015-05-21 13:11:05 UTC (rev 4231)
@@ -27,14 +27,14 @@
<script><![CDATA[
@Override
public void refresh() {
- paramsUI.refresh();
- preScriptUI.refresh();
- sensUI.refresh();
- optimizationUI.refresh();
- exportUI.refresh();
- resultChoiceUI.refresh();
- advancedParamsUI.refresh();
- optimizationUI.refresh();
+ paramsUI.getHandler().refresh();
+ preScriptUI.getHandler().refresh();
+ planUI.getHandler().refresh();
+ optimizationUI.getHandler().refresh();
+ exportUI.getHandler().refresh();
+ resultChoiceUI.getHandler().refresh();
+ advancedParamsUI.getHandler().refresh();
+ optimizationUI.getHandler().refresh();
}
/**
@@ -42,7 +42,7 @@
*/
@Override
protected void regionStorageChanged() {
- optimizationUI.regionStorageChanged();
+ //optimizationUI.getHandler().regionStorageChanged();
}
@Override
@@ -82,7 +82,7 @@
<PreScriptsUI id="preScriptUI" constructorParams='this' />
</tab>
<tab title='isisfish.sens.title' enabled='false'>
- <SensUI id="sensUI" constructorParams='this' />
+ <PlanUI id="planUI" constructorParams='this' />
</tab>
<tab title='isisfish.optimization.title' enabled='false'>
<OptimizationUI id="optimizationUI" constructorParams='this' />
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,44 @@
+package fr.ifremer.isisfish.ui.simulator;
+
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
+import fr.ifremer.isisfish.ui.CommonHandler;
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Handler common à tous les handler de chaque onglet de l'interface de simulation.
+ *
+ * @author Eric Chatellier
+ */
+public abstract class SimulationTabHandler extends CommonHandler {
+
+ // TODO might be something else, like SimulatorTabUI ?
+ protected JAXXContext simulationUI;
+
+ protected SimulationTabHandler(JAXXContext simulationUI) {
+ this.simulationUI = simulationUI;
+ }
+
+ /**
+ * Return simulation parameters from context.
+ *
+ * @return SimulationParameter
+ */
+ protected SimulationParameter getParameters() {
+ return simulationUI.getContextValue(SimulationParameter.class);
+ }
+
+ /**
+ * Return FactorGroup from context.
+ *
+ * @return FactorGroup
+ */
+ protected FactorGroup getFactorGroup() {
+ return simulationUI.getContextValue(FactorGroup.class);
+ }
+
+ @Deprecated
+ protected SimulAction getSimulAction() {
+ return simulationUI.getContextValue(SimulAction.class);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulationTabHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java 2015-05-21 13:11:05 UTC (rev 4231)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.simulator;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+
+/**
+ * Ce contexte regroupe les élements qui servent à une hierachie d'interfaces Simulator.
+ *
+ * @author Eric Chatellier
+ */
+public class SimulatorContext extends JAXXInitialContext {
+
+ public SimulatorContext(JAXXContext parent) {
+ setParentContext(parent);
+
+ // FIXME remove this
+ add(new SimulAction());
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r4230 - in trunk/src/main/java/fr/ifremer/isisfish/ui: . input input/equation input/fisheryregion input/gear input/metier input/observation input/population input/setofvessels sensitivity sensitivity/wizard simulator
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 13:37:54 +0000 (Wed, 20 May 2015)
New Revision: 4230
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4230
Log:
Remove InputAction and move related code to handlers
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -53,7 +53,6 @@
import fr.ifremer.isisfish.ui.config.RConfigHandler;
import fr.ifremer.isisfish.ui.config.RConfigUI;
import fr.ifremer.isisfish.ui.config.SSHLauncherConfigUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
import fr.ifremer.isisfish.ui.input.InputUI;
import fr.ifremer.isisfish.ui.queue.QueueUI;
@@ -153,7 +152,7 @@
* @param welcomeUI
*/
public void newInputFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new InputUI(new JAXXInitialContext().add(verifier).add(new InputAction()).add(new InputSaveVerifier()).add(this)), t("isisfish.input.title"));
+ openFrame(welcomeUI, new InputUI(new JAXXInitialContext().add(verifier).add(new InputSaveVerifier()).add(this)), t("isisfish.input.title"));
}
/**
@@ -169,7 +168,7 @@
* @param welcomeUI
*/
public void newSensitivityFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new SensitivityUI(new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add(new SimulAction()).add(this)), t("isisfish.sensitivity.title"));
+ openFrame(welcomeUI, new SensitivityUI(new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(this)), t("isisfish.sensitivity.title"));
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -26,7 +26,6 @@
<import>
fr.ifremer.isisfish.ui.simulator.SimulAction
jaxx.runtime.context.JAXXInitialContext
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.input.InputSaveVerifier
fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
fr.ifremer.isisfish.ui.sensitivity.SensitivityInputHandler
@@ -48,7 +47,7 @@
<JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}' constraints="BorderLayout.CENTER">
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'>
<fr.ifremer.isisfish.ui.input.InputUI id='inputUI'
- constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputAction()).add(new InputSaveVerifier())' />
+ constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputSaveVerifier())' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'>
<fr.ifremer.isisfish.ui.simulator.SimulUI id='simulUI'
@@ -56,7 +55,7 @@
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/sensitivities.gif"))}'>
<fr.ifremer.isisfish.ui.sensitivity.SensitivityUI id="sensitivityUI"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add(new SimulAction()).add(new SensitivityInputHandler()).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(new SensitivityInputHandler()).add(this)' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/calc.gif"))}'>
<fr.ifremer.isisfish.ui.result.ResultUI />
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -1,1011 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2005 - 2014 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin, Chatellier Eric
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.input;
-
-import static org.nuiton.i18n.I18n.t;
-
-import java.awt.geom.Point2D;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.util.FileUtil;
-import org.nuiton.widget.SwingUtil;
-import org.nuiton.widget.editor.Editor;
-
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.datastore.FormuleStorage;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.entities.Cell;
-import fr.ifremer.isisfish.entities.CellDAO;
-import fr.ifremer.isisfish.entities.EffortDescription;
-import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
-import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.entities.Formule;
-import fr.ifremer.isisfish.entities.Gear;
-import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.entities.MetierSeasonInfo;
-import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
-import fr.ifremer.isisfish.entities.Observation;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationDAO;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
-import fr.ifremer.isisfish.entities.Selectivity;
-import fr.ifremer.isisfish.entities.SelectivityDAO;
-import fr.ifremer.isisfish.entities.SetOfVessels;
-import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.entities.TargetSpecies;
-import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
-import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.check.CheckRegion;
-import fr.ifremer.isisfish.ui.input.check.CheckResult;
-import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
-import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
-import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
-import fr.ifremer.isisfish.ui.util.ErrorHelper;
-import fr.ifremer.isisfish.util.CellPointcomparator;
-
-/**
- * All code used in input UI.
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- *
- * @deprecated since 4.4.0.0, move code to dedicated handlers
- */
-@Deprecated
-public class InputAction {
-
- /** Class logger. */
- private static Log log = LogFactory.getLog(InputAction.class);
-
- /*
- * Permet de creer simplement un nouvelle objet portant un nom par defaut.
- * Le nouvel element est automatiquement selectionné dans l'arbre
- *
- * @param type le type de l'entite a creer, le type est compose seulement du
- * nom de l'entite et pas du package.
- * @return null ou un fenetre d'erreur
- *
- public TopiaEntity create(TopiaContext isisContext, String type) {
- if (log.isTraceEnabled()) {
- log.trace("create called for " + type);
- }
- try {
- //TODO use the IsisFishEntityEnum for this purpose :
- //TopiaDAO<TopiaEntity> dao = IsisFishEntityEnum.getEntry(type).getDAO(isisContext);
- String name = type + "_new";
-
- Method method = MethodUtils.getAccessibleMethod(
- IsisFishDAOHelper.class, "get" + type + "DAO",
- TopiaContext.class);
- TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) method.invoke(
- null, isisContext);
-
- TopiaEntity entity = dao.create("name", name);
- entity.update();
- isisContext.commitTransaction();
- return entity;
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create entity", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.new"), eee);
- }
- return null;
- }*/
-
- /*
- * Save entity passed in argument, and commit
- *
- * @param selected entity to save
- * @return the saved entity
- *
- public TopiaEntity save(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("save called");
- }
- try {
- if (selected == null) {
- if (log.isWarnEnabled()) {
- log.warn("Try to save null entity");
- }
- return null;
- }
- // on est pas en autoUpdate donc il faut faire le update avant le
- // commit
- selected.update();
-
- selected.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't save region", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.save"), eee);
- }
- return selected;
- }*/
-
- /*
- * Cancel all modification on entity (rollback), and force reload it and
- * refresh all ui component that name match 'type'Tab
- *
- * @return the roolbacked entity
- *
- public TopiaEntity cancel(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("cancel called");
- }
- try {
- TopiaContext isisContext = selected.getTopiaContext();
- isisContext.rollbackTransaction();
-
- // reload the object
- // can't be null here, or allready null before !!!
- //if (selected != null) {
- // FIXME don't modify parameters
- selected = isisContext.findByTopiaId(selected.getTopiaId());
- //}
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't cancel modification in region", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.cancel"), eee);
- }
- return selected;
- }*/
-
- /*
- * Delete one entity and commit the change, try to selected intelligently
- * other node in tree.
- * <p/>
- * Refresh all ui component where name match "input<entity type without
- * package >.*"
- *
- * @return if ok return null else OutView error
- *
- public String remove(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("remove called");
- }
- String msg = "";
- try {
- boolean doDelete;
- List<TopiaEntity> allWillBeRemoved = selected.getComposite();
- if (allWillBeRemoved.size() > 0) {
- String text = t("isisfish.message.delete.object", selected
- .toString());
- for (TopiaEntity e : allWillBeRemoved) {
- text += ClassUtils.getShortClassName(e.getClass()) + " - "
- + e.toString() + "\n";
- }
- int resp = JOptionPane.showConfirmDialog(null, text,
- t("isisfish.message.delete.entities"),
- JOptionPane.YES_NO_OPTION);
- doDelete = resp == JOptionPane.YES_OPTION;
- } else {
- String text = t("isisfish.message.confirm.delete.object",
- selected.toString());
- int resp = JOptionPane.showConfirmDialog(null, text,
- t("isisfish.message.delete.entity"),
- JOptionPane.YES_NO_OPTION);
- doDelete = resp == JOptionPane.YES_OPTION;
- }
-
- if (doDelete) {
- selected.delete();
- selected.getTopiaContext().commitTransaction();
- msg = t("isisfish.message.remove.finished");
- } else {
- msg = t("isisfish.message.remove.canceled");
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove entity: " + selected, eee);
- }
- showMsgBox(eee);
- }
- return msg;
- }*/
-
- /*
- * Save an Equation as model, to reuse it for other equation
- *
- * @param eq equation to put in models
- * @return if ok return null else OutputView error message
- *
- public Object saveEquationAsModel(Equation eq) {
- try {
- if (eq != null) {
- String name = showInputDialog("");
- //if ("".equals(name)) {
- // showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
- //}
- if (name != null) {
- FormuleStorage storage = FormuleStorage.createFormule(eq
- .getCategory(), name, eq.getLanguage());
- storage.setContent(eq.getContent());
- }
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't save equation as model", eee);
- }
- showMsgBox(eee);
- }
- return null;
- }*/
-
- /**
- * Save an Equation as model, to reuse it for other equation
- *
- * @param category category for this equation
- * @param language equation to put in models
- * @param content content ?
- * @return if ok return null else OutputView error message
- */
- public Object saveAsModel(String category, String language, String content) {
- try {
- String name = JOptionPane
- .showInputDialog(t("isisfish.message.saveModel.dialog"));
- /*if ("".equals(name)) {
- showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
- }*/
- if (name != null) {
- FormuleStorage storage = FormuleStorage.createFormule(category,
- name, language);
- storage.setContent(content);
- }
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't save equation as model", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.equation.savemodel"),
- eee);
- }
- return null;
- }
-
- public Object openEditor(InputOneEquationUI ui, String category, String name, Class<?> javaInterface,
- String content, Editor editor) {
- if (log.isTraceEnabled()) {
- log.trace("openEditor");
- }
- try {
- EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
- pane.getHandler().setEquation(category, name, javaInterface, content);
- pane.setLocationRelativeTo(ui);
- pane.setVisible(true); // blocking call
- if (pane.isResultOk() && editor != null) {
- editor.setText(pane.getEditor().getText());
- }
- pane.dispose();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't open editor", eee);
- }
- ErrorHelper.showErrorDialog(
- t("isisfish.error.equation.openeditor"), eee);
- }
- return null;
- }
-
- public List<Formule> getFormules(TopiaContext isisContext, String name) {
- return FormuleStorage.getFormules(isisContext, name);
- }
-
- // InputGear
-
- public Object addSelectivity(Population pop, String equation, Gear gear) {
- try {
-
- SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(pop
- .getTopiaContext());
- Selectivity selectivity = dao.create();
-
- selectivity.setGear(gear);
- selectivity.setPopulation(pop);
- selectivity.getEquation().setContent(equation);
- selectivity.update();
-
- gear.addPopulationSelectivity(selectivity);
- gear.update();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add selectivity", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Selectivity"), eee);
- }
- return null;
- }
-
- public Object removeSelectivity(Gear gear, Selectivity selectivity) {
- if (log.isTraceEnabled()) {
- log.trace("removeSelectivity called: " + selectivity);
- }
- try {
- if (gear != null && selectivity != null) {
- gear.removePopulationSelectivity(selectivity);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "Selectivity"), eee);
- }
- return null;
- }
-
- // InputMetier
-
- /*public Object createSeasonInfo(Metier metier) {
- if (log.isTraceEnabled()) {
- log.trace("createSeasonInfo called");
- }
- try {
- MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
- .getMetierSeasonInfoDAO(metier.getTopiaContext());
- MetierSeasonInfo metierSeasonInfo = metierSeasonInfoPS.create();
- metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
- metierSeasonInfo.setLastMonth(Month.MONTH[3]);
- metier.addMetierSeasonInfo(metierSeasonInfo);
- metierSeasonInfo.update();
- metier.update();
- // isisContext.commitTransaction();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity", "SeasonInfo"), eee);
- }
- return null;
- }*/
-
- /*public Object removeSeasonInfo(Metier metier, MetierSeasonInfo info) {
- if (log.isTraceEnabled()) {
- log.trace("removeSeasonInfo called");
- }
- try {
- metier.removeMetierSeasonInfo(info);
- metier.update();
- metier.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity", "SeasonInfo"), eee);
- }
- return null;
- }*/
-
- public Object addTargetSpecies(Metier metier, MetierSeasonInfo m,
- Species species, String targetFactorEquationContent,
- boolean primaryCatch) {
- if (log.isDebugEnabled()) {
- log.debug("addTargetSpecies called: " + metier + " " + species
- + " " + primaryCatch + " " + targetFactorEquationContent);
- }
- try {
- // build targetFactorEquation name
- String targetFactorEquationName = metier.getName() + "-"
- + species.getName() + "(" + m.getFirstMonth() + "-"
- + m.getLastMonth() + ")";
-
- TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(metier
- .getTopiaContext());
- TargetSpecies targetSpecies = dao.create();
-
- targetSpecies.setSpecies(species);
- targetSpecies.getTargetFactorEquation().setName(
- targetFactorEquationName);
- targetSpecies.getTargetFactorEquation().setContent(
- targetFactorEquationContent);
- targetSpecies.setPrimaryCatch(primaryCatch);
- m.addSpeciesTargetSpecies(targetSpecies);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "TargetSpecies"), eee);
- }
- return null;
- }
-
- public Object removeTargetSpecies(MetierSeasonInfo m,
- TargetSpecies targetSpecies) {
- if (log.isDebugEnabled()) {
- log.debug("removeTargetSpecies called: " + targetSpecies);
- }
- try {
- if (targetSpecies != null) {
- m.removeSpeciesTargetSpecies(targetSpecies);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "TargetSpecies"), eee);
- }
- return null;
- }
-
- // SetOfVessels
-
- public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) {
- if (log.isDebugEnabled()) {
- log.debug("addEffortDescription called: " + setOfVessels
- + " metier: " + metier);
- }
- try {
- EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper
- .getEffortDescriptionDAO(metier.getTopiaContext());
- EffortDescription effortDescription = effortDescriptionPS.create();
- // EC20090715 : c'est la classe d'association
- // qui en étant sauvee, sauve les relations en base
- // il faut bien faire les set des deux cotes
- effortDescription.setSetOfVessels(setOfVessels);
- effortDescription.setPossibleMetiers(metier);
- effortDescription.update();
- setOfVessels.addPossibleMetiers(effortDescription);
- setOfVessels.update();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create EffortDescription", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "EffortDescription"), eee);
- }
- }
-
- public Object removeEffortDescription(SetOfVessels sov,
- EffortDescription effort) {
- if (log.isTraceEnabled()) {
- log.trace("removeEffortDescription called");
- }
- try {
- sov.removePossibleMetiers(effort);
- // EC-20091112 : commit() twice cause hibernate error:
- // Found two representations of same collection:
- //sov.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove entity: " + effort, eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "EffortDescription"), eee);
- }
- return null;
- }
-
- public Population createPopulation(TopiaContext context, Species species) {
- Population pop = null;
- if (log.isTraceEnabled()) {
- log.trace("createPopulation called");
- }
- try {
- String name = "Population_new";
-
- PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(context);
- pop = dao.create();
- pop.setName(name);
-
- species.addPopulation(pop);
- pop.setSpecies(species);
- species.update();
- pop.update();
- } catch (TopiaException eee) {
- throw new IsisFishRuntimeException(t("isisfish.error.input.addentity", "Population"), eee);
- }
- return pop;
- }
-
- public PopulationSeasonInfo createPopulationSeasonInfo(Population pop) {
- if (log.isDebugEnabled()) {
- log.debug("createSeasonInfo called");
- }
- PopulationSeasonInfo seasonInfo = null;
- try {
- PopulationSeasonInfoDAO dao = IsisFishDAOHelper
- .getPopulationSeasonInfoDAO(pop.getTopiaContext());
- seasonInfo = dao.create();
- seasonInfo.setFirstMonth(Month.MONTH[0]);
- seasonInfo.setLastMonth(Month.MONTH[3]);
- pop.addPopulationSeasonInfo(seasonInfo);
- seasonInfo.setPopulation(pop);
-
- // EC-20090710 ajout du code d'initailisation
- // d'un populationseasoninfo
- // il a du se perdre au changement d'interface
- // swiat>jaxx
- // moved to entity
- //MatrixND matrix = ((PopulationSeasonInfoImpl) seasonInfo)
- // .createNoSpacializedChangeGroupMatrix();
- //seasonInfo.setLengthChangeMatrix(matrix);
-
- seasonInfo.update();
- pop.update();
- // isisContext.commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create PopulationSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "PopulationSeasonInfo"), eee);
- }
- return seasonInfo;
- }
-
- public void removePopulationSeasonInfo(Population pop,
- PopulationSeasonInfo populationSeasonInfo) {
- if (log.isDebugEnabled()) {
- log.debug("removePopulationSeasonInfo called");
- }
- try {
- pop.removePopulationSeasonInfo(populationSeasonInfo);
- pop.update();
- //pop.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove PopulationSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "PopulationSeasonInfo"), eee);
- }
- }
-
- public MetierSeasonInfo createMetierSeasonInfo(Metier metier) {
- MetierSeasonInfo metierSeasonInfo = null;
- if (log.isDebugEnabled()) {
- log.debug("createMetierSeasonInfo called");
- }
- try {
- MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
- .getMetierSeasonInfoDAO(metier.getTopiaContext());
- metierSeasonInfo = metierSeasonInfoPS.create();
- metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
- metierSeasonInfo.setLastMonth(Month.MONTH[3]);
- metier.addMetierSeasonInfo(metierSeasonInfo);
- metierSeasonInfo.update();
- metier.update();
-
- } catch (TopiaException eee) {
- throw new IsisFishRuntimeException("Can't create MetierSeasonInfo", eee);
- }
- return metierSeasonInfo;
- }
-
- public void removeMetierSeasonInfo(Metier metier, MetierSeasonInfo info) {
- if (log.isDebugEnabled()) {
- log.debug("removeMetierSeasonInfo called");
- }
- try {
- metier.removeMetierSeasonInfo(info);
- metier.update();
-
- // EC-20091112 : commit() twice cause hibernate error:
- // Found two representations of same collection:
- //metier.getTopiaContext().commitTransaction();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "MetierSeasonInfo"), eee);
- }
- }
-
- public void createRecruitmentDistribution(Population pop) {
- if (log.isTraceEnabled()) {
- log.trace("createRecruitmentDistributionon called: " + pop);
- }
- try {
- String val = JOptionPane
- .showInputDialog(t("isisfish.message.recruitment.number.month"));
- int num = -1;
- if (val != null && !"".equals(val)) {
- try {
- num = Integer.parseInt(val);
- } catch (RuntimeException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse val: " + val, eee);
- }
- }
- }
-
- if (num > 0) {
- List<String> sem = new ArrayList<String>(num);
- for (int i = 0; i < num; i++) {
- sem.add(t("isisfish.common.month", i));
- }
- MatrixND newMat = MatrixFactory.getInstance().create(
- new List[] { sem });
-
- MatrixND mat = pop.getRecruitmentDistribution();
- if (mat != null) {
- newMat.paste(mat);
- }
- pop.setRecruitmentDistribution(newMat);
- pop.update();
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove RecruitmentDistribution", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "RecruitmentDistribution"), eee);
- }
- }
-
- public void createObservationValueMatrix(Observation observation) {
- try {
- String val = JOptionPane.showInputDialog(t("isisfish.message.observation.value.dimensions"));
-
- if (StringUtils.isNotBlank(val)) {
- String[] values = val.trim().split("(,|;|\\*|x|\\s)");
-
- List<Integer> dims = new ArrayList<Integer>();
- for (String value : values) {
- if (!value.isEmpty() && StringUtils.isNumeric(value)) {
- dims.add(Integer.valueOf(value));
- }
- }
-
- int[] dim = new int[dims.size()];
- for (int i = 0; i < dims.size(); i++) {
- dim[i] = dims.get(i).intValue();
- }
- MatrixND newMat = MatrixFactory.getInstance().create(dim);
-
- MatrixND mat = observation.getValue();
- if (mat != null) {
- newMat.paste(mat);
- }
- observation.setValue(newMat);
- observation.update();
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove RecruitmentDistribution", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "RecruitmentDistribution"), eee);
- }
- }
-
- // Migration
-
- public Object addMigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone departure, Zone arrival, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addMigration called");
- }
- try {
- MatrixND mat = info.getMigrationMatrix().copy();
- mat.setValue(group, departure, arrival, coeff);
- info.setMigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add migration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Migration"), eee);
- }
- return null;
- }
-
- public Object addEmigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone departure, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addEmigration called");
- }
- try {
- MatrixND mat = info.getEmigrationMatrix().copy();
- mat.setValue(group, departure, coeff);
- info.setEmigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add emigration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Emigration"), eee);
- }
- return null;
- }
-
- public Object addImmigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone arrival, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addImmigration called");
- }
- try {
- MatrixND mat = info.getImmigrationMatrix().copy();
- mat.setValue(group, arrival, coeff);
- info.setImmigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add immigration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Immigration"), eee);
- }
- return null;
- }
-
- /**
- * Add new map in region.
- *
- * Since isis-fsih 3.3.0.0, this method supports a multiple file format :
- * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1
- *
- * @param fisheryRegion fishery region
- */
- public void addMap(FisheryRegion fisheryRegion) {
- if (log.isTraceEnabled()) {
- log.trace("AddMap called");
- }
-
- // Openmap suported fileformat
- String[] fileFormats = {
- // ESRI (http://www.esri.com) Shapefiles
- ".*\\.shp", "ESRI Shapefiles (.shp)",
-
- // NIMA (http://www.nima.mil)
- ".*\\.dcw", "Digital Chart of the World (.dcw)",
- ".*\\.vpf", "Vector Product Format (.vpf)",
- ".*\\.vmap", "Vector Map (.vmap)",
- ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)",
- ".*\\.cib", "Controlled Image Base (.cib)",
- ".*\\.rpf", "Raster Product Format (.rpf)",
- // seams to be a special format with multiples files
- //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)",
-
- // MapInfo (http://www.mapinfo.com) files (.mif)
- ".*\\.mif", "MapInfo (.mif)",
-
- // ArcInfo (.e00) files.
- ".*\\.e00", "ArcInfo (.e00)"
- };
-
- File inputMap = FileUtil.getFile(fileFormats);
- try {
- if (inputMap != null) {
-
- // copy inputMapFormat to region map directory
- // since isis-fsih-3.3.0.0, we store maps with extension
- String filename = inputMap.getName();
-
- RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
- File destDir = regionStorage.getMapRepository();
-
- // copy map file
- File destMap = new File(destDir, filename);
- FileUtils.copyFile(inputMap, destMap);
-
- List<String> maps = fisheryRegion.getMapFileList();
- maps.add(filename);
- fisheryRegion.setMapFileList(maps);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't copy map file for : " + inputMap, eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.addmap"), eee);
- }
- }
-
- /**
- * Remove map in a region.
- *
- * @param fisheryRegion fishery region
- * @param selectedMaps la liste de map a retirer
- */
- public void removeMap(FisheryRegion fisheryRegion, List<String> selectedMaps) {
- if (log.isTraceEnabled()) {
- log.trace("removeMap called");
- }
-
- try {
- List<String> maps = fisheryRegion.getMapFileList();
-
- RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
- File mapDir = regionStorage.getMapRepository();
-
- for (String mapName : selectedMaps) {
- maps.remove(mapName);
- // remove on disk too, if possible
- File mapFile = new File(mapDir, mapName);
- mapFile.delete();
- if (log.isDebugEnabled()) {
- log.debug("Removing map file : " + mapFile);
- }
-
- // special case, for some format, an index is created
- if (mapName.endsWith(".shp")) {
- String indexName = mapName.replaceAll("\\.shp$", ".ssx");
- File indexFile = new File(mapDir, indexName);
- indexFile.delete();
- if (log.isDebugEnabled()) {
- log.debug("Removing index file : " + indexFile);
- }
- }
- }
-
- fisheryRegion.setMapFileList(maps);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove map", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.removemap"),
- eee);
- }
- }
-
- /*
- * Affiche une boite de dialogue demandant a l'utilisateur de rentrer
- * un nom de fichier, et met ce nom dans la textField.
- * Passe le saveButton en enabled pour marque que la region a ete modifié
- *
- * @param cellFile file of cells
- *
- public void loadCellFile(String cellFile) {
- if (log.isWarnEnabled()) {
- log.warn("loadCell called but not implemented");
- }
- // FIXME todo loadCellFile
- }*/
-
- public void saveFisheryRegion(FisheryRegion fisheryRegion) {
- if (log.isTraceEnabled()) {
- log.trace("save called");
- }
- try {
- TopiaContext isisContext = fisheryRegion.getTopiaContext();
-
- // frame.setInfoText(t("isisfish.message.checking.cell"));
- int latNumber = (int) Math
- .round((fisheryRegion.getMaxLatitude() - fisheryRegion
- .getMinLatitude())
- / fisheryRegion.getCellLengthLatitude());
- int lonNumber = (int) Math
- .round((fisheryRegion.getMaxLongitude() - fisheryRegion
- .getMinLongitude())
- / fisheryRegion.getCellLengthLongitude());
-
- // frame.setProgressMin(0);
- // frame.setProgressMax(latNumber * lonNumber);
- int progresscpt = 0;
-
- // il faut peut-etre creer ou supprimer des mailles
- CellPointcomparator cellPointcomparator = new CellPointcomparator();
- CellDAO cellPS = IsisFishDAOHelper.getCellDAO(isisContext);
- List<Cell> cells = cellPS.findAll();
- Collections.sort(cells, cellPointcomparator);
- Point2D.Float point = new Point2D.Float();
-
- for (float lati = fisheryRegion.getMinLatitude(); lati < fisheryRegion
- .getMaxLatitude(); lati += fisheryRegion
- .getCellLengthLatitude()) {
- lati = Math.round(lati * 1000f);
- lati = lati / 1000.0f;
- for (float longi = fisheryRegion.getMinLongitude(); longi < fisheryRegion
- .getMaxLongitude(); longi += fisheryRegion
- .getCellLengthLongitude()) {
- longi = Math.round(longi * 1000f) / 1000.0f;
- point.setLocation(lati, longi);
- int position = Collections.binarySearch(cells, point,
- cellPointcomparator);
- if (position >= 0) {
- // deja existant on l'enleve de la liste, et on ne cree rien
- cells.remove(position);
- } else {
- // n'existe pas on la cree
- Cell cell = cellPS.create();
- cell.setName("La" + lati + "Lo" + longi);
- cell.setLatitude(lati);
- cell.setLongitude(longi);
- cell.setLand(false);
- cell.update();
- }
- // frame.setProgressValue(++progresscpt);
- }
- }
-
- // on est pas en autoUpdate donc il faut faire le update avant le commit
- fisheryRegion.update();
-
- // toutes les mailles restantes dans la liste sont des mailles en trop
- // on les supprimes
-
- progresscpt = 0;
- for (Cell cell : cells) {
- // FIXME il faudrait aussi rechercher les objets dependants
- // des mailles que l'on va supprimer et demander confirmation
- // a l'utilisateur qu'il souhaite reellement supprimer tous
- // ces objets. Si ce n'est pas le cas, on sort tout de suite
- // avant le commit
- cellPS.delete(cell);
- }
- isisContext.commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("isisfish.error.region.save"), eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.save"), eee);
- }
- }
-
- public void checkFisheryRegion(FisheryRegion fisheryRegion) {
- try {
- if (log.isTraceEnabled()) {
- log.trace("check called: ");
- }
- CheckResult result = new CheckResult();
- CheckRegion.check(fisheryRegion, result);
- CheckResultFrame dialog = new CheckResultFrame();
- dialog.setCheckResult(result);
- SwingUtil.center(dialog);
- dialog.setVisible(true);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("isisfish.error.region.check"), eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.check"), eee);
- }
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -99,9 +99,6 @@
}
-public InputAction getAction() {
- return getContextValue(InputAction.class);
-}
public InputSaveVerifier getSaveVerifier() {
return getContextValue(InputSaveVerifier.class);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -33,6 +33,7 @@
import java.util.List;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -41,12 +42,14 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
import org.nuiton.util.FileUtil;
+import org.nuiton.widget.editor.Editor;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.entities.Formule;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Equation handler.
@@ -187,7 +190,7 @@
TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)inputContentUI.getBean()).getTopiaContext();
List<Formule> formules = null;
if (inputContentUI.formuleCategory != null) {
- formules = inputContentUI.getAction().getFormules(isisContext, inputContentUI.formuleCategory);
+ formules = FormuleStorage.getFormules(isisContext, inputContentUI.formuleCategory);
GenericComboModel<Formule> formulesModel = new GenericComboModel<>(formules);
inputContentUI.formuleComboBox.setModel(formulesModel);
// fix default selection
@@ -197,24 +200,76 @@
}
protected void saveModel() {
- inputContentUI.getContextValue(InputAction.class).saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
+ saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
setComboModel();
inputContentUI.setInfoText(t("isisfish.message.saveModel.finished"));
}
+
+ /**
+ * Save an Equation as model, to reuse it for other equation
+ *
+ * @param category category for this equation
+ * @param language equation to put in models
+ * @param content content ?
+ */
+ protected void saveAsModel(String category, String language, String content) {
+ try {
+ String name = JOptionPane
+ .showInputDialog(t("isisfish.message.saveModel.dialog"));
+ /*if ("".equals(name)) {
+ showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
+ }*/
+ if (name != null) {
+ FormuleStorage storage = FormuleStorage.createFormule(category,
+ name, language);
+ storage.setContent(content);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't save equation as model", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.equation.savemodel"),
+ eee);
+ }
+ }
+
/**
* Open external editor, with equation documentation.
*/
protected void openEditor() {
Formule e = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
if (e != null) {
- inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, e.getCategory(),
+ openEditor(inputContentUI, e.getCategory(),
e.getName(), inputContentUI.clazz, e.getContent(), inputContentUI.editor);
} else {
- inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, inputContentUI.formuleCategory,
+ openEditor(inputContentUI, inputContentUI.formuleCategory,
"new", inputContentUI.clazz, inputContentUI.editor.getText(), inputContentUI.editor);
}
}
+
+ public void openEditor(InputOneEquationUI ui, String category, String name, Class<?> javaInterface,
+ String content, Editor editor) {
+ if (log.isTraceEnabled()) {
+ log.trace("openEditor");
+ }
+ try {
+ EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
+ pane.getHandler().setEquation(category, name, javaInterface, content);
+ pane.setLocationRelativeTo(ui);
+ pane.setVisible(true); // blocking call
+ if (pane.isResultOk() && editor != null) {
+ editor.setText(pane.getEditor().getText());
+ }
+ pane.dispose();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't open editor", eee);
+ }
+ ErrorHelper.showErrorDialog(
+ t("isisfish.error.equation.openeditor"), eee);
+ }
+ }
protected void setEditorText() {
if (inputContentUI.getFormule() != null) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -26,19 +26,34 @@
import static org.nuiton.i18n.I18n.n;
import static org.nuiton.i18n.I18n.t;
+import java.awt.geom.Point2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
import java.util.List;
import javax.swing.DefaultListModel;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+import org.nuiton.widget.SwingUtil;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.entities.CellDAO;
import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
+import fr.ifremer.isisfish.ui.input.check.CheckRegion;
+import fr.ifremer.isisfish.ui.input.check.CheckResult;
+import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+import fr.ifremer.isisfish.util.CellPointcomparator;
/**
* FisheryRegion handler.
@@ -84,10 +99,6 @@
inputContentUI.setBean(region);
}
- protected InputAction getInputAction() {
- return inputContentUI.getContextValue(InputAction.class);
- }
-
protected void setFieldMapfilesModel(FisheryRegion region) {
DefaultListModel<String> model = new DefaultListModel<>();
List<String> mapList = region.getMapFileList();
@@ -102,23 +113,152 @@
}
protected void addMap() {
- getInputAction().addMap(inputContentUI.getBean());
+ addMap(inputContentUI.getBean());
setFieldMapfilesModel(inputContentUI.getBean());
}
protected void delMap() {
- getInputAction().removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValuesList());
+ removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValuesList());
setFieldMapfilesModel(inputContentUI.getBean());
}
+
+ /**
+ * Add new map in region.
+ *
+ * Since isis-fsih 3.3.0.0, this method supports a multiple file format :
+ * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1
+ *
+ * @param fisheryRegion fishery region
+ */
+ public void addMap(FisheryRegion fisheryRegion) {
+ if (log.isTraceEnabled()) {
+ log.trace("AddMap called");
+ }
+ // Openmap suported fileformat
+ String[] fileFormats = {
+ // ESRI (http://www.esri.com) Shapefiles
+ ".*\\.shp", "ESRI Shapefiles (.shp)",
+
+ // NIMA (http://www.nima.mil)
+ ".*\\.dcw", "Digital Chart of the World (.dcw)",
+ ".*\\.vpf", "Vector Product Format (.vpf)",
+ ".*\\.vmap", "Vector Map (.vmap)",
+ ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)",
+ ".*\\.cib", "Controlled Image Base (.cib)",
+ ".*\\.rpf", "Raster Product Format (.rpf)",
+ // seams to be a special format with multiples files
+ //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)",
+
+ // MapInfo (http://www.mapinfo.com) files (.mif)
+ ".*\\.mif", "MapInfo (.mif)",
+
+ // ArcInfo (.e00) files.
+ ".*\\.e00", "ArcInfo (.e00)"
+ };
+
+ File inputMap = FileUtil.getFile(fileFormats);
+ try {
+ if (inputMap != null) {
+
+ // copy inputMapFormat to region map directory
+ // since isis-fsih-3.3.0.0, we store maps with extension
+ String filename = inputMap.getName();
+
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
+ File destDir = regionStorage.getMapRepository();
+
+ // copy map file
+ File destMap = new File(destDir, filename);
+ FileUtils.copyFile(inputMap, destMap);
+
+ List<String> maps = fisheryRegion.getMapFileList();
+ maps.add(filename);
+ fisheryRegion.setMapFileList(maps);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't copy map file for : " + inputMap, eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.addmap"), eee);
+ }
+ }
+
+ /**
+ * Remove map in a region.
+ *
+ * @param fisheryRegion fishery region
+ * @param selectedMaps la liste de map a retirer
+ */
+ public void removeMap(FisheryRegion fisheryRegion, List<String> selectedMaps) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeMap called");
+ }
+
+ try {
+ List<String> maps = fisheryRegion.getMapFileList();
+
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
+ File mapDir = regionStorage.getMapRepository();
+
+ for (String mapName : selectedMaps) {
+ maps.remove(mapName);
+ // remove on disk too, if possible
+ File mapFile = new File(mapDir, mapName);
+ mapFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing map file : " + mapFile);
+ }
+
+ // special case, for some format, an index is created
+ if (mapName.endsWith(".shp")) {
+ String indexName = mapName.replaceAll("\\.shp$", ".ssx");
+ File indexFile = new File(mapDir, indexName);
+ indexFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing index file : " + indexFile);
+ }
+ }
+ }
+
+ fisheryRegion.setMapFileList(maps);
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove map", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.removemap"),
+ eee);
+ }
+ }
+
/*protected void cellFile() {
getInputAction().loadCellFile(fieldCellFile.getText());
}*/
protected void check() {
- inputContentUI.getContextValue(InputAction.class).checkFisheryRegion(inputContentUI.getBean());
+ checkFisheryRegion(inputContentUI.getBean());
inputContentUI.setInfoText(t("isisfish.message.check.finished"));
}
+
+ public void checkFisheryRegion(FisheryRegion fisheryRegion) {
+ try {
+ if (log.isTraceEnabled()) {
+ log.trace("check called: ");
+ }
+ CheckResult result = new CheckResult();
+ CheckRegion.check(fisheryRegion, result);
+ CheckResultFrame dialog = new CheckResultFrame();
+ dialog.setCheckResult(result);
+ SwingUtil.center(dialog);
+ dialog.setVisible(true);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("isisfish.error.region.check"), eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.check"), eee);
+ }
+ }
protected void save() {
inputContentUI.setInfoText(t("isisfish.message.checking.cell"));
@@ -128,7 +268,7 @@
inputContentUI.getSaveVerifier().reset();
// save generating cells
- getInputAction().saveFisheryRegion(inputContentUI.getBean());
+ saveFisheryRegion(inputContentUI.getBean());
// reload tree
InputUI inputUI = inputContentUI.getParentContainer(InputUI.class);
@@ -136,4 +276,84 @@
inputContentUI.setInfoText(t("isisfish.message.save.finished"));
}
+
+ public void saveFisheryRegion(FisheryRegion fisheryRegion) {
+ if (log.isTraceEnabled()) {
+ log.trace("save called");
+ }
+ try {
+ TopiaContext isisContext = fisheryRegion.getTopiaContext();
+
+ // frame.setInfoText(t("isisfish.message.checking.cell"));
+ int latNumber = (int) Math
+ .round((fisheryRegion.getMaxLatitude() - fisheryRegion
+ .getMinLatitude())
+ / fisheryRegion.getCellLengthLatitude());
+ int lonNumber = (int) Math
+ .round((fisheryRegion.getMaxLongitude() - fisheryRegion
+ .getMinLongitude())
+ / fisheryRegion.getCellLengthLongitude());
+
+ // frame.setProgressMin(0);
+ // frame.setProgressMax(latNumber * lonNumber);
+ int progresscpt = 0;
+
+ // il faut peut-etre creer ou supprimer des mailles
+ CellPointcomparator cellPointcomparator = new CellPointcomparator();
+ CellDAO cellPS = IsisFishDAOHelper.getCellDAO(isisContext);
+ List<Cell> cells = cellPS.findAll();
+ Collections.sort(cells, cellPointcomparator);
+ Point2D.Float point = new Point2D.Float();
+
+ for (float lati = fisheryRegion.getMinLatitude(); lati < fisheryRegion
+ .getMaxLatitude(); lati += fisheryRegion
+ .getCellLengthLatitude()) {
+ lati = Math.round(lati * 1000f);
+ lati = lati / 1000.0f;
+ for (float longi = fisheryRegion.getMinLongitude(); longi < fisheryRegion
+ .getMaxLongitude(); longi += fisheryRegion
+ .getCellLengthLongitude()) {
+ longi = Math.round(longi * 1000f) / 1000.0f;
+ point.setLocation(lati, longi);
+ int position = Collections.binarySearch(cells, point,
+ cellPointcomparator);
+ if (position >= 0) {
+ // deja existant on l'enleve de la liste, et on ne cree rien
+ cells.remove(position);
+ } else {
+ // n'existe pas on la cree
+ Cell cell = cellPS.create();
+ cell.setName("La" + lati + "Lo" + longi);
+ cell.setLatitude(lati);
+ cell.setLongitude(longi);
+ cell.setLand(false);
+ cell.update();
+ }
+ // frame.setProgressValue(++progresscpt);
+ }
+ }
+
+ // on est pas en autoUpdate donc il faut faire le update avant le commit
+ fisheryRegion.update();
+
+ // toutes les mailles restantes dans la liste sont des mailles en trop
+ // on les supprimes
+
+ progresscpt = 0;
+ for (Cell cell : cells) {
+ // FIXME il faudrait aussi rechercher les objets dependants
+ // des mailles que l'on va supprimer et demander confirmation
+ // a l'utilisateur qu'il souhaite reellement supprimer tous
+ // ces objets. Si ce n'est pas le cas, on sort tout de suite
+ // avant le commit
+ cellPS.delete(cell);
+ }
+ isisContext.commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("isisfish.error.region.save"), eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.save"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.gear;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
@@ -31,12 +33,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Gear;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.Selectivity;
+import fr.ifremer.isisfish.entities.SelectivityDAO;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
/**
@@ -108,7 +114,7 @@
}
protected void addSelectivity() {
- inputContentUI.getAction().addSelectivity(inputContentUI.getPopulation(),
+ addSelectivity(inputContentUI.getPopulation(),
inputContentUI.selectivityEquation.getEditor().getText(), inputContentUI.getBean());
setSelectivityTableModel();
}
@@ -116,12 +122,53 @@
protected void removeSelectivity() {
GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)inputContentUI.selectivityTable.getModel();
Selectivity selectedSelectivity = model.getSelectivities().get(inputContentUI.selectivityTable.getSelectedRow());
- inputContentUI.getAction().removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
+ removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
inputContentUI.getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
setSelectivityTableModel();
inputContentUI.removeSelectivityButton.setEnabled(false);
}
+
+ protected void addSelectivity(Population pop, String equation, Gear gear) {
+ try {
+ SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(pop
+ .getTopiaContext());
+ Selectivity selectivity = dao.create();
+
+ selectivity.setGear(gear);
+ selectivity.setPopulation(pop);
+ selectivity.getEquation().setContent(equation);
+ selectivity.update();
+
+ gear.addPopulationSelectivity(selectivity);
+ gear.update();
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add selectivity", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Selectivity"), eee);
+ }
+ }
+
+ protected void removeSelectivity(Gear gear, Selectivity selectivity) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeSelectivity called: " + selectivity);
+ }
+ try {
+ if (gear != null && selectivity != null) {
+ gear.removePopulationSelectivity(selectivity);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "Selectivity"), eee);
+ }
+ }
+
protected GenericComboModel<Population> getSelectivityPopulationModel() {
List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
List<Population> populations = new ArrayList<>();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,18 +23,26 @@
package fr.ifremer.isisfish.ui.input.metier;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.entities.TargetSpecies;
-import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
/**
@@ -42,6 +50,9 @@
*/
public class MetierSeasonInfoSpeciesHandler extends InputContentHandler<MetierSeasonInfoSpeciesUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(MetierSeasonInfoSpeciesHandler.class);
+
protected void init(final MetierSeasonInfoSpeciesUI inputContentUI) {
super.init(inputContentUI);
@@ -118,7 +129,7 @@
if (selectedSpecies != null) {
// il n'y en a pas a la creation de la base
//Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
- inputContentUI.getContextValue(InputAction.class).addTargetSpecies(
+ addTargetSpecies(
inputContentUI.getBean(),
inputContentUI.getMetierSeasonInfo(),
selectedSpecies,
@@ -135,9 +146,60 @@
Object o = targetSpecies[inputContentUI.tableTargetSpecies.getSelectedRow()];
if (o != null) {
TargetSpecies ts = (TargetSpecies)o;
- inputContentUI.getAction().removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
+ removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
inputContentUI.getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
setTableTargetSpeciesModel();
}
}
+
+ public void addTargetSpecies(Metier metier, MetierSeasonInfo m,
+ Species species, String targetFactorEquationContent,
+ boolean primaryCatch) {
+ if (log.isDebugEnabled()) {
+ log.debug("addTargetSpecies called: " + metier + " " + species
+ + " " + primaryCatch + " " + targetFactorEquationContent);
+ }
+ try {
+ // build targetFactorEquation name
+ String targetFactorEquationName = metier.getName() + "-"
+ + species.getName() + "(" + m.getFirstMonth() + "-"
+ + m.getLastMonth() + ")";
+
+ TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(metier
+ .getTopiaContext());
+ TargetSpecies targetSpecies = dao.create();
+
+ targetSpecies.setSpecies(species);
+ targetSpecies.getTargetFactorEquation().setName(
+ targetFactorEquationName);
+ targetSpecies.getTargetFactorEquation().setContent(
+ targetFactorEquationContent);
+ targetSpecies.setPrimaryCatch(primaryCatch);
+ m.addSpeciesTargetSpecies(targetSpecies);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "TargetSpecies"), eee);
+ }
+ }
+
+ public void removeTargetSpecies(MetierSeasonInfo m,
+ TargetSpecies targetSpecies) {
+ if (log.isDebugEnabled()) {
+ log.debug("removeTargetSpecies called: " + targetSpecies);
+ }
+ try {
+ if (targetSpecies != null) {
+ m.removeSpeciesTargetSpecies(targetSpecies);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "TargetSpecies"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.metier;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
@@ -32,14 +34,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.Interval;
/**
@@ -96,17 +103,59 @@
}
protected void create() {
- MetierSeasonInfo newMSI = inputContentUI.getContextValue(InputAction.class).createMetierSeasonInfo(inputContentUI.getBean());
+ MetierSeasonInfo newMSI = createMetierSeasonInfo(inputContentUI.getBean());
inputContentUI.setMetierSeasonInfo(newMSI);
setMetierSeasonInfoCombo();
}
protected void delete() {
- inputContentUI.getContextValue(InputAction.class).removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
+ removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
inputContentUI.setMetierSeasonInfo(null);
setMetierSeasonInfoCombo();
}
+ public MetierSeasonInfo createMetierSeasonInfo(Metier metier) {
+ MetierSeasonInfo metierSeasonInfo = null;
+ if (log.isDebugEnabled()) {
+ log.debug("createMetierSeasonInfo called");
+ }
+ try {
+ MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
+ .getMetierSeasonInfoDAO(metier.getTopiaContext());
+ metierSeasonInfo = metierSeasonInfoPS.create();
+ metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
+ metierSeasonInfo.setLastMonth(Month.MONTH[3]);
+ metier.addMetierSeasonInfo(metierSeasonInfo);
+ metierSeasonInfo.update();
+ metier.update();
+
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException("Can't create MetierSeasonInfo", eee);
+ }
+ return metierSeasonInfo;
+ }
+
+ public void removeMetierSeasonInfo(Metier metier, MetierSeasonInfo info) {
+ if (log.isDebugEnabled()) {
+ log.debug("removeMetierSeasonInfo called");
+ }
+ try {
+ metier.removeMetierSeasonInfo(info);
+ metier.update();
+
+ // EC-20091112 : commit() twice cause hibernate error:
+ // Found two representations of same collection:
+ //metier.getTopiaContext().commitTransaction();
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove MetierSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "MetierSeasonInfo"), eee);
+ }
+ }
+
public void refresh() {
inputContentUI.setMetierSeasonInfo(null);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,19 +23,35 @@
package fr.ifremer.isisfish.ui.input.observation;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.entities.Observation;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoSpeciesHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Observation handler.
*/
public class ObservationHandler extends InputContentHandler<ObservationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ObservationHandler.class);
+
protected void init(final ObservationUI inputContentUI) {
super.init(inputContentUI);
@@ -61,10 +77,46 @@
}
protected void createObservationValueMatrix() {
- inputContentUI.getAction().createObservationValueMatrix(inputContentUI.getBean());
+ createObservationValueMatrix(inputContentUI.getBean());
setObservationValueMatrix();
}
+
+ public void createObservationValueMatrix(Observation observation) {
+ try {
+ String val = JOptionPane.showInputDialog(t("isisfish.message.observation.value.dimensions"));
+ if (StringUtils.isNotBlank(val)) {
+ String[] values = val.trim().split("(,|;|\\*|x|\\s)");
+
+ List<Integer> dims = new ArrayList<Integer>();
+ for (String value : values) {
+ if (!value.isEmpty() && StringUtils.isNumeric(value)) {
+ dims.add(Integer.valueOf(value));
+ }
+ }
+
+ int[] dim = new int[dims.size()];
+ for (int i = 0; i < dims.size(); i++) {
+ dim[i] = dims.get(i).intValue();
+ }
+ MatrixND newMat = MatrixFactory.getInstance().create(dim);
+
+ MatrixND mat = observation.getValue();
+ if (mat != null) {
+ newMat.paste(mat);
+ }
+ observation.setValue(newMat);
+ observation.update();
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove RecruitmentDistribution", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "RecruitmentDistribution"), eee);
+ }
+ }
+
protected void observationValueMatrixChanged(MatrixPanelEvent event) {
MatrixND mat = inputContentUI.fieldObservationValue.getMatrix();
if (inputContentUI.getBean() != null && mat != null) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -34,10 +34,17 @@
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationDAO;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
import jaxx.runtime.JAXXUtil;
@@ -47,6 +54,9 @@
*/
public class PopulationBasicsHandler extends InputContentHandler<PopulationBasicsUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationBasicsHandler.class);
+
protected void init(final PopulationBasicsUI inputContentUI) {
super.init(inputContentUI);
@@ -130,8 +140,30 @@
InputUI inputUI = inputContentUI.getContextValue(InputUI.class, JAXXUtil.PARENT);
Species species = inputUI.getHandler().findSpecies(inputUI);
// create node and select it
- Population population = inputContentUI.getContextValue(InputAction.class).createPopulation(inputContentUI.getTopiaContext(), species);
+ Population population = createPopulation(inputContentUI.getTopiaContext(), species);
inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
inputContentUI.setInfoText(t("isisfish.message.creation.finished"));
}
+
+ protected Population createPopulation(TopiaContext context, Species species) {
+ Population pop = null;
+ if (log.isTraceEnabled()) {
+ log.trace("createPopulation called");
+ }
+ try {
+ String name = "Population_new";
+
+ PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(context);
+ pop = dao.create();
+ pop.setName(name);
+
+ species.addPopulation(pop);
+ pop.setSpecies(species);
+ species.update();
+ pop.update();
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException(t("isisfish.error.input.addentity", "Population"), eee);
+ }
+ return pop;
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,24 +23,31 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationEmigrationHandler extends InputContentHandler<PopulationMigrationEmigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationEmigrationHandler.class);
+
protected void init(final PopulationMigrationEmigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -94,13 +101,33 @@
}
protected void add() {
- inputContentUI.getContextValue(InputAction.class).addEmigration(inputContentUI.getPopInfo(),
+ addEmigration(inputContentUI.getPopInfo(),
(PopulationGroup)inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText()));
inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().clone());
}
+
+ public Object addEmigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone departure, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addEmigration called");
+ }
+ try {
+ MatrixND mat = info.getEmigrationMatrix().copy();
+ mat.setValue(group, departure, coeff);
+ info.setEmigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add emigration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Emigration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,24 +23,31 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationImmigrationHandler extends InputContentHandler<PopulationMigrationImmigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationImmigrationHandler.class);
+
protected void init(final PopulationMigrationImmigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -93,13 +100,33 @@
}
protected void add() {
- inputContentUI.getContextValue(InputAction.class).addImmigration(inputContentUI.getPopInfo(),
+ addImmigration(inputContentUI.getPopInfo(),
(PopulationGroup)inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText()));
inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().clone());
}
+
+ public Object addImmigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone arrival, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addImmigration called");
+ }
+ try {
+ MatrixND mat = info.getImmigrationMatrix().copy();
+ mat.setValue(group, arrival, coeff);
+ info.setImmigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add immigration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Immigration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationImmigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,9 +23,13 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
@@ -34,12 +38,16 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationMigrationHandler extends InputContentHandler<PopulationMigrationMigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationMigrationHandler.class);
+
protected void init(final PopulationMigrationMigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -102,13 +110,33 @@
}
protected void add() {
- inputContentUI.getAction().addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
+ addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText()));
inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().clone());
}
+
+ public Object addMigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone departure, Zone arrival, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addMigration called");
+ }
+ try {
+ MatrixND mat = info.getMigrationMatrix().copy();
+ mat.setValue(group, departure, arrival, coeff);
+ info.setMigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add migration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Migration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationMigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,18 +23,33 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationRecruitmentHandler extends InputContentHandler<PopulationRecruitmentUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationRecruitmentHandler.class);
+
protected void init(final PopulationRecruitmentUI inputContentUI) {
super.init(inputContentUI);
@@ -58,4 +73,46 @@
}
}
}
+
+ public void createRecruitmentDistribution(Population pop) {
+ if (log.isTraceEnabled()) {
+ log.trace("createRecruitmentDistributionon called: " + pop);
+ }
+ try {
+ String val = JOptionPane
+ .showInputDialog(t("isisfish.message.recruitment.number.month"));
+ int num = -1;
+ if (val != null && !"".equals(val)) {
+ try {
+ num = Integer.parseInt(val);
+ } catch (RuntimeException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse val: " + val, eee);
+ }
+ }
+ }
+
+ if (num > 0) {
+ List<String> sem = new ArrayList<String>(num);
+ for (int i = 0; i < num; i++) {
+ sem.add(t("isisfish.common.month", i));
+ }
+ MatrixND newMat = MatrixFactory.getInstance().create(
+ new List[] { sem });
+
+ MatrixND mat = pop.getRecruitmentDistribution();
+ if (mat != null) {
+ newMat.paste(mat);
+ }
+ pop.setRecruitmentDistribution(newMat);
+ pop.update();
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove RecruitmentDistribution", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "RecruitmentDistribution"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -80,7 +80,7 @@
</cell>
<cell>
<JButton icon="table.png" toolTipText="isisfish.common.newMatrix"
- onActionPerformed="getAction().createRecruitmentDistribution(getBean())"
+ onActionPerformed="handler.createRecruitmentDistribution(getBean())"
enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -31,11 +33,14 @@
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.Interval;
/**
@@ -91,17 +96,71 @@
}
protected void create() {
- PopulationSeasonInfo seasonNew = inputContentUI.getContextValue(InputAction.class).createPopulationSeasonInfo(inputContentUI.getBean());
+ PopulationSeasonInfo seasonNew = createPopulationSeasonInfo(inputContentUI.getBean());
inputContentUI.setPopulationSeasonInfo(seasonNew);
setPopulationSeasonInfoCombo();
}
protected void delete() {
- inputContentUI.getContextValue(InputAction.class).removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
+ removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
inputContentUI.setPopulationSeasonInfo(null);
setPopulationSeasonInfoCombo();
}
+
+ protected PopulationSeasonInfo createPopulationSeasonInfo(Population pop) {
+ if (log.isDebugEnabled()) {
+ log.debug("createSeasonInfo called");
+ }
+ PopulationSeasonInfo seasonInfo = null;
+ try {
+ PopulationSeasonInfoDAO dao = IsisFishDAOHelper
+ .getPopulationSeasonInfoDAO(pop.getTopiaContext());
+ seasonInfo = dao.create();
+ seasonInfo.setFirstMonth(Month.MONTH[0]);
+ seasonInfo.setLastMonth(Month.MONTH[3]);
+ pop.addPopulationSeasonInfo(seasonInfo);
+ seasonInfo.setPopulation(pop);
+ // EC-20090710 ajout du code d'initailisation
+ // d'un populationseasoninfo
+ // il a du se perdre au changement d'interface
+ // swiat>jaxx
+ // moved to entity
+ //MatrixND matrix = ((PopulationSeasonInfoImpl) seasonInfo)
+ // .createNoSpacializedChangeGroupMatrix();
+ //seasonInfo.setLengthChangeMatrix(matrix);
+
+ seasonInfo.update();
+ pop.update();
+ // isisContext.commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create PopulationSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "PopulationSeasonInfo"), eee);
+ }
+ return seasonInfo;
+ }
+
+ protected void removePopulationSeasonInfo(Population pop,
+ PopulationSeasonInfo populationSeasonInfo) {
+ if (log.isDebugEnabled()) {
+ log.debug("removePopulationSeasonInfo called");
+ }
+ try {
+ pop.removePopulationSeasonInfo(populationSeasonInfo);
+ pop.update();
+ //pop.getTopiaContext().commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove PopulationSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "PopulationSeasonInfo"), eee);
+ }
+ }
+
protected void save() {
inputContentUI.getSaveVerifier().save();
setPopulationSeasonInfoCombo();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,22 +23,33 @@
package fr.ifremer.isisfish.ui.input.setofvessels;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.entities.SetOfVessels;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* set of vessels handler.
*/
public class EffortDescriptionHandler extends InputContentHandler<EffortDescriptionUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(EffortDescriptionHandler.class);
+
protected void init(final EffortDescriptionUI inputContentUI) {
super.init(inputContentUI);
@@ -56,14 +67,6 @@
});
}
- /**
- * Get input action from context.
- */
- @Deprecated
- protected InputAction getInputAction() {
- return inputContentUI.getContextValue(InputAction.class);
- }
-
protected void onFieldEffortDescriptionMetierListValueChanged() {
// active le bouton seulement si l'interface est active
// dans le cas de sensitivity par exemple
@@ -92,15 +95,61 @@
protected void addEffortDescriptions() {
List<Metier> selectedValues = inputContentUI.fieldEffortDescriptionMetierList.getSelectedValuesList();
for (Metier selectedMetier : selectedValues) {
- getInputAction().addEffortDescription(inputContentUI.getBean(), selectedMetier);
+ addEffortDescription(inputContentUI.getBean(), selectedMetier);
}
setEffortDescriptionEffortDescriptionList();
}
+
protected void removeEffortDescriptions() {
List<EffortDescription> selectedValues = inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
for (EffortDescription selectedEffortDescription : selectedValues) {
- getInputAction().removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
+ removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
}
setEffortDescriptionEffortDescriptionList();
}
+
+ public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) {
+ if (log.isDebugEnabled()) {
+ log.debug("addEffortDescription called: " + setOfVessels
+ + " metier: " + metier);
+ }
+ try {
+ EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper
+ .getEffortDescriptionDAO(metier.getTopiaContext());
+ EffortDescription effortDescription = effortDescriptionPS.create();
+ // EC20090715 : c'est la classe d'association
+ // qui en étant sauvee, sauve les relations en base
+ // il faut bien faire les set des deux cotes
+ effortDescription.setSetOfVessels(setOfVessels);
+ effortDescription.setPossibleMetiers(metier);
+ effortDescription.update();
+ setOfVessels.addPossibleMetiers(effortDescription);
+ setOfVessels.update();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create EffortDescription", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "EffortDescription"), eee);
+ }
+ }
+
+ public void removeEffortDescription(SetOfVessels sov,
+ EffortDescription effort) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeEffortDescription called");
+ }
+ try {
+ sov.removePossibleMetiers(effort);
+ // EC-20091112 : commit() twice cause hibernate error:
+ // Found two representations of same collection:
+ //sov.getTopiaContext().commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove entity: " + effort, eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "EffortDescription"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -27,7 +27,6 @@
javax.swing.tree.DefaultTreeModel
fr.ifremer.isisfish.datastore.RegionStorage
fr.ifremer.isisfish.ui.WelcomePanelUI
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.input.InputSaveVerifier
fr.ifremer.isisfish.ui.simulator.SimulAction
fr.ifremer.isisfish.simulator.sensitivity.FactorGroup
@@ -43,10 +42,6 @@
<fr.ifremer.isisfish.entities.FisheryRegion id='fisheryRegion' javaBean='null'/>
<script><![CDATA[
-protected InputAction getInputAction() {
- return getContextValue(InputAction.class);
-}
-
protected SimulAction getSimulAction() {
return getContextValue(SimulAction.class);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -25,7 +25,6 @@
<fr.ifremer.isisfish.ui.SimulationUI>
<import>
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
jaxx.runtime.context.JAXXInitialContext
jaxx.runtime.JAXXContext
@@ -79,11 +78,11 @@
<JTabbedPane id="bodyTabbedPane">
<tab title='isisfish.params.title'>
<fr.ifremer.isisfish.ui.simulator.ParamsUI id='paramsUI' sensitivity='true' regionStorage="{getRegionStorage()}"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivity.title' enabled="false">
<fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI id="sensitivityTabUI"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivityChooser.title' enabled="false">
<SensitivityChooserUI id="sensitivityChooserUI" constructorParams='this'/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -72,7 +72,6 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.TimeUnit;
import fr.ifremer.isisfish.ui.SimulationUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
@@ -364,7 +363,7 @@
result = new ContinuousDistributionPanel(min);
} else if (value instanceof Equation) {
Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI(new JAXXInitialContext().add(new InputAction()));
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
ui.setSelectedEquation(equation);
ui.setText(t("isisfish.common.equation")); // can't get real name
ui.setFormuleCategory(equation.getCategory());
@@ -575,7 +574,7 @@
result = new ContinuousDistributionPanel(min);
} else if (value instanceof Equation) {
Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI(new JAXXInitialContext().add(new InputAction()));
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
ui.setSelectedEquation(equation);
ui.setText(t("isisfish.common.equation")); // can't get real name
ui.setFormuleCategory(equation.getCategory());
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -52,7 +52,6 @@
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
import fr.ifremer.isisfish.ui.SimulationUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor;
import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer;
@@ -182,7 +181,6 @@
// init new sensitivity tav ui hierarchy
final SensitivityTabUI sensitivityTabUI = new SensitivityTabUI(view);
- sensitivityTabUI.setContextValue(new InputAction());
sensitivityTabUI.setContextValue(new SensitivitySaveVerifier()); // prevent NPE
sensitivityTabUI.setContextValue(view.getParentContainer(SimulationUI.class), "SimulationUI"); // prevent NPE
1
0
r4229 - trunk/src/main/java/fr/ifremer/isisfish/ui/queue
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 13:11:09 +0000 (Wed, 20 May 2015)
New Revision: 4229
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4229
Log:
Move script code to dedicated handler (queue)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -4,7 +4,7 @@
* #%L
* IsisFish
* %%
- * Copyright (C) 2014 Ifremer, Codelutin, Benjamin Poussin
+ * Copyright (C) 2014 - 2015 Ifremer, Codelutin, Benjamin Poussin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -22,7 +22,6 @@
* #L%
*/
-
import fr.ifremer.isisfish.simulator.launcher.SimulationExecutor;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
import java.awt.event.ItemEvent;
@@ -89,5 +88,4 @@
}
}
-
}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -1,146 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.queue;
-
-import static org.nuiton.i18n.I18n.t;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
-import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
-import fr.ifremer.isisfish.simulator.launcher.SimulationService;
-import fr.ifremer.isisfish.ui.util.ErrorHelper;
-
-/**
- * Common action for all queue ui.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class QueueAction {
-
- /** Log. */
- private static Log log = LogFactory.getLog(QueueAction.class);
-
- /** queue ui to manage. */
- protected QueueUI queueUI;
-
- /**
- * Queue action.
- *
- * @param queueUI queue ui to manage
- */
- public QueueAction(QueueUI queueUI) {
- this.queueUI = queueUI;
- }
-
- /**
- * Update ui buttons.
- */
- public void updateActions() {
- queueUI.setCanStop(!queueUI.getSelectionModelQueueTable().isSelectionEmpty());
- queueUI.setCanShowLog(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
- queueUI.setCanClear(queueUI.getQueueTableDone().getModel().getRowCount()>0);
- queueUI.setCanRestart(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
- }
-
- /**
- * Stop simulation associated with table selected rows.
- */
- protected void stopSimulation() {
- int[] selectedRows = queueUI.getQueueTable().getSelectedRows();
- SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length];
- int index = 0;
-
- // to do in two pass, because each stopped simulation
- // change selected rows
- for (int selectedRow : selectedRows) {
- jobsToStop[index++] = queueUI.getNewSimulationModel().getJob(selectedRow);
- }
- for (SimulationJob jobToStop : jobsToStop) {
- jobToStop.stop();
- if (log.isInfoEnabled()) {
- log.info(t("User stop simulation %s", jobToStop.getItem().getControl()
- .getId()));
- }
- }
- }
-
- /**
- * Restart simulation.
- */
- protected void restartSimulation() {
- int[] selectedRows = queueUI.getQueueTableDone().getSelectedRows();
- SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length];
- int index = 0;
-
- // to do in two pass, because each simulation
- // change selected rows
- for (int selectedRow : selectedRows) {
- jobsToRestart[index++] = queueUI.getDoneSimulationModel().getJob(selectedRow);
- }
- for (SimulationJob jobToRestart : jobsToRestart) {
-
- jobToRestart.restart();
- jobToRestart.getItem().getControl().setText(t("isisfish.simulation.restarting"));
- if (log.isInfoEnabled()) {
- log.info(t("User restart simulation %s", jobToRestart.getItem().getControl()
- .getId()));
- }
- }
- }
-
- /**
- * View log of selected done jobs.
- */
- protected void viewLog() {
- if (queueUI.getQueueTableDone().getSelectedRow() >= 0) {
- SimulationJob selectedJob = queueUI.getDoneSimulationModel().getJob(queueUI.getQueueTableDone().getSelectedRow());
-
- String id = selectedJob.getItem().getControl().getId();
- try {
- SimulationLoggerUtil.showSimulationLogConsole(queueUI, id);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("Can't open log for %s", id), eee);
- }
- ErrorHelper.showErrorDialog(t("Can't open log for %s", id), eee);
- }
- }
- }
-
- /**
- * Remove all done jobs.
- */
- protected void clearDoneJobs() {
- SimulationService ss = SimulationService.getService();
- ss.clearJobDone();
- }
-}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -0,0 +1,151 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.queue;
+
+import static org.nuiton.i18n.I18n.t;
+
+import javax.swing.JProgressBar;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
+import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
+import fr.ifremer.isisfish.simulator.launcher.SimulationService;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+
+/**
+ * Common action for all queue ui.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class QueueHandler {
+
+ /** Log. */
+ private static Log log = LogFactory.getLog(QueueHandler.class);
+
+ /** queue ui to manage. */
+ protected QueueUI queueUI;
+
+ /**
+ * Queue action.
+ *
+ * @param queueUI queue ui to manage
+ */
+ public void init(QueueUI queueUI) {
+ this.queueUI = queueUI;
+
+ queueUI.queueTable.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
+ queueUI.queueTableDone.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
+ }
+
+ /**
+ * Update ui buttons.
+ */
+ public void updateActions() {
+ queueUI.setCanStop(!queueUI.getSelectionModelQueueTable().isSelectionEmpty());
+ queueUI.setCanShowLog(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
+ queueUI.setCanClear(queueUI.getQueueTableDone().getModel().getRowCount()>0);
+ queueUI.setCanRestart(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
+ }
+
+ /**
+ * Stop simulation associated with table selected rows.
+ */
+ protected void stopSimulation() {
+ int[] selectedRows = queueUI.getQueueTable().getSelectedRows();
+ SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length];
+ int index = 0;
+
+ // to do in two pass, because each stopped simulation
+ // change selected rows
+ for (int selectedRow : selectedRows) {
+ jobsToStop[index++] = queueUI.getNewSimulationModel().getJob(selectedRow);
+ }
+ for (SimulationJob jobToStop : jobsToStop) {
+ jobToStop.stop();
+ if (log.isInfoEnabled()) {
+ log.info(t("User stop simulation %s", jobToStop.getItem().getControl()
+ .getId()));
+ }
+ }
+ }
+
+ /**
+ * Restart simulation.
+ */
+ protected void restartSimulation() {
+ int[] selectedRows = queueUI.getQueueTableDone().getSelectedRows();
+ SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length];
+ int index = 0;
+
+ // to do in two pass, because each simulation
+ // change selected rows
+ for (int selectedRow : selectedRows) {
+ jobsToRestart[index++] = queueUI.getDoneSimulationModel().getJob(selectedRow);
+ }
+ for (SimulationJob jobToRestart : jobsToRestart) {
+
+ jobToRestart.restart();
+ jobToRestart.getItem().getControl().setText(t("isisfish.simulation.restarting"));
+ if (log.isInfoEnabled()) {
+ log.info(t("User restart simulation %s", jobToRestart.getItem().getControl()
+ .getId()));
+ }
+ }
+ }
+
+ /**
+ * View log of selected done jobs.
+ */
+ protected void viewLog() {
+ if (queueUI.getQueueTableDone().getSelectedRow() >= 0) {
+ SimulationJob selectedJob = queueUI.getDoneSimulationModel().getJob(queueUI.getQueueTableDone().getSelectedRow());
+
+ String id = selectedJob.getItem().getControl().getId();
+ try {
+ SimulationLoggerUtil.showSimulationLogConsole(queueUI, id);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("Can't open log for %s", id), eee);
+ }
+ ErrorHelper.showErrorDialog(t("Can't open log for %s", id), eee);
+ }
+ }
+ }
+
+ /**
+ * Remove all done jobs.
+ */
+ protected void clearDoneJobs() {
+ SimulationService ss = SimulationService.getService();
+ ss.clearJobDone();
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
@@ -23,44 +23,42 @@
#L%
-->
<Table>
- <import>
- fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel;
- fr.ifremer.isisfish.simulator.launcher.SimulationService;
- javax.swing.JProgressBar;
- javax.swing.ListSelectionModel;
- </import>
-
- <script><![CDATA[
- queueTable.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
- queueTableDone.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
- ]]>
- </script>
+ <import>
+ fr.ifremer.isisfish.simulator.launcher.SimulationService
+ fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel
+ </import>
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
<Boolean id='canStop' javaBean='false'/>
<Boolean id='canShowLog' javaBean='false'/>
<Boolean id='canClear' javaBean='false'/>
<Boolean id='canRestart' javaBean='false'/>
- <QueueAction id="queueAction" javaBean='new QueueAction(this)'/>
+ <QueueHandler id="handler" />
<SimulationServiceTableModel id="newSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), true)'/>
<SimulationServiceTableModel id="doneSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), false)'
- onTableChanged='queueAction.updateActions()' />
+ onTableChanged='handler.updateActions()' />
<PauseButtonModel id="autoLaunchButtonModel" javaBean='new PauseButtonModel(SimulationService.getService())'/>
- <DefaultListSelectionModel id="selectionModelQueueTable" onValueChanged='queueAction.updateActions()'/>
- <DefaultListSelectionModel id="selectionModelQueueTableDone" onValueChanged='queueAction.updateActions()'/>
+ <DefaultListSelectionModel id="selectionModelQueueTable" onValueChanged='handler.updateActions()'/>
+ <DefaultListSelectionModel id="selectionModelQueueTableDone" onValueChanged='handler.updateActions()'/>
<row>
<cell columns="5" fill="both" weightx="1.0" weighty="0.5">
<JSplitPane oneTouchExpandable="true" orientation="VERTICAL" resizeWeight="0.5">
<JScrollPane>
<JTable id="queueTable" model='{newSimulationModel}'
- selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
+ selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{selectionModelQueueTable}"/>
</JScrollPane>
<JScrollPane>
<JTable id="queueTableDone" model='{doneSimulationModel}'
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
selectionModel="{selectionModelQueueTableDone}" />
</JScrollPane>
</JSplitPane>
@@ -71,16 +69,16 @@
<JToggleButton id="autoLaunchButton" text="isisfish.queue.simulationLaunch" model="{autoLaunchButtonModel}"/>
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='queueAction.stopSimulation()' enabled='{isCanStop()}' />
+ <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='handler.stopSimulation()' enabled='{isCanStop()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='queueAction.restartSimulation()' enabled='{isCanRestart()}' />
+ <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='handler.restartSimulation()' enabled='{isCanRestart()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='queueAction.viewLog()' enabled='{isCanShowLog()}' />
+ <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='handler.viewLog()' enabled='{isCanShowLog()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='queueAction.clearDoneJobs()' enabled='{isCanClear()}' />
+ <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='handler.clearDoneJobs()' enabled='{isCanClear()}' />
</cell>
</row>
</Table>
1
0
r4228 - in trunk/src/main/java/fr/ifremer/isisfish: datastore/migration ui/input ui/input/equation ui/input/gear ui/input/metier ui/input/population ui/input/setofvessels ui/input/strategy ui/input/variable ui/sensitivity ui/sensitivity/wizard ui/widget/editor
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 12:58:46 +0000 (Wed, 20 May 2015)
New Revision: 4228
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4228
Log:
Move script code to dedicated handler (equation)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
Modified:
trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -43,7 +43,7 @@
import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationImpl;
-import fr.ifremer.isisfish.ui.input.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
import fr.ifremer.isisfish.util.EvaluatorHelper;
/**
@@ -159,7 +159,7 @@
frame.setTitle(t("isisfish.message.import.equation.convert"));
try {
- frame.setEquation(equation.getCategory(), equation.getName(),
+ frame.getHandler().setEquation(equation.getCategory(), equation.getName(),
equation.getJavaInterface(), content);
} catch (Exception ex) {
if (log.isErrorEnabled()) {
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,141 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
- %%
- 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%
- -->
-<JDialog id="EquationEditorPane" modal="true" title="isisfish.equation.editor.title"
- width="400" height="400" layout="{new BorderLayout()}"
- modalityType="{Dialog.ModalityType.APPLICATION_MODAL}">
-
- <Boolean id="resultOk" javaBean="false" />
-
- <import>
- fr.ifremer.isisfish.util.CompileHelper;
- fr.ifremer.isisfish.util.EvaluatorHelper;
- org.nuiton.util.FileUtil;
- javax.swing.text.html.HTMLEditorKit;
- javax.swing.text.html.HTMLDocument;
- javax.swing.event.HyperlinkListener;
- javax.swing.text.html.HTMLFrameHyperlinkEvent;
- javax.swing.event.HyperlinkEvent;
- java.io.PrintWriter;
- java.io.StringWriter;
- java.awt.Color
- java.awt.Desktop
- </import>
-
- <script><![CDATA[
-Class javaInterface = null;
-
-protected void $afterCompleteSetup() {
- split.setDividerLocation(0.8);
-}
-
-public void setEquation(String category, String name, Class javaInterface, String content) throws Exception {
- this.javaInterface = javaInterface;
- getDoc().setText(CompileHelper.extractDoc(category, name, javaInterface));
- getEditor().open(FileUtil.getTempFile(content, ".java"));
-}
-
-public void docEditorHyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- if (e instanceof HTMLFrameHyperlinkEvent) {
- ((HTMLDocument)doc.getDocument()).processHTMLFrameHyperlinkEvent(
- (HTMLFrameHyperlinkEvent)e);
- } else {
- try {
- if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
- Desktop.getDesktop().browse(e.getURL().toURI());
- } else {
- doc.setPage(e.getURL());
- }
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Error for : " + e.getURL(), ex);
- }
- }
- }
- }
-}
-
-public void check() {
- try {
- String content = editor.getText();
-
- StringWriter result = new StringWriter();
- PrintWriter out = new PrintWriter(result);
- int compileResult = 0;
- try {
- compileResult = EvaluatorHelper.check(javaInterface, content, out);
- } catch (Exception eee) {
- compileResult = -1;
- }
-
- out.flush();
- if (compileResult != 0) {
- checkWindow.setText(result.toString());
- checkWindow.setBackground(Color.RED);
- } else {
- checkWindow.setText("Compilation Ok");
- checkWindow.setBackground(Color.WHITE);
- }
-
- } catch(Exception e){
- log.error("Can't check script", e);
- }
-}
-
- ]]></script>
-
- <Table constraints="BorderLayout.CENTER">
- <row>
- <cell columns='3' weighty="1" fill='both'>
- <JScrollPane>
- <JEditorPane id="doc" editable="false" editorKit="{new HTMLEditorKit()}"
- onHyperlinkUpdate="docEditorHyperlinkUpdate(event)" />
- </JScrollPane>
- </cell>
- </row>
- <row columns='3' weightx="1" weighty="5" fill='both'>
- <cell>
- <JSplitPane id='split' orientation='vertical'
- oneTouchExpandable='true' resizeWeight='0.8'>
- <org.nuiton.widget.editor.Editor id="editor" askIfNotSaved="false" />
- <JScrollPane>
- <JTextArea id="checkWindow" editable="false" />
- </JScrollPane>
- </JSplitPane>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JButton text='isisfish.common.check' onActionPerformed='check()' />
- </cell>
- <cell weightx="1" fill="none" anchor="east">
- <JButton id='okButton' text='isisfish.common.ok' onActionPerformed='setResultOk(true); setVisible(false)' />
- </cell>
- <cell anchor="east">
- <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed='setVisible(false)' />
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,69 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * 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%
- */
-
-package fr.ifremer.isisfish.ui.input;
-
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-
-import fr.ifremer.isisfish.entities.Formule;
-
-/**
- * Renderer pour la combo des {@link Formule}.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FormuleComboRenderer extends DefaultListCellRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8277883340386163087L;
-
- /*
- * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
- */
- @Override
- public Component getListCellRendererComponent(JList<?> list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- // this must be used to have alterned highlight rows and default
- // selection color
- JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
- index, isSelected, cellHasFocus);
-
- // there is no default selection
- if (value != null) {
- Formule formule = (Formule) value;
- c.setText(formule.getName());
- }
- return c;
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -78,6 +78,8 @@
import fr.ifremer.isisfish.ui.input.check.CheckRegion;
import fr.ifremer.isisfish.ui.input.check.CheckResult;
import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.util.CellPointcomparator;
@@ -91,7 +93,10 @@
*
* Last update: $Date$
* by : $Author$
+ *
+ * @deprecated since 4.4.0.0, move code to dedicated handlers
*/
+@Deprecated
public class InputAction {
/** Class logger. */
@@ -313,7 +318,7 @@
}
try {
EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
- pane.setEquation(category, name, javaInterface, content);
+ pane.getHandler().setEquation(category, name, javaInterface, content);
pane.setLocationRelativeTo(ui);
pane.setVisible(true); // blocking call
if (pane.isResultOk() && editor != null) {
@@ -330,7 +335,7 @@
return null;
}
- protected List<Formule> getFormules(TopiaContext isisContext, String name) {
+ public List<Formule> getFormules(TopiaContext isisContext, String name) {
return FormuleStorage.getFormules(isisContext, name);
}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,271 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
- %%
- 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%
- -->
-<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
-
- <!-- Equation name (just for display purpose, not mandatory) -->
- <String id='text' javaBean='null'/>
- <!-- Bean containing equation -->
- <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
- <!-- Bean property used to access equation -->
- <String id='beanProperty' javaBean='null'/>
- <!-- Used to get documentation in opened editor (not mandatory) -->
- <Class id='clazz' javaBean='null'/>
-
- <!-- Bean property -->
- <fr.ifremer.isisfish.entities.Formule id='formule' javaBean='null'/>
- <!-- Equation name used to auto select formule in combo box -->
- <String id='formuleCategory' javaBean='null'/>
- <!-- Selected equation -->
- <fr.ifremer.isisfish.entities.Equation id='selectedEquation' javaBean='null'/>
-
- <Boolean id="autoSaveModification" javaBean="true" />
-
- <import>
- static org.nuiton.i18n.I18n.t
- java.lang.reflect.Method;
- java.io.File;
- fr.ifremer.isisfish.entities.Formule;
- fr.ifremer.isisfish.entities.Equation;
- fr.ifremer.isisfish.ui.models.common.GenericComboModel;
- org.apache.commons.lang3.StringUtils;
- org.nuiton.topia.TopiaContext;
- javax.swing.event.DocumentListener;
- javax.swing.event.DocumentEvent
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- java.io.IOException
- javax.swing.DefaultComboBoxModel
- </import>
- <script><![CDATA[
-
-protected DocumentListener listener = null;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- formuleComboBox.setModel(new DefaultComboBoxModel());
- try {
- File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(nullFile);
- editor.setEnabled(false); // editor is replaced at each launch
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Error on property change", e);
- }
- }
- }
- if (evt.getNewValue() != null) {
- // chatellier 20090526 : force refresh in bean change ?
- refresh();
- }
- }
- });
-
- if (listener == null) {
- listener = new DocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- setEquation();
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- setEquation();
- }
- @Override
- public void changedUpdate(DocumentEvent e) {
- }
- };
- }
- setComboModel();
-}
-
-/**
- * Get equation on entity.
- */
-protected Equation getEquation() {
- Equation result = null;
- try {
- // can be null in some uis
- // content is managed by caller, can do anythings here
- if (bean != null && beanProperty != null) {
- String localBeanProperty = StringUtils.capitalize(beanProperty);
- Method m = bean.getClass().getMethod("get" + localBeanProperty);
- result = (Equation)m.invoke(bean);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't get equation", e);
- }
- }
- return result;
-}
-
-/**
- * Call setXXXContent on topia entity (convention).
- */
-protected void setEquation() {
- try {
- // can be null in some uis
- // content is managed by caller, can do anythings here
- if (bean != null && beanProperty != null) {
- if (log.isDebugEnabled()) {
- log.debug("Saving equation content (" + bean.getClass().getSimpleName() +
- "#" + beanProperty + ")");
- }
- String localBeanProperty = StringUtils.capitalize(beanProperty);
- Method m = bean.getClass().getMethod("set" + localBeanProperty + "Content", String.class);
- m.invoke(bean, editor.getText());
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No bean property defined, skipping content saving");
- }
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't set equation content", e);
- }
- }
-}
-
-public void refresh() {
-
- // TODO binding don't work
- if (getText() == null) {
- setText(t("isisfish.common.equation"));
- }
-
- editor.getCurrentEditor().removeDocumentListener(listener);
- try {
- File equationContentFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(equationContentFile);
- editor.setEnabled(isActive());
- } catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't refresh editor", ex);
- }
- }
- if (formuleCategory != null) {
- // chatellier 20090526 (change to get combo selected on this equation)
- selectedEquation = getEquation();
- setComboModel();
- setFormule((Formule)formuleComboBox.getSelectedItem());
- setEditorText();
- }
-
- // utilisee lors de l'edition des equations dans l'interface de sensibilité
- // le contenu de l'equation ne doit pas automatiquement
- // etre sauvé dans l'entité (pas de sens pour un facteur discret de type equation)
- if (autoSaveModification) {
- editor.getCurrentEditor().addDocumentListener(listener);
- }
-}
-
-protected void setComboModel() {
- if (getBean() != null){
- TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)getBean()).getTopiaContext();
- java.util.List<Formule> formules = null;
- if (formuleCategory != null) {
- formules = getAction().getFormules(isisContext, formuleCategory);
- GenericComboModel formulesModel = new GenericComboModel(formules);
- formuleComboBox.setModel(formulesModel);
- // fix default selection
- formuleComboBox.setSelectedItem(selectedEquation);
- }
- }
-}
-protected void saveModel() {
- getContextValue(InputAction.class).saveAsModel(formuleCategory, "Java", editor.getText());
- setComboModel();
- setInfoText(t("isisfish.message.saveModel.finished"));
-}
-
-/**
- * Open external editor, with equation documentation.
- */
-protected void openEditor() {
- Formule e = (Formule)formuleComboBox.getSelectedItem();
- if (e != null) {
- getContextValue(InputAction.class).openEditor(this, e.getCategory(), e.getName(), clazz, e.getContent(), editor);
- }
- else {
- getContextValue(InputAction.class).openEditor(this, formuleCategory, "new", clazz, editor.getText(), editor);
- }
-}
-protected void setEditorText() {
- if (getFormule() != null) {
- editor.setText(getFormule().getContent());
- }
- else {
- try {
- File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(nullFile);
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Open editor", e);
- }
- }
- }
-}
-
-/**
- * New formule selected, replace content.
- */
-protected void formuleChanged() {
- Formule selectedFormule = (Formule)formuleComboBox.getSelectedItem();
- setFormule(selectedFormule);
- setEditorText();
-}
- ]]>
- </script>
- <JPanel id="body">
- <Table insets="0">
- <row>
- <cell fill='horizontal' anchor='east'>
- <JLabel text='{getText()}' enabled='{isActive()}'/>
- </cell>
- <cell fill='horizontal'>
- <JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}'
- genericType="fr.ifremer.isisfish.entities.Formule"
- renderer="{new FormuleComboRenderer()}" />
- </cell>
- </row>
- <row>
- <cell fill='horizontal' anchor='north'>
- <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
- </cell>
- <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
- <org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' anchor='north' weighty='1.0'>
- <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
-</fr.ifremer.isisfish.ui.input.InputContentUI>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import java.awt.Color;
+import java.awt.Desktop;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLFrameHyperlinkEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+
+import fr.ifremer.isisfish.util.CompileHelper;
+import fr.ifremer.isisfish.util.EvaluatorHelper;
+
+/**
+ * Equation editor handler.
+ */
+public class EquationEditorPaneHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(EquationEditorPaneHandler.class);
+
+ protected EquationEditorPaneUI equationUI;
+
+ protected Class javaInterface = null;
+
+ protected void init(final EquationEditorPaneUI equationUI) {
+ this.equationUI = equationUI;
+
+ equationUI.split.setDividerLocation(0.8);
+ }
+
+ public void setEquation(String category, String name, Class javaInterface, String content) throws Exception {
+ this.javaInterface = javaInterface;
+ equationUI.getDoc().setText(CompileHelper.extractDoc(category, name, javaInterface));
+ equationUI.getEditor().open(FileUtil.getTempFile(content, ".java"));
+ }
+
+ public void docEditorHyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ if (e instanceof HTMLFrameHyperlinkEvent) {
+ ((HTMLDocument)equationUI.doc.getDocument()).processHTMLFrameHyperlinkEvent(
+ (HTMLFrameHyperlinkEvent)e);
+ } else {
+ try {
+ if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ Desktop.getDesktop().browse(e.getURL().toURI());
+ } else {
+ equationUI.doc.setPage(e.getURL());
+ }
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error for : " + e.getURL(), ex);
+ }
+ }
+ }
+ }
+ }
+
+ public void check() {
+ try {
+ String content = equationUI.editor.getText();
+
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
+ int compileResult = 0;
+ try {
+ compileResult = EvaluatorHelper.check(javaInterface, content, out);
+ } catch (Exception eee) {
+ compileResult = -1;
+ }
+
+ out.flush();
+ if (compileResult != 0) {
+ equationUI.checkWindow.setText(result.toString());
+ equationUI.checkWindow.setBackground(Color.RED);
+ } else {
+ equationUI.checkWindow.setText("Compilation Ok");
+ equationUI.checkWindow.setBackground(Color.WHITE);
+ }
+
+ } catch(Exception e){
+ log.error("Can't check script", e);
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,71 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
+ %%
+ 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%
+ -->
+<JDialog id="EquationEditorPane" modal="true" title="isisfish.equation.editor.title"
+ width="400" height="400" layout="{new BorderLayout()}"
+ modalityType="{Dialog.ModalityType.APPLICATION_MODAL}">
+
+ <Boolean id="resultOk" javaBean="false" />
+
+ <EquationEditorPaneHandler id="handler" />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
+ <Table constraints="BorderLayout.CENTER">
+ <row>
+ <cell columns='3' weighty="1" fill='both'>
+ <JScrollPane>
+ <JEditorPane id="doc" editable="false" editorKit="{new javax.swing.text.html.HTMLEditorKit()}"
+ onHyperlinkUpdate="handler.docEditorHyperlinkUpdate(event)" />
+ </JScrollPane>
+ </cell>
+ </row>
+ <row columns='3' weightx="1" weighty="5" fill='both'>
+ <cell>
+ <JSplitPane id='split' orientation='vertical'
+ oneTouchExpandable='true' resizeWeight='0.8'>
+ <org.nuiton.widget.editor.Editor id="editor" askIfNotSaved="false" />
+ <JScrollPane>
+ <JTextArea id="checkWindow" editable="false" />
+ </JScrollPane>
+ </JSplitPane>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JButton text='isisfish.common.check' onActionPerformed='handler.check()' />
+ </cell>
+ <cell weightx="1" fill="none" anchor="east">
+ <JButton id='okButton' text='isisfish.common.ok' onActionPerformed='setResultOk(true); setVisible(false)' />
+ </cell>
+ <cell anchor="east">
+ <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed='setVisible(false)' />
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java (from rev 4227, trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Formule;
+
+/**
+ * Renderer pour la combo des {@link Formule}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FormuleComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ // there is no default selection
+ if (value != null) {
+ Formule formule = (Formule) value;
+ c.setText(formule.getName());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,242 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Formule;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Equation handler.
+ */
+public class InputOneEquationHandler extends InputContentHandler<InputOneEquationUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(InputOneEquationHandler.class);
+
+ protected DocumentListener listener = null;
+
+ protected void init(final InputOneEquationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(InputOneEquationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.formuleComboBox.setModel(new DefaultComboBoxModel<Formule>());
+ try {
+ File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(nullFile);
+ inputContentUI.editor.setEnabled(false); // editor is replaced at each launch
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error on property change", e);
+ }
+ }
+ }
+ if (evt.getNewValue() != null) {
+ // chatellier 20090526 : force refresh in bean change ?
+ refresh();
+ }
+ }
+ });
+
+ if (listener == null) {
+ listener = new DocumentListener() {
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ setEquation();
+ }
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ setEquation();
+ }
+ @Override
+ public void changedUpdate(DocumentEvent e) {
+ }
+ };
+ }
+ setComboModel();
+ }
+
+ /**
+ * Get equation on entity.
+ */
+ protected Equation getEquation() {
+ Equation result = null;
+ try {
+ // can be null in some uis
+ // content is managed by caller, can do anythings here
+ if (inputContentUI.bean != null && inputContentUI.beanProperty != null) {
+ String localBeanProperty = StringUtils.capitalize(inputContentUI.beanProperty);
+ Method m = inputContentUI.bean.getClass().getMethod("get" + localBeanProperty);
+ result = (Equation)m.invoke(inputContentUI.bean);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get equation", e);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Call setXXXContent on topia entity (convention).
+ */
+ protected void setEquation() {
+ try {
+ // can be null in some uis
+ // content is managed by caller, can do anythings here
+ if (inputContentUI.bean != null && inputContentUI.beanProperty != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Saving equation content (" + inputContentUI.bean.getClass().getSimpleName() +
+ "#" + inputContentUI.beanProperty + ")");
+ }
+ String localBeanProperty = StringUtils.capitalize(inputContentUI.beanProperty);
+ Method m = inputContentUI.bean.getClass().getMethod("set" + localBeanProperty + "Content", String.class);
+ m.invoke(inputContentUI.bean, inputContentUI.editor.getText());
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No bean property defined, skipping content saving");
+ }
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't set equation content", e);
+ }
+ }
+ }
+
+ public void refresh() {
+
+ // TODO binding don't work
+ if (inputContentUI.getText() == null) {
+ inputContentUI.setText(t("isisfish.common.equation"));
+ }
+
+ inputContentUI.editor.getCurrentEditor().removeDocumentListener(listener);
+ try {
+ File equationContentFile = FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(equationContentFile);
+ inputContentUI.editor.setEnabled(inputContentUI.isActive());
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't refresh editor", ex);
+ }
+ }
+ if (inputContentUI.formuleCategory != null) {
+ // chatellier 20090526 (change to get combo selected on this equation)
+ inputContentUI.selectedEquation = getEquation();
+ setComboModel();
+ inputContentUI.setFormule((Formule)inputContentUI.formuleComboBox.getSelectedItem());
+ setEditorText();
+ }
+
+ // utilisee lors de l'edition des equations dans l'interface de sensibilité
+ // le contenu de l'equation ne doit pas automatiquement
+ // etre sauvé dans l'entité (pas de sens pour un facteur discret de type equation)
+ if (inputContentUI.autoSaveModification) {
+ inputContentUI.editor.getCurrentEditor().addDocumentListener(listener);
+ }
+ }
+
+ protected void setComboModel() {
+ if (inputContentUI.getBean() != null){
+ TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)inputContentUI.getBean()).getTopiaContext();
+ List<Formule> formules = null;
+ if (inputContentUI.formuleCategory != null) {
+ formules = inputContentUI.getAction().getFormules(isisContext, inputContentUI.formuleCategory);
+ GenericComboModel<Formule> formulesModel = new GenericComboModel<>(formules);
+ inputContentUI.formuleComboBox.setModel(formulesModel);
+ // fix default selection
+ inputContentUI.formuleComboBox.setSelectedItem(inputContentUI.selectedEquation);
+ }
+ }
+ }
+
+ protected void saveModel() {
+ inputContentUI.getContextValue(InputAction.class).saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
+ setComboModel();
+ inputContentUI.setInfoText(t("isisfish.message.saveModel.finished"));
+ }
+
+ /**
+ * Open external editor, with equation documentation.
+ */
+ protected void openEditor() {
+ Formule e = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
+ if (e != null) {
+ inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, e.getCategory(),
+ e.getName(), inputContentUI.clazz, e.getContent(), inputContentUI.editor);
+ } else {
+ inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, inputContentUI.formuleCategory,
+ "new", inputContentUI.clazz, inputContentUI.editor.getText(), inputContentUI.editor);
+ }
+ }
+
+ protected void setEditorText() {
+ if (inputContentUI.getFormule() != null) {
+ inputContentUI.editor.setText(inputContentUI.getFormule().getContent());
+ } else {
+ try {
+ File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(nullFile);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Open editor", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * New formule selected, replace content.
+ */
+ protected void formuleChanged() {
+ Formule selectedFormule = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
+ inputContentUI.setFormule(selectedFormule);
+ setEditorText();
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx (from rev 4227, trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,81 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
+ %%
+ 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%
+ -->
+<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
+
+ <!-- Equation name (just for display purpose, not mandatory) -->
+ <String id='text' javaBean='null'/>
+ <!-- Bean containing equation -->
+ <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
+ <!-- Bean property used to access equation -->
+ <String id='beanProperty' javaBean='null'/>
+ <!-- Used to get documentation in opened editor (not mandatory) -->
+ <Class id='clazz' javaBean='null'/>
+
+ <!-- Bean property -->
+ <fr.ifremer.isisfish.entities.Formule id='formule' javaBean='null'/>
+ <!-- Equation name used to auto select formule in combo box -->
+ <String id='formuleCategory' javaBean='null'/>
+ <!-- Selected equation -->
+ <fr.ifremer.isisfish.entities.Equation id='selectedEquation' javaBean='null'/>
+
+ <Boolean id="autoSaveModification" javaBean="true" />
+
+ <InputOneEquationHandler id="handler" />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
+ <JPanel id="body">
+ <Table insets="0">
+ <row>
+ <cell fill='horizontal' anchor='east'>
+ <JLabel text='{getText()}' enabled='{isActive()}'/>
+ </cell>
+ <cell fill='horizontal'>
+ <JComboBox id="formuleComboBox" onActionPerformed='handler.formuleChanged()' enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Formule"
+ renderer="{new FormuleComboRenderer()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' anchor='north'>
+ <JButton text="isisfish.common.saveModel" onActionPerformed='handler.saveModel()' enabled='{isActive() && formuleCategory != null}'/>
+ </cell>
+ <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
+ <org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' anchor='north' weighty='1.0'>
+ <JButton text="isisfish.common.openEditor" onActionPerformed='handler.openEditor()'
+ enabled='{isActive() && clazz != null && formuleCategory != null}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+</fr.ifremer.isisfish.ui.input.InputContentUI>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -67,7 +67,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0' insets="0">
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='selectivityEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='selectivityEquation' constructorParams='this'
text='isisfish.selectivity.equation'
bean='{getBean()}' formuleCategory='Selectivity' active='{getPopulation() != null}'
clazz='{fr.ifremer.isisfish.equation.SelectivityEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -85,7 +85,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='targetFactor' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='targetFactor' constructorParams='this'
active='{isActive() && getMetierSeasonInfo() != null}'
text='isisfish.metierSeasonInfoSpecies.targetFactor'
bean='{getMetierSeasonInfo()}' formuleCategory='TargetFactor'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -122,7 +122,7 @@
</row>
<row>
<cell columns='4' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='growthEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='growthEquation' constructorParams='this'
text='isisfish.populationBasics.growth' active='{isActive()}'
bean='{getBean()}' beanProperty='growth' formuleCategory='Growth'
clazz='{fr.ifremer.isisfish.equation.PopulationGrowth.class}'
@@ -131,7 +131,7 @@
</row>
<row>
<cell columns='4' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='growthReverseEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='growthReverseEquation' constructorParams='this'
text='isisfish.populationBasics.growthReverse' active='{isActive()}'
bean='{getBean()}' formuleCategory='GrowthReverse' beanProperty='GrowthReverse'
clazz='{fr.ifremer.isisfish.equation.PopulationGrowthReverse.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -63,7 +63,7 @@
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"Capturability"'
onMatrixChanged="handler.populationCapturabilityMatrixChanged(event)"
constraints='"fieldUseMatrix"' />
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
text='isisfish.common.capturability' active='{isActive()}'
bean='{getBean()}' formuleCategory='Capturability' beanProperty='CapturabilityEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationCapturabilityEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
<Table>
<row>
<cell columns='2' fill='both' weightx='0.5' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='naturalDeathRate' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='naturalDeathRate' constructorParams='this'
text='isisfish.populationEquation.naturalDeathRate' active="{isActive()}"
bean='{getBean()}' formuleCategory='NaturalDeathRate' beanProperty='NaturalDeathRate'
clazz='{fr.ifremer.isisfish.equation.PopulationNaturalDeathRate.class}'
@@ -53,7 +53,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='meanWeight' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='meanWeight' constructorParams='this'
text='isisfish.populationEquation.meanWeight' active="{isActive()}"
bean='{getBean()}' formuleCategory='MeanWeight' beanProperty='MeanWeight'
clazz='{fr.ifremer.isisfish.equation.PopulationMeanWeight.class}'
@@ -62,7 +62,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='maturityOgive' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='maturityOgive' constructorParams='this'
text='isisfish.populationEquation.MaturityOgive' active="{isActive()}"
bean='{getBean()}' formuleCategory='MaturityOgive' beanProperty='MaturityOgiveEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationMaturityOgiveEquation.class}'
@@ -71,7 +71,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='reproductionRate' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='reproductionRate' constructorParams='this'
text='isisfish.populationEquation.reproductionRate' active="{isActive()}"
bean='{getBean()}' formuleCategory='ReproductionRate' beanProperty='ReproductionRateEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationReproductionRateEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -47,7 +47,7 @@
<Table>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='migrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='migrationEquation' constructorParams='this'
text='isisfish.common.migration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Migration' beanProperty='MigrationEquation'
clazz='{fr.ifremer.isisfish.equation.MigrationEquation.class}'
@@ -56,7 +56,7 @@
</row>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='emigrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='emigrationEquation' constructorParams='this'
text='isisfish.common.emigration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Emigration' beanProperty='EmigrationEquation'
clazz='{fr.ifremer.isisfish.equation.EmigrationEquation.class}'
@@ -65,7 +65,7 @@
</row>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='immigrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='immigrationEquation' constructorParams='this'
text='isisfish.common.immigration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Immigration' beanProperty='ImmigrationEquation'
clazz='{fr.ifremer.isisfish.equation.ImmigrationEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
<Table>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='price' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='price' constructorParams='this'
text='isisfish.populationEquation.price' active="{isActive()}"
bean='{getBean()}' formuleCategory='Price' beanProperty='Price'
clazz='{fr.ifremer.isisfish.equation.PopulationPrice.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -47,7 +47,7 @@
<Table>
<row>
<cell columns='3' fill='both' weightx='1.0' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='reproductionEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='reproductionEquation' constructorParams='this'
active="{isActive()}" text='isisfish.populationEquation.reproductionEquation'
bean='{getBean()}' formuleCategory='Reproduction' beanProperty='ReproductionEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationReproductionEquation.class}'
@@ -86,7 +86,7 @@
</row>
<row>
<cell columns='3' fill='both' weightx='1.0' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='recruitmentEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='recruitmentEquation' constructorParams='this'
active="{isActive()}" text='isisfish.populationEquation.recruitmentEquation'
bean='{getBean()}' formuleCategory='Recruitment' beanProperty='RecruitmentEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationRecruitmentEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -104,7 +104,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='technicalEfficiency' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='technicalEfficiency' constructorParams='this'
text='isisfish.setOfVessels.technicalEfficiency' active='{isActive()}'
bean='{getBean()}' formuleCategory='TechnicalEfficiency' beanProperty='TechnicalEfficiencyEquation'
clazz='{fr.ifremer.isisfish.equation.SoVTechnicalEfficiencyEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -92,7 +92,7 @@
</row>
<row>
<cell columns="2" fill='both' weightx='1.0' weighty='0.5'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="strategyInactivity" constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id="strategyInactivity" constructorParams='this'
text='isisfish.strategy.inactivity'
active="{isActive() && getBean() != null && bean.isInactivityEquationUsed()}"
bean='{getBean()}' formuleCategory='Inactivity' beanProperty='InactivityEquation'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -141,7 +141,7 @@
<Table constraints='"equationtype"' insets="0">
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue"
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id="variableEquationValue"
constructorParams='this'
active='{isActive() && getVariable() != null}'
text='isisfish.common.equation' formuleCategory='Variable'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -63,7 +63,7 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.ui.input.InputContentUI;
import fr.ifremer.isisfish.ui.input.InputHandler;
-import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -191,7 +191,7 @@
</row>
<row>
<cell fill='both' columns='2' weightx='1' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='editor' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='editor' constructorParams='this'
autoSaveModification="false" formule='{getFormule()}' text='{getText()}'
bean='{getBean()}' clazz='{getClazz()}' beanProperty='{getBeanProperty()}'
formuleCategory='{getFormuleCategory()}' selectedEquation='{getSelectedEquation()}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -73,7 +73,7 @@
import fr.ifremer.isisfish.types.TimeUnit;
import fr.ifremer.isisfish.ui.SimulationUI;
import fr.ifremer.isisfish.ui.input.InputAction;
-import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
import fr.ifremer.isisfish.ui.widget.editor.MonthComponent;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.Equation;
-import fr.ifremer.isisfish.ui.input.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
/**
* Equation table cell editor.
@@ -102,7 +102,7 @@
this.setText(equation.getName());
try {
- getFrame().setEquation(equation.getCategory(), equation.getName(),
+ getFrame().getHandler().setEquation(equation.getCategory(), equation.getName(),
equation.getJavaInterface(), equation.getContent());
} catch (Exception eee) {
throw new IsisFishRuntimeException(
1
0
20 May '15
Author: echatellier
Date: 2015-05-20 12:09:09 +0000 (Wed, 20 May 2015)
New Revision: 4227
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4227
Log:
Move script code to dedicated handler
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx
trunk/src/main/resources/i18n/isis-fish_en_GB.properties
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ * Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,6 +25,8 @@
package fr.ifremer.isisfish.ui;
+import javax.swing.JOptionPane;
+
/**
* Isis interface modification verifier.
*
@@ -38,16 +40,18 @@
* by : $Author$
*/
public interface SaveVerifier {
-
+
+ public static final int YES_OPTION = JOptionPane.YES_OPTION;
+ public static final int NO_OPTION = JOptionPane.NO_OPTION;
+ public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
+
/**
* Tell verifier to check for unsaved modification.
*
- * Then return user choice ({@link javax.swing.JOptionPane} type).
- *
- * @return user JOptionPane response
- * @see javax.swing.JOptionPane#YES_OPTION
- * @see javax.swing.JOptionPane#NO_OPTION
- * @see javax.swing.JOptionPane#CANCEL_OPTION
+ * @return user int response
+ * @see #YES_OPTION
+ * @see #NO_OPTION
+ * @see #CANCEL_OPTION
*/
public int checkEdit();
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * Copyright (C) 2009 - 2015 Ifremer, Code Lutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -28,8 +28,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.swing.JOptionPane;
-
/**
* WelcomeSaveVerifier.
*
@@ -66,7 +64,7 @@
// return false, if at least one verifier
// return cancel option
- if (reponse == JOptionPane.CANCEL_OPTION) {
+ if (reponse == SaveVerifier.CANCEL_OPTION) {
canExit = false;
}
}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/FormuleComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Formule;
+
+/**
+ * Renderer pour la combo des {@link Formule}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FormuleComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ // there is no default selection
+ if (value != null) {
+ Formule formule = (Formule) value;
+ c.setText(formule.getName());
+ }
+ return c;
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -48,7 +48,7 @@
protected void init(final T inputContentUI) {
this.inputContentUI = inputContentUI;
}
-
+
/**
* Action appelée lors du clic sur un layer (sensitivity).
*
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -242,41 +242,30 @@
]]>
</script>
<JPanel id="body">
- <Table>
+ <Table insets="0">
<row>
<cell fill='horizontal' anchor='east'>
<JLabel text='{getText()}' enabled='{isActive()}'/>
</cell>
- <cell fill='horizontal' weightx='1.0'>
+ <cell fill='horizontal'>
<JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Formule"
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.FormuleComboRenderer()}" />
+ renderer="{new FormuleComboRenderer()}" />
</cell>
</row>
<row>
- <cell fill='both' weighty='1.0'>
- <Table>
- <row>
- <cell fill='horizontal'>
- <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal'>
- <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' weighty='1.0'>
- <JPanel/>
- </cell>
- </row>
- </Table>
+ <cell fill='horizontal' anchor='north'>
+ <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
</cell>
- <cell fill='both' weightx='1.0' weighty='1.0'>
+ <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
<org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
</cell>
</row>
+ <row>
+ <cell fill='horizontal' anchor='north' weighty='1.0'>
+ <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
+ </cell>
+ </row>
</Table>
</JPanel>
</fr.ifremer.isisfish.ui.input.InputContentUI>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -25,7 +25,6 @@
package fr.ifremer.isisfish.ui.input;
-import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -114,7 +113,7 @@
int response = saveVerifier.checkEdit();
- if (response == JOptionPane.CANCEL_OPTION) {
+ if (response == SaveVerifier.CANCEL_OPTION) {
exit = false;
}
return exit;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,9 +31,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import com.bbn.openmap.event.SelectMouseMode;
import fr.ifremer.isisfish.entities.Cell;
@@ -49,9 +46,6 @@
*/
public class CellHandler extends InputContentHandler<CellUI> {
- /** Class logger. */
- private static final Log log = LogFactory.getLog(CellHandler.class);
-
protected boolean init;
protected void init(final CellUI cellUI) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2002 - 2011 Ifremer, CodeLutin, Chatellier Eric
+ * Copyright (C) 2002 - 2015 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -48,9 +48,9 @@
protected Set<Object> order = new LinkedHashSet<Object>();
- protected Map<Object, List<String>> info = new HashMap<Object, List<String>>();
- protected Map<Object, List<String>> warning = new HashMap<Object, List<String>>();
- protected Map<Object, List<String>> error = new HashMap<Object, List<String>>();
+ protected Map<Object, List<String>> info = new HashMap<>();
+ protected Map<Object, List<String>> warning = new HashMap<>();
+ protected Map<Object, List<String>> error = new HashMap<>();
public StringBuffer getInfo() {
StringBuffer result = new StringBuffer();
@@ -187,7 +187,7 @@
order.add(o);
List<String> list = info.get(o);
if (list == null) {
- info.put(o, list = new LinkedList<String>());
+ info.put(o, list = new LinkedList<>());
}
list.add(message);
}
@@ -202,7 +202,7 @@
order.add(o);
List<String> list = warning.get(o);
if (list == null) {
- warning.put(o, list = new LinkedList<String>());
+ warning.put(o, list = new LinkedList<>());
}
list.add(message);
}
@@ -217,7 +217,7 @@
order.add(o);
List<String> list = error.get(o);
if (list == null) {
- error.put(o, list = new LinkedList<String>());
+ error.put(o, list = new LinkedList<>());
}
list.add(message);
}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Gear handler.
+ */
+public class GearHandler extends InputContentHandler<GearUI> {
+
+ protected void init(final GearUI gearUI) {
+ super.init(gearUI);
+
+ gearUI.setButtonTitle(t("isisfish.input.continueMetiers"));
+ gearUI.setNextPath(n("isisfish.input.tree.metiers"));
+
+ gearUI.addPropertyChangeListener(GearUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
+ }
+ }
+ });
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ gearUI.installChangeListener(gearUI.gearTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Gear tab handler.
+ */
+public class GearTabHandler extends InputContentHandler<GearTabUI> {
+
+ protected void init(final GearTabUI gearTabUI) {
+ super.init(gearTabUI);
+
+ gearTabUI.addPropertyChangeListener(GearTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ gearTabUI.fieldGearName.setText("");
+ gearTabUI.fieldGearEffortUnit.setText("");
+ gearTabUI.fieldGearStandardisationFactor.setText("");
+ gearTabUI.fieldGearParamName.setText("");
+ gearTabUI.fieldGearComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,11 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Gear;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
+ <GearTabHandler id="handler" />
<BeanValidator id='validator' context="gear"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear'
@@ -41,40 +37,11 @@
</BeanValidator>
<script><![CDATA[
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldGearName.setText("");
- fieldGearEffortUnit.setText("");
- fieldGearStandardisationFactor.setText("");
- fieldGearParamName.setText("");
- fieldGearComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-/*public void refresh() {
- Gear gear = getSaveVerifier().getEntity(Gear.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(gear);
-
- getVerifier().addCurrentPanel(rangeOfValues);
-
- // chatellier commented since number editor is not working
- //if (getBean() != null) {
- // fieldGearStandardisationFactor.init();
- //}
-}*/
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
]]></script>
+
<JPanel id="body">
<Table>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,50 +26,25 @@
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
+ <GearHandler id="handler" />
+
<script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueMetiers"));
- setNextPath(n("isisfish.input.tree.metiers"));
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ gearTabUI.setLayer(active);
+ selectivityUI.setLayer(active);
+ }
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
- }
- }
- });
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(gearTab);
-}
-
-/*public void refresh() {
- //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- gearTabUI.setLayer(active);
- selectivityUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- gearTabUI.resetChangeModel();
- selectivityUI.resetChangeModel();
-}
+ @Override
+ public void resetChangeModel() {
+ gearTabUI.resetChangeModel();
+ selectivityUI.resetChangeModel();
+ }
]]></script>
<JPanel id="body">
<JTabbedPane constraints='BorderLayout.CENTER' id="gearTab">
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.types.RangeOfValues;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * RangeOfValues handler.
+ */
+public class RangeOfValuesHandler extends InputContentHandler<RangeOfValuesUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(RangeOfValuesHandler.class);
+
+ protected boolean init;
+
+ protected void init(final RangeOfValuesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(RangeOfValuesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>();
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldGearParamPossibleValue.setText("");
+ inputContentUI.fieldGearParamType.setSelectedItem(null);
+ inputContentUI.fieldGearParamType.setModel(gearParamTypeModel);
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+
+ List<String> values = new ArrayList<String>();
+ for (String value : RangeOfValues.getPossibleTypes()) {
+ values.add(value);
+ }
+ gearParamTypeModel.setElementList(values);
+
+ inputContentUI.fieldGearParamType.setModel(gearParamTypeModel);
+ if (inputContentUI.getBean().getPossibleValue() != null) {
+ inputContentUI.fieldGearParamType.setSelectedItem(inputContentUI.getBean().getPossibleValue().getType());
+ }
+
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void gearParamChanged() {
+ if (inputContentUI.fieldGearParamType.getSelectedItem() != null && !init) {
+ inputContentUI.getBean().setPossibleValue(new RangeOfValues(inputContentUI.fieldGearParamType.getSelectedItem().toString()
+ .concat("[" + inputContentUI.fieldGearParamPossibleValue.getText() + "]")));
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,55 +27,12 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.types.RangeOfValues
- fr.ifremer.isisfish.entities.Gear
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener
- java.util.List
- java.util.ArrayList
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <RangeOfValuesHandler id="handler" />
<script><![CDATA[
-
-boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
-
- GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>();
- if (evt.getNewValue() == null) {
- fieldGearParamPossibleValue.setText("");
- fieldGearParamType.setSelectedItem(null);
- fieldGearParamType.setModel(gearParamTypeModel);
- }
- if (evt.getNewValue() != null) {
- init = true;
-
- List<String> values = new ArrayList<String>();
- for (String value : RangeOfValues.getPossibleTypes()) {
- values.add(value);
- }
- gearParamTypeModel.setElementList(values);
-
- fieldGearParamType.setModel(gearParamTypeModel);
- if (getBean().getPossibleValue() != null) {
- fieldGearParamType.setSelectedItem(getBean().getPossibleValue().getType());
- }
-
- init = false;
- }
- }
- });
-}
-
-protected void gearParamChanged() {
- if (fieldGearParamType.getSelectedItem() != null && !init) {
- getBean().setPossibleValue(new RangeOfValues(fieldGearParamType.getSelectedItem().toString().concat("[" + fieldGearParamPossibleValue.getText() + "]")));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
]]></script>
<JPanel id='body'>
<Table>
@@ -83,11 +40,11 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldGearParamType"
genericType="String"
- onItemStateChanged='gearParamChanged()' enabled='{isActive()}'/>
+ onItemStateChanged='handler.gearParamChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue() == null ? "" : getBean().getPossibleValue().getValues()}'
- onKeyReleased='gearParamChanged()' enabled='{isActive()}'/>
+ onKeyReleased='handler.gearParamChanged()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,142 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.Selectivity;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
+
+/**
+ * Selectivity handler.
+ */
+public class SelectivityHandler extends InputContentHandler<SelectivityUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(SelectivityHandler.class);
+
+ protected void init(final SelectivityUI selectivityUI) {
+ super.init(selectivityUI);
+
+ selectivityUI.addPropertyChangeListener(SelectivityUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ selectivityUI.setPopulation(null);
+ selectivityUI.selectivityTable.setModel(new GearPopulationSelectivityModel());
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+ }
+
+ public void refresh() {
+
+ //Gear gear = (Gear)inputContentUI.getSaveVerifier().getEntity(Gear.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(gear);
+
+ if (inputContentUI.getBean() != null) {
+ setSelectivityTableModel();
+ inputContentUI.fieldSelectivityPopulation.setModel(getSelectivityPopulationModel());
+ }
+ }
+
+ protected void setSelectivityTableModel() {
+
+ List<Selectivity> selectivitiesList = new ArrayList<Selectivity>();
+
+ // set model even if no selectivity
+ // to clear data
+ if (inputContentUI.getBean().getPopulationSelectivity() != null) {
+ // move collection to list
+ // and add all entity to verifier
+ for (Selectivity oneSelectivity : inputContentUI.getBean().getPopulationSelectivity()) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(oneSelectivity);
+ selectivitiesList.add(oneSelectivity);
+
+ // hack to enable save button :(
+ oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+ }
+ }
+
+ // set table model
+ GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList);
+ inputContentUI.selectivityTable.setModel(model);
+ inputContentUI.selectivityTable.setDefaultRenderer(Equation.class, model);
+ inputContentUI.selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor());
+ }
+
+ protected void addSelectivity() {
+ inputContentUI.getAction().addSelectivity(inputContentUI.getPopulation(),
+ inputContentUI.selectivityEquation.getEditor().getText(), inputContentUI.getBean());
+ setSelectivityTableModel();
+ }
+
+ protected void removeSelectivity() {
+ GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)inputContentUI.selectivityTable.getModel();
+ Selectivity selectedSelectivity = model.getSelectivities().get(inputContentUI.selectivityTable.getSelectedRow());
+ inputContentUI.getAction().removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
+ inputContentUI.getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
+ setSelectivityTableModel();
+ inputContentUI.removeSelectivityButton.setEnabled(false);
+ }
+
+ protected GenericComboModel<Population> getSelectivityPopulationModel() {
+ List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
+ List<Population> populations = new ArrayList<>();
+ if (species != null) {
+ for (Species s : species) {
+ if (s.getPopulation() != null) {
+ populations.addAll(s.getPopulation());
+ }
+ }
+ }
+ GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations);
+ return selectivityPopulationModel;
+ }
+
+ protected void selectivityChanged() {
+ inputContentUI.setPopulation((Population)inputContentUI.fieldSelectivityPopulation.getSelectedItem());
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,6 +29,8 @@
<fr.ifremer.isisfish.entities.Population id='population' javaBean='null'/>
+ <SelectivityHandler id="handler" />
+
<BeanValidator id='validator' context="selectivity"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -37,116 +39,17 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}"
valid="{validator.isValid()}" />
- <import>
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Gear
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.Selectivity
- fr.ifremer.isisfish.entities.Species
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- javax.swing.DefaultComboBoxModel
- </import>
-
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setPopulation(null);
- selectivityTable.setModel(new GearPopulationSelectivityModel());
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-public void refresh() {
-
- Gear gear = (Gear)getSaveVerifier().getEntity(Gear.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(gear);
-
- if (getBean() != null) {
- setSelectivityTableModel();
- fieldSelectivityPopulation.setModel(getSelectivityPopulationModel());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-protected void setSelectivityTableModel() {
-
- List<Selectivity> selectivitiesList = new ArrayList<Selectivity>();
-
- // set model even if no selectivity
- // to clear data
- if (getBean().getPopulationSelectivity() != null) {
- // move collection to list
- // and add all entity to verifier
- for (Selectivity oneSelectivity : getBean().getPopulationSelectivity()) {
- getSaveVerifier().addCurrentEntity(oneSelectivity);
- selectivitiesList.add(oneSelectivity);
-
- // hack to enable save button :(
- oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
- }
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-
- // set table model
- GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList);
- selectivityTable.setModel(model);
- selectivityTable.setDefaultRenderer(Equation.class, model);
- selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor());
-}
-
-protected void addSelectivity() {
- getAction().addSelectivity(getPopulation(), selectivityEquation.getEditor().getText(), getBean());
- setSelectivityTableModel();
-}
-
-protected void removeSelectivity() {
- GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)selectivityTable.getModel();
- Selectivity selectedSelectivity = model.getSelectivities().get(selectivityTable.getSelectedRow());
- getAction().removeSelectivity(getBean(), selectedSelectivity);
- getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
- setSelectivityTableModel();
- removeSelectivityButton.setEnabled(false);
-}
-
-protected DefaultComboBoxModel getSelectivityPopulationModel() {
- List<Species> species = getFisheryRegion().getSpecies();
- List<Population> populations = new ArrayList<Population>();
- if (species != null) {
- for (Species s : species) {
- if (s.getPopulation() != null) {
- populations.addAll(s.getPopulation());
- }
- }
- }
- GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations);
- return selectivityPopulationModel;
-}
-
-protected void selectivityChanged() {
- setPopulation((Population)fieldSelectivityPopulation.getSelectedItem());
-}
]]></script>
+
<JPanel id='body'>
<Table>
<row>
@@ -157,7 +60,7 @@
<JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActive()}' decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='selectivityChanged()'
+ <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='handler.selectivityChanged()'
genericType="fr.ifremer.isisfish.entities.Population"
enabled='{isActive()}' decorator='boxed' />
</cell>
@@ -173,7 +76,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()'
+ <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='handler.addSelectivity()'
enabled='{getPopulation() != null}' decorator='boxed' />
</cell>
</row>
@@ -189,7 +92,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()'
+ <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='handler.removeSelectivity()'
enabled='false' decorator='boxed' />
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Metier handler.
+ */
+public class MetierHandler extends InputContentHandler<MetierUI> {
+
+ protected void init(final MetierUI metierUI) {
+ super.init(metierUI);
+
+ metierUI.setButtonTitle(t("isisfish.input.continueTripTypes"));
+ metierUI.setNextPath(n("isisfish.input.tree.triptypes"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ metierUI.installChangeListener(metierUI.metierTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+
+/**
+ * Renderer pour la combo des {@link MetierSeasonInfo}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MetierSeasonInfoComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ MetierSeasonInfo metierSeasonInfo = (MetierSeasonInfo) value;
+
+ // there is no default selection
+ if (value != null) {
+ c.setText(metierSeasonInfo.getFirstMonth() + "-" + metierSeasonInfo.getLastMonth());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,143 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierSeasonInfoSpeciesHandler extends InputContentHandler<MetierSeasonInfoSpeciesUI> {
+
+ protected void init(final MetierSeasonInfoSpeciesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(MetierSeasonInfoSpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ setSeasonModel();
+ inputContentUI.setSpecies(null);
+ inputContentUI.setMetierSeasonInfo(null);
+ setTargetSpeciesModel();
+ setTableTargetSpeciesModel();
+ }
+ });
+ }
+
+ protected void setSeasonModel() {
+ List<MetierSeasonInfo> metierSeasonInfo = null;
+
+ if (inputContentUI.getBean() != null) {
+ metierSeasonInfo = inputContentUI.getBean().getMetierSeasonInfo();
+ }
+ GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo);
+ inputContentUI.fieldMetierSeasonInfo.setModel(seasonModel);
+ }
+
+ protected void metierSeasonInfoChanged() {
+ MetierSeasonInfo selectedMSI = (MetierSeasonInfo)inputContentUI.fieldMetierSeasonInfo.getSelectedItem();
+ inputContentUI.setMetierSeasonInfo(selectedMSI);
+ if (selectedMSI != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo());
+ setTableTargetSpeciesModel();
+ }
+ }
+
+ protected void setTargetSpeciesModel() {
+ List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
+ GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species);
+ inputContentUI.fieldTargetSpecies.setModel(fieldTargetSpeciesModel);
+ }
+
+ protected void speciesChanged() {
+ Species species = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem();
+ inputContentUI.setSpecies(species);
+ }
+
+ protected void setTableTargetSpeciesModel() {
+ List<TargetSpecies> targetSpecies = new ArrayList<>();
+
+ if (inputContentUI.getBean() != null && inputContentUI.getMetierSeasonInfo() != null) {
+ // SpeciesTargetSpecies can be null durring region creation
+ if (inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies() != null) {
+ // move collection to list
+ // and add all entity to verifier
+ for (TargetSpecies oneTargetSpecies : inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies()) {
+ targetSpecies.add(oneTargetSpecies);
+ inputContentUI.getSaveVerifier().addCurrentEntity(oneTargetSpecies);
+ oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+ }
+ }
+ }
+
+ // set table model
+ MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies);
+ inputContentUI.tableTargetSpecies.setModel(model);
+ inputContentUI.tableTargetSpecies.setDefaultRenderer(Equation.class, model);
+ inputContentUI.tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor());
+ }
+
+ protected void add() {
+ Species selectedSpecies = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem();
+ if (selectedSpecies != null) {
+ // il n'y en a pas a la creation de la base
+ //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
+ inputContentUI.getContextValue(InputAction.class).addTargetSpecies(
+ inputContentUI.getBean(),
+ inputContentUI.getMetierSeasonInfo(),
+ selectedSpecies,
+ inputContentUI.targetFactor.getEditor().getText(),
+ inputContentUI.fieldPrimaryCatch.isSelected());
+ setTableTargetSpeciesModel();
+ }
+ }
+
+ protected void remove() {
+ // TODO change delete selected truc from model
+ Object[] targetSpecies = inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies().toArray();
+
+ Object o = targetSpecies[inputContentUI.tableTargetSpecies.getSelectedRow()];
+ if (o != null) {
+ TargetSpecies ts = (TargetSpecies)o;
+ inputContentUI.getAction().removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
+ inputContentUI.getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
+ setTableTargetSpeciesModel();
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,22 +31,7 @@
<fr.ifremer.isisfish.entities.Species id='species' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.MetierSeasonInfo
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.entities.Species
- fr.ifremer.isisfish.entities.TargetSpecies
- fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- java.util.List
- java.awt.Dimension
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <MetierSeasonInfoSpeciesHandler id="handler" />
<BeanValidator id='validator' context="metier"
bean='{getMetierSeasonInfo()}' beanClass='fr.ifremer.isisfish.entities.MetierSeasonInfo'
@@ -56,110 +41,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}"
valid="{validator.isValid()}" />
- <script><![CDATA[
+ <import>
+ java.awt.Dimension
+ </import>
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- setSeasonModel();
- setSpecies(null);
- setMetierSeasonInfo(null);
- setTargetSpeciesModel();
- setTableTargetSpeciesModel();
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void setSeasonModel() {
- List<MetierSeasonInfo> metierSeasonInfo = null;
-
- if (getBean() != null) {
- metierSeasonInfo = getBean().getMetierSeasonInfo();
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo);
- fieldMetierSeasonInfo.setModel(seasonModel);
-}
-protected void metierSeasonInfoChanged() {
- MetierSeasonInfo selectedMSI = (MetierSeasonInfo)fieldMetierSeasonInfo.getSelectedItem();
- setMetierSeasonInfo(selectedMSI);
- if (selectedMSI != null) {
- getSaveVerifier().addCurrentEntity(getMetierSeasonInfo());
- setTableTargetSpeciesModel();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
-
-protected void setTargetSpeciesModel() {
- List<Species> species = getFisheryRegion().getSpecies();
- GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species);
- fieldTargetSpecies.setModel(fieldTargetSpeciesModel);
-}
-
-protected void speciesChanged() {
- Species species = (Species)fieldTargetSpecies.getSelectedItem();
- setSpecies(species);
-}
-
-protected void setTableTargetSpeciesModel() {
- List<TargetSpecies> targetSpecies = new ArrayList<TargetSpecies>();
-
- if (getBean() != null && getMetierSeasonInfo() != null) {
- // SpeciesTargetSpecies can be null durring region creation
- if (getMetierSeasonInfo().getSpeciesTargetSpecies() != null) {
- // move collection to list
- // and add all entity to verifier
- for (TargetSpecies oneTargetSpecies : getMetierSeasonInfo().getSpeciesTargetSpecies()) {
- targetSpecies.add(oneTargetSpecies);
- getSaveVerifier().addCurrentEntity(oneTargetSpecies);
- oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
- }
- }
- }
-
- // set table model
- MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies);
- tableTargetSpecies.setModel(model);
- tableTargetSpecies.setDefaultRenderer(Equation.class, model);
- tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor());
-}
-
-protected void add() {
- Species selectedSpecies = (Species)fieldTargetSpecies.getSelectedItem();
- if (selectedSpecies != null) {
- // il n'y en a pas a la creation de la base
- //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
- getContextValue(InputAction.class).addTargetSpecies(
- getBean(),
- getMetierSeasonInfo(),
- selectedSpecies,
- targetFactor.getEditor().getText(),
- fieldPrimaryCatch.isSelected());
- setTableTargetSpeciesModel();
- }
-}
-
-protected void remove() {
- // TODO change delete selected truc from model
- Object[] targetSpecies = getMetierSeasonInfo().getSpeciesTargetSpecies().toArray();
-
- Object o = targetSpecies[tableTargetSpecies.getSelectedRow()];
- if (o != null) {
- TargetSpecies ts = (TargetSpecies)o;
- getAction().removeTargetSpecies(getMetierSeasonInfo(), ts);
- getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
- setTableTargetSpeciesModel();
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -170,9 +66,9 @@
<JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='metierSeasonInfoChanged()'
+ <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='handler.metierSeasonInfoChanged()'
genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}"
+ renderer="{new MetierSeasonInfoComboRenderer()}"
enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'/>
</cell>
</row>
@@ -182,7 +78,7 @@
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldTargetSpecies" onItemStateChanged='speciesChanged()'
+ <JComboBox id="fieldTargetSpecies" onItemStateChanged='handler.speciesChanged()'
genericType="fr.ifremer.isisfish.entities.Species"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
@@ -208,7 +104,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='{getMetierSeasonInfo() != null && getSpecies() != null}' decorator='boxed'/>
</cell>
</row>
@@ -225,7 +121,7 @@
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='false' decorator='boxed'/>
+ onActionPerformed='handler.remove()' enabled='false' decorator='boxed'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,211 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.event.ListSelectionListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.widget.Interval;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierSeasonInfoZoneHandler extends InputContentHandler<MetierSeasonInfoZoneUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(MetierSeasonInfoZoneHandler.class);
+
+ protected Interval interval = null;
+ protected boolean init = false;
+
+ protected void init(final MetierSeasonInfoZoneUI inputContentUI) {
+ super.init(inputContentUI);
+
+ /*
+ * Don't add both in same listener.
+ * When first is set, last value from getPopulationSeasonInfo()
+ * is erased by interval.getLast() default value.
+ */
+ inputContentUI.ip.addPropertyChangeListener("first", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ inputContentUI.getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst()));
+ }
+ }
+ });
+ inputContentUI.ip.addPropertyChangeListener("last", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ inputContentUI.getMetierSeasonInfo().setLastMonth(new Month(interval.getLast()));
+ }
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(MetierSeasonInfoZoneUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+ }
+
+ protected void save() {
+ inputContentUI.getSaveVerifier().save();
+ setMetierSeasonInfoCombo();
+ }
+
+ protected void create() {
+ MetierSeasonInfo newMSI = inputContentUI.getContextValue(InputAction.class).createMetierSeasonInfo(inputContentUI.getBean());
+ inputContentUI.setMetierSeasonInfo(newMSI);
+ setMetierSeasonInfoCombo();
+ }
+
+ protected void delete() {
+ inputContentUI.getContextValue(InputAction.class).removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
+ inputContentUI.setMetierSeasonInfo(null);
+ setMetierSeasonInfoCombo();
+ }
+
+ public void refresh() {
+
+ inputContentUI.setMetierSeasonInfo(null);
+
+ if (inputContentUI.getBean() != null) {
+ // Model instanciation
+ interval = new Interval();
+ interval.setMin(0);
+ interval.setMax(11);
+ interval.setFirst(0);
+ interval.setLast(2);
+
+ setMetierSeasonInfoCombo();
+ setSeason();
+ setMetierZone();
+
+ inputContentUI.ip.setLabelRenderer(Month.MONTH);
+ inputContentUI.ip.setModel(interval);
+ }
+ }
+
+ protected void setSeason() {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+
+ // register selected item in save verifier
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo());
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Refresh interval : ");
+ }
+ Month firstMonth = inputContentUI.getMetierSeasonInfo().getFirstMonth();
+ if (firstMonth != null) {
+ interval.setFirst(firstMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" first : " + interval.getFirst());
+ }
+ } else {
+ interval.setFirst(0);
+ }
+
+ Month lastMonth = inputContentUI.getMetierSeasonInfo().getLastMonth();
+ if (lastMonth != null) {
+ interval.setLast(lastMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" last : " + interval.getLast());
+ }
+ } else {
+ interval.setLast(3);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't display season", e);
+ }
+ }
+ }
+ }
+ protected void setMetierZone() {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ ListSelectionListener[] listeners = inputContentUI.metierZones.getListSelectionListeners();
+ for (ListSelectionListener listener : listeners) {
+ inputContentUI.metierZones.removeListSelectionListener(listener);
+ }
+
+ List<Zone> allZones = inputContentUI.getFisheryRegion().getZone();
+ GenericListModel<Zone> model = new GenericListModel<>(allZones);
+ inputContentUI.metierZones.setModel(model);
+ // restore selection
+ if (inputContentUI.metierSeasonInfo.getZone() != null) {
+ for (Zone zone : inputContentUI.metierSeasonInfo.getZone()) {
+ int index = allZones.indexOf(zone);
+ inputContentUI.metierZones.getSelectionModel().addSelectionInterval(index, index);
+ }
+ }
+
+ for (ListSelectionListener listener : listeners) {
+ inputContentUI.metierZones.addListSelectionListener(listener);
+ }
+ }
+ }
+
+ protected void setMetierSeasonInfoCombo() {
+ List<MetierSeasonInfo> metierSeasonInfoList = inputContentUI.getBean().getMetierSeasonInfo();
+ GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList);
+ inputContentUI.metierSeasonInfoCombo.setModel(metierSeasonInfoModel);
+ metierSeasonInfoModel.setSelectedItem(inputContentUI.getMetierSeasonInfo());
+ }
+
+ protected void metierZonesChanged() {
+ List<Zone> selected = inputContentUI.metierZones.getSelectedValuesList();
+ List<Zone> zones = new ArrayList<>(selected);
+ inputContentUI.getMetierSeasonInfo().setZone(zones);
+ }
+
+ protected void seasonChanged() {
+ init = true;
+ inputContentUI.setMetierSeasonInfo((MetierSeasonInfo)inputContentUI.metierSeasonInfoCombo.getSelectedItem());
+ setSeason();
+ setMetierZone();
+ init = false;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,21 +29,7 @@
<fr.ifremer.isisfish.entities.MetierSeasonInfo id='metierSeasonInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.entities.MetierSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.types.Month
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.widget.Interval
- fr.ifremer.isisfish.ui.widget.IntervalPanel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- java.awt.Dimension
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <MetierSeasonInfoZoneHandler id="handler" />
<BeanValidator id='validator' context="metier"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier'
@@ -58,177 +44,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorSeason.isChanged()}"
valid="{validator.isValid() && validatorSeason.isValid()}" />
- <script><![CDATA[
-
- protected Interval interval = null;
- protected boolean init = false;
+ <import>
+ java.awt.Dimension
+ </import>
+ <script><![CDATA[
protected void $afterCompleteSetup() {
- /*
- * Don't add both in same listener.
- * When first is set, last value from getPopulationSeasonInfo()
- * is erased by interval.getLast() default value.
- */
- ip.addPropertyChangeListener("first", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getMetierSeasonInfo() != null) {
- getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst()));
- }
- }
- });
- ip.addPropertyChangeListener("last", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getMetierSeasonInfo() != null) {
- getMetierSeasonInfo().setLastMonth(new Month(interval.getLast()));
- }
- }
- });
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
+ handler.init(this);
}
@Override
public void resetChangeModel() {
changeModel.setStayChanged(false);
}
-
- protected void save() {
- getSaveVerifier().save();
- setMetierSeasonInfoCombo();
- }
-
- protected void create() {
- MetierSeasonInfo newMSI = getContextValue(InputAction.class).createMetierSeasonInfo(getBean());
- setMetierSeasonInfo(newMSI);
- setMetierSeasonInfoCombo();
- }
-
- protected void delete() {
- getContextValue(InputAction.class).removeMetierSeasonInfo(getBean(), getMetierSeasonInfo());
- setMetierSeasonInfo(null);
- setMetierSeasonInfoCombo();
- }
-
- public void refresh() {
-
- if (log.isDebugEnabled()) {
- log.debug("Refresh called in ui : " + this);
- }
-
- setMetierSeasonInfo(null);
-
- if (getBean() != null) {
- // Model instanciation
- interval = new Interval();
- interval.setMin(0);
- interval.setMax(11);
- interval.setFirst(0);
- interval.setLast(2);
-
- setMetierSeasonInfoCombo();
- setSeason();
- setMetierZone();
-
- ip.setLabelRenderer(Month.MONTH);
- ip.setModel(interval);
- }
- }
-
- protected void setSeason() {
- if (getMetierSeasonInfo() != null) {
-
- // register selected item in save verifier
- getSaveVerifier().addCurrentEntity(getMetierSeasonInfo());
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Refresh interval : ");
- }
- Month firstMonth = getMetierSeasonInfo().getFirstMonth();
- if (firstMonth != null) {
- interval.setFirst(firstMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" first : " + interval.getFirst());
- }
- } else {
- interval.setFirst(0);
- }
-
- Month lastMonth = getMetierSeasonInfo().getLastMonth();
- if (lastMonth != null) {
- interval.setLast(lastMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" last : " + interval.getLast());
- }
- } else {
- interval.setLast(3);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't display season", e);
- }
- }
- }
- }
- protected void setMetierZone() {
- if (getMetierSeasonInfo() != null) {
- ListSelectionListener[] listeners = metierZones.getListSelectionListeners();
- for (ListSelectionListener listener : listeners) {
- metierZones.removeListSelectionListener(listener);
- }
-
- List<Zone> allZones = getFisheryRegion().getZone();
- GenericListModel<Zone> model = new GenericListModel<>(allZones);
- metierZones.setModel(model);
- // restore selection
- if (metierSeasonInfo.getZone() != null) {
- for (Zone zone : metierSeasonInfo.getZone()) {
- int index = allZones.indexOf(zone);
- metierZones.getSelectionModel().addSelectionInterval(index, index);
- }
- }
-
- for (ListSelectionListener listener : listeners) {
- metierZones.addListSelectionListener(listener);
- }
- }
- }
-
- protected void setMetierSeasonInfoCombo() {
- List<MetierSeasonInfo> metierSeasonInfoList = getBean().getMetierSeasonInfo();
- GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList);
- metierSeasonInfoCombo.setModel(metierSeasonInfoModel);
- metierSeasonInfoModel.setSelectedItem(getMetierSeasonInfo());
- }
-
- protected void metierZonesChanged() {
- List<Zone> selected = metierZones.getSelectedValuesList();
- List<Zone> zones = new ArrayList<Zone>();
- for (Zone o : selected) {
- zones.add(o);
- }
- getMetierSeasonInfo().setZone(zones);
- }
-
- protected void seasonChanged() {
- init = true;
- setMetierSeasonInfo((MetierSeasonInfo)metierSeasonInfoCombo.getSelectedItem());
- setSeason();
- setMetierZone();
- init = false;
- }
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -239,10 +69,10 @@
<JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()'
+ <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='handler.seasonChanged()'
genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" />
+ renderer="{new MetierSeasonInfoComboRenderer()}" />
</cell>
</row>
<row>
@@ -250,7 +80,7 @@
<JLabel text="isisfish.metierSeasonInfoZone.season" enabled='{getMetierSeasonInfo() != null}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
+ <fr.ifremer.isisfish.ui.widget.IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
</row>
<row>
@@ -259,7 +89,7 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="metierZones" onValueChanged='metierZonesChanged()'
+ <JList id="metierZones" onValueChanged='handler.metierZonesChanged()'
genericType="fr.ifremer.isisfish.entities.Zone"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</JScrollPane>
@@ -289,7 +119,7 @@
<JButton id='save' decorator='boxed'
text="isisfish.common.save"
enabled="{changeModel.isValid() && changeModel.isChanged()}"
- onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
+ onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='cancel' decorator='boxed'
@@ -303,13 +133,13 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!changeModel.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
text="isisfish.common.remove"
enabled="{getMetierSeasonInfo() != null}"
- onActionPerformed="delete()"/>
+ onActionPerformed="handler.delete()"/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierTabHandler extends InputContentHandler<MetierTabUI> {
+
+ protected boolean init;
+
+ protected void init(final MetierTabUI metierTabUI) {
+ super.init(metierTabUI);
+
+ metierTabUI.addPropertyChangeListener(MetierTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ GenericComboModel<Gear> model = new GenericComboModel<>(metierTabUI.getFisheryRegion().getGear());
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ model.setSelectedItem(metierTabUI.bean.getGear());
+ init = false;
+ }
+ metierTabUI.fieldMetierGear.setModel(model);
+ }
+ });
+ }
+
+ protected void gearChanged() {
+ if (!init) {
+ inputContentUI.getBean().setGear((Gear)inputContentUI.fieldMetierGear.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,61 +27,24 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Gear
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.Dimension
- </import>
-
+ <MetierTabHandler id="handler" />
+
<BeanValidator id='validator' context="metier"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
<field name="name" component="fieldMetierName" />
</BeanValidator>
- <script><![CDATA[
-protected boolean init = false;
+ <import>
+ java.awt.Dimension
+ </import>
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- GenericComboModel<Gear> model = new GenericComboModel<>(getFisheryRegion().getGear());
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
- model.setSelectedItem(bean.getGear());
- init = false;
- }
- fieldMetierGear.setModel(model);
- }
- });
-}
-
-/*public void refresh() {
-
- if (log.isDebugEnabled()) {
- log.debug("Refresh called in ui : " + this);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-
- Metier metier = getSaveVerifier().getEntity(Metier.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(metier);
-}*/
-
-protected void gearChanged() {
- if (!init) {
- getBean().setGear((Gear)fieldMetierGear.getSelectedItem());
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -102,7 +65,7 @@
<JLabel text="isisfish.common.gear" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldMetierGear" onItemStateChanged='gearChanged()'
+ <JComboBox id="fieldMetierGear" onItemStateChanged='handler.gearChanged()'
genericType="fr.ifremer.isisfish.entities.Gear"
enabled='{isActive()}' decorator='boxed'/>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,36 +26,29 @@
<fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <MetierHandler id="handler" />
-<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueTripTypes"));
- setNextPath(n("isisfish.input.tree.triptypes"));
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(metierTab);
-}
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- metierTabUI.setLayer(active);
- metierSeasonInfoUI.setLayer(active);
- metierSeasonSpeciesUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- metierTabUI.resetChangeModel();
- metierSeasonInfoUI.resetChangeModel();
- metierSeasonSpeciesUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ metierTabUI.setLayer(active);
+ metierSeasonInfoUI.setLayer(active);
+ metierSeasonSpeciesUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ metierTabUI.resetChangeModel();
+ metierSeasonInfoUI.resetChangeModel();
+ metierSeasonSpeciesUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="metierTab" constraints='BorderLayout.CENTER'>
<tab title='isisfish.metier.title'>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.observation;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Observation handler.
+ */
+public class ObservationHandler extends InputContentHandler<ObservationUI> {
+
+ protected void init(final ObservationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(ObservationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldObservationValue.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ setObservationValueMatrix();
+ }
+ }
+ });
+ }
+
+ protected void setObservationValueMatrix() {
+ MatrixND prop = inputContentUI.getBean().getValue();
+ if (prop != null) {
+ inputContentUI.fieldObservationValue.setMatrix(prop.copy());
+ } else {
+ inputContentUI.fieldObservationValue.setMatrix(null);
+ }
+ }
+
+ protected void createObservationValueMatrix() {
+ inputContentUI.getAction().createObservationValueMatrix(inputContentUI.getBean());
+ setObservationValueMatrix();
+ }
+
+ protected void observationValueMatrixChanged(MatrixPanelEvent event) {
+ MatrixND mat = inputContentUI.fieldObservationValue.getMatrix();
+ if (inputContentUI.getBean() != null && mat != null) {
+ inputContentUI.getBean().setValue(mat.copy());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2014 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -23,64 +23,25 @@
#L%
-->
<fr.ifremer.isisfish.ui.input.InputContentUI
- superGenericType='fr.ifremer.isisfish.entities.Observation'>
+ superGenericType='fr.ifremer.isisfish.entities.Observation'>
- <!-- bean property -->
- <fr.ifremer.isisfish.entities.Observation
- id='bean' javaBean='null' />
+ <!-- bean property -->
+ <fr.ifremer.isisfish.entities.Observation id='bean' javaBean='null' />
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.MatrixND
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <ObservationHandler id="handler" />
- <BeanValidator id='validator'
- bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation'
- uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="name" component="fieldObservationName" />
- </BeanValidator>
+ <BeanValidator id='validator'
+ bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation'
+ uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="name" component="fieldObservationName" />
+ </BeanValidator>
- <script><![CDATA[
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldObservationValue.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- setObservationValueMatrix();
- }
- }
- });
-}
-
-protected void setObservationValueMatrix() {
- MatrixND prop = getBean().getValue();
- if (prop != null) {
- fieldObservationValue.setMatrix(prop.copy());
- } else {
- fieldObservationValue.setMatrix(null);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-protected void createObservationValueMatrix() {
- getAction().createObservationValueMatrix(getBean());
- setObservationValueMatrix();
-}
-
-protected void observationValueMatrixChanged(MatrixPanelEvent event) {
- MatrixND mat = fieldObservationValue.getMatrix();
- if (getBean() != null && mat != null) {
- getBean().setValue(mat.copy());
- }
-}
-
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -124,7 +85,7 @@
<row>
<cell columns='2' fill='both' weighty='1' weightx='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor
- id="fieldObservationValue" onMatrixChanged="observationValueMatrixChanged(event)"
+ id="fieldObservationValue" onMatrixChanged="handler.observationValueMatrixChanged(event)"
enabled='{isActive()}' decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Observation.class}'
_sensitivityMethod='"Value"' />
@@ -135,7 +96,7 @@
<JPanel/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JButton text="isisfish.common.newMatrix" onActionPerformed='createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/>
+ <JButton text="isisfish.common.newMatrix" onActionPerformed='handler.createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.BorderLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.table.DefaultTableModel;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.InputUI;
+import jaxx.runtime.JAXXUtil;
+
+/**
+ * Population handler.
+ */
+public class PopulationBasicsHandler extends InputContentHandler<PopulationBasicsUI> {
+
+ protected void init(final PopulationBasicsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationBasicsName.setText("");
+ inputContentUI.fieldPopulationBasicsGeographicID.setText("");
+ inputContentUI.fieldPopulationBasicsNbClasses.setText("");
+ inputContentUI.fieldPopulationBasicsComment.setText("");
+ inputContentUI.tableAgeLength.setModel(new DefaultTableModel());
+ }
+ if (evt.getNewValue() != null) {
+ setTableAgeLengthModel();
+ }
+ }
+ });
+ }
+
+ public void refresh() {
+ Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ inputContentUI.setBean(null);
+ inputContentUI.setBean(population);
+
+ if (inputContentUI.getBean() != null) {
+ setTableAgeLengthModel();
+ }
+ //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation);
+ }
+
+ /**
+ * Open creation classe wizard after confirmation.
+ */
+ protected void createGroups() {
+
+ int response = JOptionPane.showConfirmDialog(inputContentUI, t("isisfish.populationBasics.confirmCreateGroups"),
+ t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ JFrame wizardFrame = new JFrame();
+ wizardFrame.setLayout(new BorderLayout());
+ WizardGroupCreationUI wizard = new WizardGroupCreationUI(inputContentUI);
+ wizard.getHandler().initParent(inputContentUI);
+ wizardFrame.add(wizard, BorderLayout.CENTER);
+ wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title"));
+ Species species = inputContentUI.getBean().getSpecies();
+ wizard.getHandler().setAgeType(species.isAgeGroupType());
+ if (wizard.getHandler().isAgeType()) {
+ wizard.getHandler().setCard("singleGroupAge");
+ } else {
+ wizard.getHandler().setCard("beginGroupLength");
+ }
+ wizardFrame.pack();
+ wizardFrame.setLocationRelativeTo(inputContentUI);
+ wizardFrame.setVisible(true);
+ }
+
+ }
+
+ protected void setTableAgeLengthModel() {
+ List<PopulationGroup> popGroup = inputContentUI.getBean().getPopulationGroup();
+ if (popGroup != null){
+ DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1);
+ model.setValueAt("Age", 0, 0);
+ model.setValueAt("Lengths", 1, 0);
+ int cnt = 1;
+ for (PopulationGroup pg : popGroup){
+ model.setValueAt(pg.getAge(), 0, cnt);
+ model.setValueAt(pg.getLength(), 1, cnt);
+ cnt++;
+ }
+ inputContentUI.tableAgeLength.setModel(model);
+ }
+ }
+
+ protected void create() {
+ // find species node
+ InputUI inputUI = inputContentUI.getContextValue(InputUI.class, JAXXUtil.PARENT);
+ Species species = inputUI.getHandler().findSpecies(inputUI);
+ // create node and select it
+ Population population = inputContentUI.getContextValue(InputAction.class).createPopulation(inputContentUI.getTopiaContext(), species);
+ inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
+ inputContentUI.setInfoText(t("isisfish.message.creation.finished"));
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.Species;
- fr.ifremer.isisfish.entities.PopulationGroup;
- fr.ifremer.isisfish.entities.Population;
- javax.swing.table.DefaultTableModel;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- javax.swing.JOptionPane
- javax.swing.JFrame
- java.awt.BorderLayout
- fr.ifremer.isisfish.ui.input.InputUI
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <PopulationBasicsHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -49,93 +36,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationBasicsName.setText("");
- fieldPopulationBasicsGeographicID.setText("");
- fieldPopulationBasicsNbClasses.setText("");
- fieldPopulationBasicsComment.setText("");
- tableAgeLength.setModel(new DefaultTableModel());
- }
- if (evt.getNewValue() != null) {
- setTableAgeLengthModel();
- }
- }
- });
-}
-
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null) {
- setTableAgeLengthModel();
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation);
-}
+ ]]></script>
-/**
- * Open creation classe wizard after confirmation.
- */
-protected void createGroups() {
-
- int response = JOptionPane.showConfirmDialog(this, t("isisfish.populationBasics.confirmCreateGroups"),
- t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
-
- if (response == JOptionPane.YES_OPTION) {
- JFrame wizardFrame = new JFrame();
- wizardFrame.setLayout(new BorderLayout());
- WizardGroupCreationUI wizard = new WizardGroupCreationUI(this);
- wizard.init(this);
- wizardFrame.add(wizard, BorderLayout.CENTER);
- wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title"));
- Species species = getBean().getSpecies();
- wizard.setAgeType(species.isAgeGroupType());
- if (wizard.isAgeType()) {
- wizard.setCard("singleGroupAge");
- } else {
- wizard.setCard("beginGroupLength");
- }
- wizardFrame.pack();
- wizardFrame.setLocationRelativeTo(this);
- wizardFrame.setVisible(true);
- }
-
-}
-
-protected void setTableAgeLengthModel() {
- java.util.List<PopulationGroup> popGroup = getBean().getPopulationGroup();
- if (popGroup != null){
- DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1);
- model.setValueAt("Age", 0, 0);
- model.setValueAt("Lengths", 1, 0);
- int cnt = 1;
- for (PopulationGroup pg : popGroup){
- model.setValueAt(pg.getAge(), 0, cnt);
- model.setValueAt(pg.getLength(), 1, cnt);
- cnt++;
- }
- tableAgeLength.setModel(model);
- }
-}
-
-protected void create() {
- // find species node
- InputUI inputUI = getContextValue(InputUI.class, JAXXUtil.PARENT);
- Species species = inputUI.getHandler().findSpecies(inputUI);
- // create node and select it
- Population population = getContextValue(InputAction.class).createPopulation(getTopiaContext(), species);
- inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
- setInfoText(t("isisfish.message.creation.finished"));
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -176,7 +81,7 @@
</cell>
<cell fill='horizontal'>
<JButton id="buttonPopulationBasicsCreateClasses" text="isisfish.populationBasics.recreateClasses"
- onActionPerformed='createGroups()' enabled='{isActive()}' decorator='boxed'/>
+ onActionPerformed='handler.createGroups()' enabled='{isActive()}' decorator='boxed'/>
</cell>
<cell fill='horizontal'>
<JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup"
@@ -277,7 +182,7 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!validator.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,87 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationCapturabilityHandler extends InputContentHandler<PopulationCapturabilityUI> {
+
+ protected void init(final PopulationCapturabilityUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationCapturabilityUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationCapturabilityComment.setText("");
+ inputContentUI.fieldPopulationCapturability.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ if (inputContentUI.getBean().getCapturability() != null) {
+ inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy());
+ }
+ refreshHidablePanel();
+ }
+ }
+ });
+ }
+
+ protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getBean() != null && inputContentUI.fieldPopulationCapturability.getMatrix() != null) {
+ inputContentUI.getBean().setCapturability(inputContentUI.fieldPopulationCapturability.getMatrix().copy());
+ }
+ }
+
+ protected void useEquationChanged() {
+ inputContentUI.getBean().setCapturabilityEquationUsed(inputContentUI.fieldUseCapturabilityEquation.isSelected());
+
+ // compute matrix again to not diplay values computed by equation
+ if (!inputContentUI.fieldUseCapturabilityEquation.isSelected()) {
+ if (inputContentUI.getBean().getCapturability() != null) {
+ inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy());
+ }
+ }
+ refreshHidablePanel();
+ }
+
+ protected void refreshHidablePanel() {
+ if (inputContentUI.getBean() != null) {
+ if (inputContentUI.getBean().isCapturabilityEquationUsed()) {
+ inputContentUI.fieldUseCapturabilityEquation.setSelected(true);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation");
+ } else {
+ inputContentUI.fieldUseCapturabilityEquation.setSelected(false);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix");
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- java.awt.CardLayout
- </import>
+ <PopulationCapturabilityHandler id="handler" />
<BeanValidator id='validator' context="capturability"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -42,68 +35,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationCapturabilityComment.setText("");
- fieldPopulationCapturability.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- refreshHidablePanel();
- }
- }
- });
-}
-
-protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) {
- if (getBean() != null && fieldPopulationCapturability.getMatrix() != null) {
- getBean().setCapturability(fieldPopulationCapturability.getMatrix().copy());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null){
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- }
-}*/
-protected void useEquationChanged() {
- getBean().setCapturabilityEquationUsed(fieldUseCapturabilityEquation.isSelected());
-
- // compute matrix again to not diplay values computed by equation
- if (!fieldUseCapturabilityEquation.isSelected()) {
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- }
- refreshHidablePanel();
-}
-protected void refreshHidablePanel() {
- if (getBean() != null) {
- if (getBean().isCapturabilityEquationUsed()) {
- fieldUseCapturabilityEquation.setSelected(true);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation");
- }
- else {
- fieldUseCapturabilityEquation.setSelected(false);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix");
- }
- }
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -114,18 +50,18 @@
<row>
<cell columns='2' fill='horizontal' weightx='1.0' anchor='east'>
<JCheckBox id="fieldUseCapturabilityEquation" selected='{getBean().isCapturabilityEquationUsed()}'
- text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='useEquationChanged()'
+ text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='handler.useEquationChanged()'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.5'>
- <JPanel id="hidablePanel" layout='{new CardLayout()}'>
+ <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationCapturability'
matrix='{getBean().getCapturability() == null ? null : getBean().getCapturability().copy()}'
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"Capturability"'
- onMatrixChanged="populationCapturabilityMatrixChanged(event)"
+ onMatrixChanged="handler.populationCapturabilityMatrixChanged(event)"
constraints='"fieldUseMatrix"' />
<fr.ifremer.isisfish.ui.input.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
text='isisfish.common.capturability' active='{isActive()}'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationEquationHandler extends InputContentHandler<PopulationEquationUI> {
+
+ protected void init(final PopulationEquationUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,9 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationEquationHandler id="handler" />
<BeanValidator id='validator' context="equation"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -37,18 +35,11 @@
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationGroupHandler extends InputContentHandler<PopulationGroupUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationGroupHandler.class);
+
+ protected void init(final PopulationGroupUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>();
+
+ if (evt.getNewValue() == null) {
+ inputContentUI.setPopulationGroup(null);
+ }
+ if (evt.getNewValue() != null) {
+ groupModel.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+
+ inputContentUI.populationGroupPopulationGroupComboBox.setModel(groupModel);
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_POPULATION_GROUP, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationGroupMeanWeight.setText("");
+ inputContentUI.fieldPopulationGroupPrice.setText("");
+ inputContentUI.fieldPopulationGroupReproductionRate.setText("");
+ inputContentUI.fieldPopulationGroupMaturityOgive.setText("");
+ inputContentUI.fieldPopulationGroupAge.setText("");
+ inputContentUI.fieldPopulationGroupMinLength.setText("");
+ inputContentUI.fieldPopulationGroupMaxLength.setText("");
+ inputContentUI.fieldPopulationGroupComment.setText("");
+ inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void setNaturalDeathRateMatrix() {
+ try {
+ Population population = inputContentUI.getBean();
+ MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix();
+
+ // extract only line for this population group
+ MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, inputContentUI.getPopulationGroup());
+ inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy());
+ } catch (Exception e) {
+ // can happen if population has no zone yet
+ // TODO maybe display a message
+ if (log.isWarnEnabled()) {
+ log.warn("No zone defined for this population group", e);
+ }
+ }
+ }
+
+ /**
+ * Called on PopulationGroup combo box selection.
+ */
+ protected void populationGroupChanged() {
+ PopulationGroup selectedPopulationGroup = (PopulationGroup)inputContentUI.populationGroupPopulationGroupComboBox.getSelectedItem();
+ inputContentUI.setPopulationGroup(selectedPopulationGroup);
+ if (selectedPopulationGroup != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(selectedPopulationGroup);
+ setNaturalDeathRateMatrix();
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -39,14 +39,7 @@
<fr.ifremer.isisfish.entities.PopulationGroup id='populationGroup' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.Population
- org.nuiton.math.matrix.MatrixND
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationGroupHandler id="handler" />
<BeanValidator id='validator' context="group"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -63,78 +56,16 @@
valid="{validator.isValid() && validatorGroup.isValid()}" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
-
- GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>();
-
- if (evt.getNewValue() == null) {
- setPopulationGroup(null);
- }
- if (evt.getNewValue() != null) {
- groupModel.setElementList(getBean().getPopulationGroup());
- }
-
- populationGroupPopulationGroupComboBox.setModel(groupModel);
- }
- });
-
- addPropertyChangeListener(PROPERTY_POPULATION_GROUP, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationGroupMeanWeight.setText("");
- fieldPopulationGroupPrice.setText("");
- fieldPopulationGroupReproductionRate.setText("");
- fieldPopulationGroupMaturityOgive.setText("");
- fieldPopulationGroupAge.setText("");
- fieldPopulationGroupMinLength.setText("");
- fieldPopulationGroupMaxLength.setText("");
- fieldPopulationGroupComment.setText("");
- fieldPopulationGroupNaturalDeathRate.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void setNaturalDeathRateMatrix() {
- try {
- Population population = getBean();
- MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix();
-
- // extract only line for this population group
- MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, getPopulationGroup());
- fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy());
- } catch (Exception e) {
- // can happen if population has no zone yet
- // TODO maybe display a message
- if (log.isWarnEnabled()) {
- log.warn("No zone defined for this population group", e);
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-/**
- * Called on PopulationGroup combo box selection.
- */
-protected void populationGroupChanged() {
- PopulationGroup selectedPopulationGroup = (PopulationGroup)populationGroupPopulationGroupComboBox.getSelectedItem();
- setPopulationGroup(selectedPopulationGroup);
- if (selectedPopulationGroup != null) {
- getSaveVerifier().addCurrentEntity(selectedPopulationGroup);
- setNaturalDeathRateMatrix();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -144,7 +75,7 @@
<cell columns='2' fill='horizontal' weightx='1.0'>
<JComboBox id='populationGroupPopulationGroupComboBox'
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- onActionPerformed='populationGroupChanged()' enabled='{isActive()}'/>
+ onActionPerformed='handler.populationGroupChanged()' enabled='{isActive()}'/>
</cell>
</row>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationHandler extends InputContentHandler<PopulationUI> {
+
+ protected void init(final PopulationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueGears"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.gears"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.populationTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,122 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationEmigrationHandler extends InputContentHandler<PopulationMigrationEmigrationUI> {
+
+ protected void init(final PopulationMigrationEmigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationEmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationEmigrationCoefficient.setText("");
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(pi);
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy());
+ }
+
+ protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) {
+ inputContentUI.remove.setEnabled(inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow() != -1);
+ if (inputContentUI.popInfo != null) {
+ inputContentUI.popInfo.setMigrationMatrix(inputContentUI.populationMigrationEmigrationTable.getMatrix().clone());
+ }
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getContextValue(InputAction.class).addEmigration(inputContentUI.getPopInfo(),
+ (PopulationGroup)inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText()));
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 0);
+ Object arrival = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 1);
+
+ MatrixND mat = inputContentUI.popInfo.getEmigrationMatrix().clone();
+ mat.setValue(group, arrival, 0);
+ inputContentUI.popInfo.setEmigrationMatrix(mat);
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null
+ && inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -28,97 +28,14 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationEmigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationEmigrationCoefficient.setText("");
- populationMigrationEmigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-public void init(PopulationSeasonInfo pi){
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(pi);
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
-}
-
-protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) {
- remove.setEnabled(populationMigrationEmigrationTable.getTable().getSelectedRow() != -1);
- if (popInfo != null) {
- popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null) {
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationEmigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones);
-}
-protected void add() {
- getContextValue(InputAction.class).addEmigration(
- getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationEmigrationCoefficient.getText()));
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().clone());
-}
-
-protected void remove() {
- int row = populationMigrationEmigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationEmigrationTable.getTable().getValueAt(row, 0);
- Object arrival = populationMigrationEmigrationTable.getTable().getValueAt(row, 1);
-
- MatrixND mat = popInfo.getEmigrationMatrix().clone();
- mat.setValue(group, arrival, 0);
- popInfo.setEmigrationMatrix(mat);
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
- }
-}
-protected void setAddButton() {
- add.setEnabled(isActive()
- && fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null
- && fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null
- && !fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
-}
-]]></script>
<JPanel id="body">
<Table>
<row>
@@ -128,13 +45,13 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationEmigrationGroupChooser"
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
+ enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
+ <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/>
</cell>
</row>
<row>
@@ -144,7 +61,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser"
genericType="fr.ifremer.isisfish.entities.Zone"
- enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
+ enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
@@ -152,7 +69,7 @@
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='false'/>
</cell>
</row>
@@ -160,13 +77,13 @@
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationEmigrationTable'
linearModel="true" enabled='{isActive()}'
- onMatrixChanged="populationMigrationEmigrationMatrixChanged(event)"/>
+ onMatrixChanged="handler.populationMigrationEmigrationMatrixChanged(event)"/>
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}'/>
+ onActionPerformed='handler.remove()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationEquationHandler extends InputContentHandler<PopulationMigrationEquationUI> {
+
+ protected void init(final PopulationMigrationEquationUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,24 +29,20 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationMigrationEquationHandler id="handler" />
<script><![CDATA[
-public void init(PopulationSeasonInfo populationSeasonInfo) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(populationSeasonInfo);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ /*public void init(PopulationSeasonInfo populationSeasonInfo) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(populationSeasonInfo);
+ }*/
+ ]]></script>
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(immigrationEquation, emigrationEquation, migrationEquation);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,115 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationHandler extends InputContentHandler<PopulationMigrationUI> {
+
+ protected void init(final PopulationMigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationComment.setText("");
+ inputContentUI.fieldUseEquationMigration.setSelected(false);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ refresh();
+ }
+ });
+ }
+
+ public void refresh() {
+ //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(population);
+
+ // refresh psi list in combo box
+ GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel();
+ if (inputContentUI.getBean() != null) {
+ PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem();
+ model.setElementList(inputContentUI.getBean().getPopulationSeasonInfo());
+
+ // do this to keep selected after cancel/refresh
+ if (previousSelected != null) {
+ for (PopulationSeasonInfo psi : inputContentUI.getBean().getPopulationSeasonInfo()) {
+ if (psi.getTopiaId().equals(previousSelected.getTopiaId())) {
+ model.setSelectedItem(psi);
+ }
+ }
+ }
+
+ seasonChanged();
+ } else {
+ model.setElementList(null);
+ }
+ }
+
+ protected void seasonChanged() {
+ GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel();
+ PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem();
+ inputContentUI.setPopInfo(selectedPSI);
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationEquationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationMigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationImmigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationEmigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ }
+ refreshHidablePanel();
+ }
+
+ protected void useEquationChanged() {
+ inputContentUI.getPopInfo().setUseEquationMigration(inputContentUI.fieldUseEquationMigration.isSelected());
+ refreshHidablePanel();
+ }
+
+ protected void refreshHidablePanel() {
+ if (inputContentUI.getPopInfo() != null) {
+ if (inputContentUI.getPopInfo().isUseEquationMigration()) {
+ inputContentUI.fieldUseEquationMigration.setSelected(true);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation");
+ } else {
+ inputContentUI.fieldUseEquationMigration.setSelected(false);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix");
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,121 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationImmigrationHandler extends InputContentHandler<PopulationMigrationImmigrationUI> {
+
+ protected void init(final PopulationMigrationImmigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationImmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationImmigrationCoefficient.setText("");
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getPopInfo().setImmigrationMatrix(inputContentUI.populationMigrationImmigrationTable.getMatrix().clone());
+ }
+ }
+
+ public void init(PopulationSeasonInfo populationSeasonInfo) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(populationSeasonInfo);
+
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy());
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getContextValue(InputAction.class).addImmigration(inputContentUI.getPopInfo(),
+ (PopulationGroup)inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText()));
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationImmigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 0);
+ Object departure = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 1);
+
+ MatrixND mat = inputContentUI.getPopInfo().getImmigrationMatrix().clone();
+ mat.setValue(group, departure, 0);
+ inputContentUI.getPopInfo().setImmigrationMatrix(mat);
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText().equals("")
+ && inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -28,97 +28,14 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationImmigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationImmigrationCoefficient.setText("");
- populationMigrationImmigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) {
- if (getPopInfo() != null){
- getPopInfo().setImmigrationMatrix(populationMigrationImmigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-public void init(PopulationSeasonInfo populationSeasonInfo) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(populationSeasonInfo);
-
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
-}
-
-protected void setFieldPopulationMigrationMigrationGroupChooserModel(){
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null){
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationImmigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones);
-}
-protected void add() {
- getContextValue(InputAction.class).addImmigration(getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationImmigrationCoefficient.getText()));
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().clone());
-}
-protected void remove() {
- int row = populationMigrationImmigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationImmigrationTable.getTable().getValueAt(row, 0);
- Object departure = populationMigrationImmigrationTable.getTable().getValueAt(row, 1);
-
- MatrixND mat = getPopInfo().getImmigrationMatrix().clone();
- mat.setValue(group, departure, 0);
- getPopInfo().setImmigrationMatrix(mat);
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
- }
-}
-
-protected void setAddButton() {
- add.setEnabled(isActive() &&
- fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null &&
- !fieldPopulationMigrationImmigrationCoefficient.getText().equals("") &&
- fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null
- );
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -128,13 +45,13 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationImmigrationGroupChooser"
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- enabled='{isActive()}' onActionPerformed='setAddButton()'/>
+ enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
+ <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/>
</cell>
</row>
<row>
@@ -144,7 +61,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser"
genericType="fr.ifremer.isisfish.entities.Zone"
- enabled='{isActive()}' onActionPerformed='setAddButton()'/>
+ enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
@@ -152,7 +69,7 @@
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='false'/>
</cell>
</row>
@@ -160,13 +77,13 @@
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationImmigrationTable'
linearModel="true" enabled='{isActive()}'
- onMatrixChanged="populationMigrationImmigrationMatrixChanged(event)"/>
+ onMatrixChanged="handler.populationMigrationImmigrationMatrixChanged(event)"/>
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}'/>
+ onActionPerformed='handler.remove()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,132 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationMigrationHandler extends InputContentHandler<PopulationMigrationMigrationUI> {
+
+ protected void init(final PopulationMigrationMigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationMigrationCoefficient.setText("");
+ inputContentUI.populationMigrationMigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getPopInfo().setMigrationMatrix(inputContentUI.populationMigrationMigrationTable.getMatrix().clone());
+ }
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(pi);
+
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy());
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones);
+ }
+
+ protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getAction().addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText()));
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationMigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 0);
+ Object departure = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 1);
+ Object arrival = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 2);
+
+ MatrixND mat = inputContentUI.getPopInfo().getMigrationMatrix().clone();
+ mat.setValue(group, departure, arrival, 0);
+ inputContentUI.getPopInfo().setMigrationMatrix(mat);
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText().equals("")
+ && inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null
+ && inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -33,107 +33,14 @@
<Boolean id='zoneArrivalSelected' javaBean='false'/>
<Boolean id='coefNonVide' javaBean='false'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- javax.swing.text.Document
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationMigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationMigrationCoefficient.setText("");
- populationMigrationMigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) {
- if (getPopInfo() != null) {
- getPopInfo().setMigrationMatrix(populationMigrationMigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-public void init(PopulationSeasonInfo pi) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(pi);
+ ]]></script>
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
-}
-
-protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null){
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationMigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones);
-}
-protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones);
-}
-protected void add() {
- getAction().addMigration(getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationMigrationCoefficient.getText()));
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().clone());
-}
-protected void remove() {
- int row = populationMigrationMigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationMigrationTable.getTable().getValueAt(row, 0);
- Object departure = populationMigrationMigrationTable.getTable().getValueAt(row, 1);
- Object arrival = populationMigrationMigrationTable.getTable().getValueAt(row, 2);
-
- MatrixND mat = getPopInfo().getMigrationMatrix().clone();
- mat.setValue(group, departure, arrival, 0);
- getPopInfo().setMigrationMatrix(mat);
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
- }
-}
-protected void setAddButton() {
- add.setEnabled(isActive() &&
- fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null &&
- !fieldPopulationMigrationMigrationCoefficient.getText().equals("") &&
- fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null &&
- fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null);
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -142,16 +49,17 @@
</cell>
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}'
- onItemStateChanged="setAddButton()"/>
+ genericType="fr.ifremer.isisfish.entities.PopulationGroup"
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActive()}'/>
- <Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()"
- onInsertUpdate='setAddButton()'
- onRemoveUpdate='setAddButton()' />
+ <javax.swing.text.Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()"
+ onInsertUpdate='handler.setAddButton()'
+ onRemoveUpdate='handler.setAddButton()' />
</cell>
</row>
<row>
@@ -161,7 +69,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Zone"
- onItemStateChanged="setAddButton()"/>
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActive()}'/>
@@ -169,25 +77,25 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Zone"
- onItemStateChanged="setAddButton()"/>
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='false'/>
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='false'/>
</cell>
</row>
<row columns='4'>
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationMigrationTable'
linearModel='{true}' enabled='{isActive()}'
- onMatrixChanged="populationMigrationMigrationMatrixChanged(event)" />
+ onMatrixChanged="handler.populationMigrationMigrationMatrixChanged(event)" />
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}' />
+ onActionPerformed='handler.remove()' enabled='{isActive()}' />
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -29,16 +29,7 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Population;
- fr.ifremer.isisfish.ui.models.common.GenericComboModel;
- fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- java.awt.CardLayout
- </import>
+ <PopulationMigrationHandler id="handler" />
<BeanValidator id='validator' context="migration"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -54,92 +45,22 @@
valid="{validator.isValid() && validatorSeason.isValid()}" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationComment.setText("");
- fieldUseEquationMigration.setSelected(false);
- }
- if (evt.getNewValue() != null) {
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- }
- refresh();
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(population);
-
- // refresh psi list in combo box
- GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel();
- if (getBean() != null) {
- PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem();
- model.setElementList(getBean().getPopulationSeasonInfo());
-
- // do this to keep selected after cancel/refresh
- if (previousSelected != null) {
- for (PopulationSeasonInfo psi : getBean().getPopulationSeasonInfo()) {
- if (psi.getTopiaId().equals(previousSelected.getTopiaId())) {
- model.setSelectedItem(psi);
- }
- }
- }
-
- seasonChanged();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
- else {
- model.setElementList(null);
- }
-}
-protected void seasonChanged() {
- GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel();
- PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem();
- setPopInfo(selectedPSI);
- if (getPopInfo() != null) {
- getSaveVerifier().addCurrentEntity(getPopInfo());
- populationMigrationEquationUI.init(getPopInfo());
- populationMigrationMigrationUI.init(getPopInfo());
- populationMigrationImmigrationUI.init(getPopInfo());
- populationMigrationEmigrationUI.init(getPopInfo());
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationMigrationEquationUI.setLayer(active);
}
- refreshHidablePanel();
-}
-protected void useEquationChanged() {
- getPopInfo().setUseEquationMigration(fieldUseEquationMigration.isSelected());
- refreshHidablePanel();
-}
-protected void refreshHidablePanel() {
- if (getPopInfo() != null) {
- if (getPopInfo().isUseEquationMigration()) {
- fieldUseEquationMigration.setSelected(true);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation");
- }
- else {
- fieldUseEquationMigration.setSelected(false);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix");
- }
- }
-}
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationMigrationEquationUI.setLayer(active);
-}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
@@ -149,22 +70,22 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldPopulationMigrationSeasonChooser"
genericType="PopulationSeasonInfo"
- model='{new GenericComboModel<PopulationSeasonInfo>()}'
+ model='{new fr.ifremer.isisfish.ui.models.common.GenericComboModel<PopulationSeasonInfo>()}'
renderer="{new PopulationSeasonInfoComboRenderer()}"
- onActionPerformed='seasonChanged()'
+ onActionPerformed='handler.seasonChanged()'
enabled='{isActive()}'/>
</cell>
</row>
<row>
<cell columns='2' anchor='west'>
<JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().isUseEquationMigration()}'
- text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()'
+ text="isisfish.populationMigration.useEquation" onActionPerformed='handler.useEquationChanged()'
enabled='{getPopInfo() != null}' decorator='boxed'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.7'>
- <JPanel id="hidablePanel" layout='{new CardLayout()}'>
+ <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'>
<JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"' enabled='{getPopInfo() != null}'>
<tab title='{t("isisfish.populationMigrationMigration.title")}'>
<PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='this' decorator='boxed'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationPriceHandler extends InputContentHandler<PopulationPriceUI> {
+
+ protected void init(final PopulationPriceUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,9 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationPriceHandler id="handler" />
<BeanValidator id='validator' context="equation"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -37,18 +35,11 @@
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,61 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationRecruitmentHandler extends InputContentHandler<PopulationRecruitmentUI> {
+
+ protected void init(final PopulationRecruitmentUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationRecruitmentUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMonthGapBetweenReproRecrutement.setText("");
+ inputContentUI.fieldPopulationRecruitmentComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getBean() != null){
+ if (inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix() != null){
+ inputContentUI.getBean().setRecruitmentDistribution(inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix().copy());
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,13 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- org.nuiton.math.matrix.gui.MatrixPanelEvent;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- org.nuiton.math.matrix.gui.MatrixPanelListener;
- </import>
+ <PopulationRecruitmentHandler id="handler" />
<BeanValidator id='validator' context="recruitement"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -41,48 +35,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMonthGapBetweenReproRecrutement.setText("");
- fieldPopulationRecruitmentComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) {
- if (getBean() != null){
- if (fieldPopulationRecruitmentDistribution.getMatrix() != null){
- getBean().setRecruitmentDistribution(fieldPopulationRecruitmentDistribution.getMatrix().copy());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null && getBean().getRecruitmentDistribution() != null) {
- fieldPopulationRecruitmentDistribution.setMatrix(getBean().getRecruitmentDistribution().copy());
-
- // chatellier : number editor is not working
- //fieldPopulationMonthGapBetweenReproRecrutement.init();
- }
-
- // TODO add only once
- //fieldPopulationRecruitmentDistribution.addMatrixListener(listener);
-}*/
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -119,7 +76,7 @@
<org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationRecruitmentDistribution'
matrix='{getBean() == null ? null : bean.getRecruitmentDistribution().copy()}'
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"RecruitmentDistribution"'
- onMatrixChanged="populationRecruitmentDistributionMatrixChanged(event)" />
+ onMatrixChanged="handler.populationRecruitmentDistributionMatrixChanged(event)" />
</cell>
<cell>
<JButton icon="table.png" toolTipText="isisfish.common.newMatrix"
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+
+/**
+ * Renderer pour la combo des {@link PopulationSeasonInfo}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class PopulationSeasonInfoComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ PopulationSeasonInfo populationSeasonInfo = (PopulationSeasonInfo) value;
+
+ // there is no default selection
+ if (value != null) {
+ c.setText(populationSeasonInfo.getFirstMonth() + " - " + populationSeasonInfo.getLastMonth());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,105 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.t;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEditor;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+
+/**
+ * Population handler.
+ */
+public class PopulationSeasonSpacializedHandler extends InputContentHandler<PopulationSeasonSpacializedUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class);
+
+ protected void init(final PopulationSeasonSpacializedUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix() != null) {
+ // must be a copy for fire event
+ MatrixND lengthChangeMatrix = inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix().copy();
+ inputContentUI.getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix);
+ }
+ }
+
+ /**
+ * Called on spacialized radio button change.
+ */
+ protected void spacializedActionPerformed() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ boolean spacializedSelection = inputContentUI.radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected();
+ popInfo.setSimpleLengthChangeMatrix(spacializedSelection);
+ try {
+ MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
+ if (lengthChangeMatrix != null) {
+ if (popInfo.isSimpleLengthChangeMatrix()) {
+ lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix);
+ } else {
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ popInfo.setLengthChangeMatrix(lengthChangeMatrix);
+ inputContentUI.matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix);
+ }
+ } catch(Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't (un)spacialize Matrix Change Of Group", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee);
+ }
+ }
+
+ protected void computeMatrixChangeOfGroup() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix();
+ if (!popInfo.isSimpleLengthChangeMatrix()){
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ popInfo.setLengthChangeMatrix(lengthChangeMatrix);
+ }
+
+ protected void showSpacializedMatrixChangeOfGroup() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
+ if (popInfo.isSimpleLengthChangeMatrix()) {
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300);
+ panel.setMatrix(lengthChangeMatrix);
+ JOptionPane.showMessageDialog(inputContentUI, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,76 +31,12 @@
<Boolean id='ageGroupType' javaBean='false'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.ui.util.ErrorHelper;
- org.nuiton.math.matrix.MatrixND;
- org.nuiton.math.matrix.gui.MatrixPanelEditor;
- org.nuiton.math.matrix.gui.MatrixPanelEvent;
- org.nuiton.math.matrix.gui.MatrixPanelListener;
- javax.swing.JOptionPane
- </import>
+ <PopulationSeasonSpacializedHandler id="handler" />
<script><![CDATA[
-protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) {
- if (getPopulationSeasonInfo() != null && matrixPanelPopulationSeasonLengthChange.getMatrix() != null) {
- // must be a copy for fire event
- MatrixND lengthChangeMatrix = matrixPanelPopulationSeasonLengthChange.getMatrix().copy();
- getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-/*public void refresh() {
- // TODO add only once
- //matrixPanelPopulationSeasonLengthChange.addMatrixListener(matrixPanelListener);
-}*/
-
-/**
- * Called on spacialized radio button change.
- */
-protected void spacializedActionPerformed() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- boolean spacializedSelection = radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected();
- popInfo.setSimpleLengthChangeMatrix(spacializedSelection);
- try {
- MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
- if (lengthChangeMatrix != null) {
- if (popInfo.isSimpleLengthChangeMatrix()) {
- lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix);
- } else {
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- popInfo.setLengthChangeMatrix(lengthChangeMatrix);
- matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix);
- }
- } catch(Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't (un)spacialize Matrix Change Of Group", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee);
- }
-}
-
-protected void computeMatrixChangeOfGroup() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix();
- if (!popInfo.isSimpleLengthChangeMatrix()){
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- popInfo.setLengthChangeMatrix(lengthChangeMatrix);
-}
-
-protected void showSpacializedMatrixChangeOfGroup() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
- if (popInfo.isSimpleLengthChangeMatrix()) {
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300);
- panel.setMatrix(lengthChangeMatrix);
- JOptionPane.showMessageDialog(this, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE);
-}
]]></script>
<JPanel id='body'>
@@ -114,7 +50,7 @@
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
selected='{getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
- text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()'
+ text="isisfish.populationSeasons.noSpacialized" onActionPerformed='handler.spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='0.5'>
@@ -122,7 +58,7 @@
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
selected='{!getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
- text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()'
+ text="isisfish.populationSeasons.spacialized" onActionPerformed='handler.spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
</cell>
</row>
@@ -133,12 +69,12 @@
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton text="isisfish.populationSeasons.computeCoefficient" decorator='boxed' visible='{isAgeGroupType()}'
- enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='computeMatrixChangeOfGroup()'/>
+ enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='handler.computeMatrixChangeOfGroup()'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id="buttonPopulationSeasonGroupChangeLengthButtonShow" text="isisfish.populationSeasons.showSpacialized"
enabled='{radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected() && getPopulationSeasonInfo() != null}'
- onActionPerformed='showSpacializedMatrixChangeOfGroup()'
+ onActionPerformed='handler.showSpacializedMatrixChangeOfGroup()'
visible='{isAgeGroupType()}' decorator='boxed'/>
</cell>
</row>
@@ -152,7 +88,7 @@
_sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"LengthChangeMatrix"'
visible='{isAgeGroupType()}' decorator='boxed'
matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix().copy()}'
- onMatrixChanged="populationSeasonLengthMatrixChanged(event)" />
+ onMatrixChanged="handler.populationSeasonLengthMatrixChanged(event)" />
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,234 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.Interval;
+
+/**
+ * Population handler.
+ */
+public class PopulationSeasonsHandler extends InputContentHandler<PopulationSeasonsUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class);
+
+ protected Interval seasonInterval;
+
+ protected boolean init = false;
+
+ protected void init(final PopulationSeasonsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationSeasonsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationSeasonComment.setText("");
+ inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+
+ /*
+ * Don't add both in same listener.
+ * When first is set, last value from getPopulationSeasonInfo()
+ * is erased by interval.getLast() default value.
+ */
+ inputContentUI.seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst()));
+ setReproductionDistributionMatrix();
+ }
+ }
+ });
+ inputContentUI.seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast()));
+ setReproductionDistributionMatrix();
+ }
+ }
+ });
+ }
+
+ protected void create() {
+ PopulationSeasonInfo seasonNew = inputContentUI.getContextValue(InputAction.class).createPopulationSeasonInfo(inputContentUI.getBean());
+ inputContentUI.setPopulationSeasonInfo(seasonNew);
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void delete() {
+ inputContentUI.getContextValue(InputAction.class).removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
+ inputContentUI.setPopulationSeasonInfo(null);
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void save() {
+ inputContentUI.getSaveVerifier().save();
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix() != null) {
+ MatrixND reproductionDistribution = inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix().copy();
+ if (log.isDebugEnabled()) {
+ log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution);
+ }
+ inputContentUI.getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution);
+ }
+ }
+
+ public void refresh() {
+ //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(population);
+
+ inputContentUI.setPopulationSeasonInfo(null);
+
+ // Model instanciation
+ seasonInterval = new Interval();
+ seasonInterval.setMin(0);
+ seasonInterval.setMax(11);
+ seasonInterval.setFirst(0);
+ seasonInterval.setLast(2);
+
+ setPopulationSeasonInfoCombo();
+ setSeasonInterval();
+
+ inputContentUI.seasonIntervalPanel.setLabelRenderer(Month.MONTH);
+ inputContentUI.seasonIntervalPanel.setModel(seasonInterval);
+
+ //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener);
+
+ /*if(getPopulationSeasonInfo() != null) {
+ PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
+ setPopulationSeasonInfo(null);
+ setPopulationSeasonInfo(popInfo);
+ getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo());
+ }*/
+ //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI);
+ }
+
+ protected void setSeasonInterval() {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Updating interval : ");
+ }
+ Month firstMonth = inputContentUI.getPopulationSeasonInfo().getFirstMonth();
+
+ if (firstMonth != null) {
+ seasonInterval.setFirst(firstMonth.getMonthNumber());
+
+ if (log.isDebugEnabled()) {
+ log.debug(" first : " + seasonInterval.getFirst());
+ }
+ } else {
+ seasonInterval.setFirst(0);
+ }
+
+ Month lastMonth = inputContentUI.getPopulationSeasonInfo().getLastMonth();
+ if (lastMonth != null) {
+ seasonInterval.setLast(lastMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" last : " + seasonInterval.getLast());
+ }
+ } else {
+ seasonInterval.setLast(3);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't display interval", e);
+ }
+ }
+ }
+ }
+
+ protected void setPopulationSeasonInfoCombo() {
+ if (inputContentUI.getBean() != null) {
+ GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(inputContentUI.getBean().getPopulationSeasonInfo());
+ inputContentUI.fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel);
+ populationSeasonInfoModel.setSelectedItem(inputContentUI.getPopulationSeasonInfo());
+ }
+ }
+
+ protected void seasonGroupChanged() {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setGroupChange(inputContentUI.fieldPopulationSeasonGroupChange.isSelected());
+ }
+ }
+
+ protected void seasonChanged() {
+ init = true;
+ PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)inputContentUI.fieldPopulationSeasonInfoChooser.getSelectedItem();
+ if (log.isDebugEnabled()) {
+ log.debug("Season changed : " + seasonInfoSelected);
+ }
+ inputContentUI.setPopulationSeasonInfo(seasonInfoSelected);
+ if (seasonInfoSelected != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(seasonInfoSelected);
+ }
+ setSeasonInterval();
+ setReproductionDistributionMatrix();
+ init = false;
+ }
+
+ protected void setReproductionDistributionMatrix() {
+ if (inputContentUI.getPopulationSeasonInfo() != null){
+ MatrixND reproductionDistribution = inputContentUI.getPopulationSeasonInfo().getReproductionDistribution();
+ // must be a copy (otherwise, modify current entity matrix)
+ if (reproductionDistribution != null){
+ inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy());
+ }
+ }
+ }
+
+ // TODO une methode isXXX ne prend pas de parametre
+ // et ne fait rien
+ protected boolean isAgeGroupType(boolean result) {
+ inputContentUI.populationSeasonSpecializedUI.setVisible(result);
+ return result;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,19 +29,7 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='populationSeasonInfo' javaBean='null'/>
- <import>
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.types.Month
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.ui.widget.Interval
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <PopulationSeasonsHandler id="handler" />
<BeanValidator id='validator' context="seasons"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -58,202 +46,22 @@
valid="{validator.isValid() && validatorSeason.isValid()}" />
<script><![CDATA[
-protected Interval seasonInterval;
-
-protected boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationSeasonComment.setText("");
- fieldPopulationSeasonReproductionDistribution.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
-
- /*
- * Don't add both in same listener.
- * When first is set, last value from getPopulationSeasonInfo()
- * is erased by interval.getLast() default value.
- */
- seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst()));
- setReproductionDistributionMatrix();
- }
- }
- });
- seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast()));
- setReproductionDistributionMatrix();
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void create() {
- PopulationSeasonInfo seasonNew = getContextValue(InputAction.class).createPopulationSeasonInfo(getBean());
- setPopulationSeasonInfo(seasonNew);
- setPopulationSeasonInfoCombo();
-}
-
-protected void delete() {
- getContextValue(InputAction.class).removePopulationSeasonInfo(getBean(), getPopulationSeasonInfo());
- setPopulationSeasonInfo(null);
- setPopulationSeasonInfoCombo();
-}
-
-protected void save() {
- getSaveVerifier().save();
- setPopulationSeasonInfoCombo();
-}
-
-protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) {
- if (getPopulationSeasonInfo() != null && fieldPopulationSeasonReproductionDistribution.getMatrix() != null) {
- MatrixND reproductionDistribution = fieldPopulationSeasonReproductionDistribution.getMatrix().copy();
- if (log.isDebugEnabled()) {
- log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution);
- }
- getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(population);
-
- setPopulationSeasonInfo(null);
-
- // Model instanciation
- seasonInterval = new Interval();
- seasonInterval.setMin(0);
- seasonInterval.setMax(11);
- seasonInterval.setFirst(0);
- seasonInterval.setLast(2);
-
- setPopulationSeasonInfoCombo();
- setSeasonInterval();
-
- seasonIntervalPanel.setLabelRenderer(Month.MONTH);
- seasonIntervalPanel.setModel(seasonInterval);
-
- //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener);
-
- /*if(getPopulationSeasonInfo() != null) {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- setPopulationSeasonInfo(null);
- setPopulationSeasonInfo(popInfo);
- getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo());
- }*/
- //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI);
-}
-
-protected void setSeasonInterval() {
- if(getPopulationSeasonInfo() != null) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Updating interval : ");
- }
- Month firstMonth = getPopulationSeasonInfo().getFirstMonth();
-
- if (firstMonth != null) {
- seasonInterval.setFirst(firstMonth.getMonthNumber());
-
- if (log.isDebugEnabled()) {
- log.debug(" first : " + seasonInterval.getFirst());
- }
- } else {
- seasonInterval.setFirst(0);
- }
-
- Month lastMonth = getPopulationSeasonInfo().getLastMonth();
- if (lastMonth != null) {
- seasonInterval.setLast(lastMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" last : " + seasonInterval.getLast());
- }
- } else {
- seasonInterval.setLast(3);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't display interval", e);
- }
- }
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
-protected void setPopulationSeasonInfoCombo() {
- if (getBean() != null) {
- GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(getBean().getPopulationSeasonInfo());
- fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel);
- populationSeasonInfoModel.setSelectedItem(getPopulationSeasonInfo());
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationSeasonSpecializedUI.setLayer(active);
}
-}
+ ]]></script>
-protected void seasonGroupChanged() {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setGroupChange(fieldPopulationSeasonGroupChange.isSelected());
- }
-}
-
-protected void seasonChanged() {
- init = true;
- PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)fieldPopulationSeasonInfoChooser.getSelectedItem();
- if (log.isDebugEnabled()) {
- log.debug("Season changed : " + seasonInfoSelected);
- }
- setPopulationSeasonInfo(seasonInfoSelected);
- if (seasonInfoSelected != null) {
- getSaveVerifier().addCurrentEntity(seasonInfoSelected);
- }
- setSeasonInterval();
- setReproductionDistributionMatrix();
- init = false;
-}
-
-protected void setReproductionDistributionMatrix() {
- if (getPopulationSeasonInfo() != null){
- MatrixND reproductionDistribution = getPopulationSeasonInfo().getReproductionDistribution();
- // must be a copy (otherwise, modify current entity matrix)
- if (reproductionDistribution != null){
- fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy());
- }
- }
-}
-
-// TODO une methode isXXX ne prend pas de parametre
-// et ne fait rien
-protected boolean isAgeGroupType(boolean result) {
- populationSeasonSpecializedUI.setVisible(result);
- return result;
-}
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationSeasonSpecializedUI.setLayer(active);
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -266,8 +74,8 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldPopulationSeasonInfoChooser"
genericType="PopulationSeasonInfo"
- onItemStateChanged='seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer()}"/>
+ onItemStateChanged='handler.seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
+ renderer="{new PopulationSeasonInfoComboRenderer()}"/>
</cell>
</row>
<row>
@@ -284,16 +92,18 @@
<JPanel/>
</cell>
<cell fill='both' weightx='1.0'>
- <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().isGroupChange()}'
+ <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup"
+ selected='{getPopulationSeasonInfo().isGroupChange()}'
decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"GroupChange"'
- onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
+ onActionPerformed='handler.seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}'
+ visible='{handler.isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.6'>
<PopulationSeasonSpacializedUI id='populationSeasonSpecializedUI' constructorParams='this' bean='{getBean()}'
populationSeasonInfo='{getPopulationSeasonInfo()}'
- ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
+ ageGroupType='{handler.isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
@@ -317,7 +127,7 @@
enabled='{getPopulationSeasonInfo() != null}'
visible='{getPopulationSeasonInfo().isReproduction()}'
decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"ReproductionDistribution"'
- onMatrixChanged="populationSeasonReproductionDistributionMatrixChanged(event)" />
+ onMatrixChanged="handler.populationSeasonReproductionDistributionMatrixChanged(event)" />
</cell>
</row>
<row>
@@ -344,7 +154,7 @@
<JButton id='save' decorator='boxed'
text="isisfish.common.save"
enabled="{changeModel.isValid() && changeModel.isChanged()}"
- onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
+ onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='cancel' decorator='boxed'
@@ -358,13 +168,13 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!changeModel.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
text="isisfish.common.remove"
enabled="{getPopulationSeasonInfo() != null}"
- onActionPerformed="delete()"/>
+ onActionPerformed="handler.delete()"/>
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,51 +27,43 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <PopulationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueGears"));
- setNextPath(n("isisfish.input.tree.gears"));
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(populationTab);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationBasicsUI.setLayer(active);
- populationZoneUI.setLayer(active);
- populationSeasonsUI.setLayer(active);
- populationEquationUI.setLayer(active);
- populationRecruitementUI.setLayer(active);
- populationGroupUI.setLayer(active);
- populationCapturabilityUI.setLayer(active);
- populationMigrationUI.setLayer(active);
- populationPriceUI.setLayer(active);
- variablesUI.setLayer(active);
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationBasicsUI.setLayer(active);
+ populationZoneUI.setLayer(active);
+ populationSeasonsUI.setLayer(active);
+ populationEquationUI.setLayer(active);
+ populationRecruitementUI.setLayer(active);
+ populationGroupUI.setLayer(active);
+ populationCapturabilityUI.setLayer(active);
+ populationMigrationUI.setLayer(active);
+ populationPriceUI.setLayer(active);
+ variablesUI.setLayer(active);
+ }
-@Override
-public void resetChangeModel() {
- populationBasicsUI.resetChangeModel();
- populationZoneUI.resetChangeModel();
- populationSeasonsUI.resetChangeModel();
- populationEquationUI.resetChangeModel();
- populationRecruitementUI.resetChangeModel();
- populationGroupUI.resetChangeModel();
- populationCapturabilityUI.resetChangeModel();
- populationMigrationUI.resetChangeModel();
- populationPriceUI.resetChangeModel();
- variablesUI.resetChangeModel();
-}
- ]]>
- </script>
+ @Override
+ public void resetChangeModel() {
+ populationBasicsUI.resetChangeModel();
+ populationZoneUI.resetChangeModel();
+ populationSeasonsUI.resetChangeModel();
+ populationEquationUI.resetChangeModel();
+ populationRecruitementUI.resetChangeModel();
+ populationGroupUI.resetChangeModel();
+ populationCapturabilityUI.resetChangeModel();
+ populationMigrationUI.resetChangeModel();
+ populationPriceUI.resetChangeModel();
+ variablesUI.resetChangeModel();
+ }
+ ]]></script>
+
<JPanel id='body'>
<JTabbedPane id="populationTab">
<!-- Saisie des populations -->
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,145 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JList;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationZonesEditorHandler extends InputContentHandler<PopulationZonesEditorUI> {
+
+ protected boolean init = false;
+
+ protected void init(final PopulationZonesEditorUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationZonesEditorUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ setPopulationZonesPresenceModel();
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ setPopulationZonesPresenceModel();
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) {
+ inputContentUI.getBean().setMappingZoneReproZoneRecru(inputContentUI.fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone());
+ }
+
+ protected void setFieldPopulationMappingZoneReproZoneRecru() {
+ if (inputContentUI.getBean() != null) {
+ if (inputContentUI.getBean().getMappingZoneReproZoneRecru() != null) {
+ inputContentUI.fieldPopulationMappingZoneReproZoneRecru.setMatrix(inputContentUI.getBean().getMappingZoneReproZoneRecru().copy());
+ }
+ }
+ }
+ protected void setPopulationZonesPresenceModel() {
+ if (inputContentUI.getBean() != null) {
+ List<Zone> zones = inputContentUI.getFisheryRegion().getZone();
+ setModel(zones, inputContentUI.getBean().getPopulationZone(), inputContentUI.populationZonesPresence);
+ }
+ }
+ protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) {
+ if (inputContentUI.getBean() != null) {
+ setModel(zones, inputContentUI.getBean().getReproductionZone(), inputContentUI.fieldPopulationZonesReproduction);
+ }
+ }
+ protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) {
+ if (inputContentUI.getBean() != null) {
+ setModel(zones, inputContentUI.getBean().getRecruitmentZone(), inputContentUI.fieldPopulationZonesRecruitment);
+ }
+ }
+
+ /**
+ * Change model of {@code associatedList} with all available zones, but keep
+ * selection with {@code selectedZones}.
+ */
+ protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) {
+ GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones);
+ associatedList.setModel(zoneModel);
+
+ // can be null at population init
+ if (selectedZones != null) {
+ for (Zone selectedZone : selectedZones) {
+ int index = availableZones.indexOf(selectedZone);
+ associatedList.addSelectionInterval(index, index);
+ }
+ }
+ }
+
+ protected void presenceChanged() {
+ if (!init) {
+ inputContentUI.getBean().setPopulationZone(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ protected void reproductionChanged() {
+ if (!init) {
+ inputContentUI.getBean().setReproductionZone(getSelectedValues(inputContentUI.fieldPopulationZonesReproduction));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ protected void recruitementChanged() {
+ if (!init) {
+ inputContentUI.getBean().setRecruitmentZone(getSelectedValues(inputContentUI.fieldPopulationZonesRecruitment));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ /**
+ * Get selected values for components as list.
+ */
+ protected List<Zone> getSelectedValues(JList<Zone> component) {
+ List<Zone> selectedValues = component.getSelectedValuesList();
+ List<Zone> selectedZone = new ArrayList<>(selectedValues);
+ return selectedZone;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,129 +27,18 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
+ <PopulationZonesEditorHandler id="handler" />
+
<import>
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.List
- java.util.ArrayList
java.awt.Dimension
</import>
<script><![CDATA[
-protected boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
- if (evt.getNewValue() != null) {
- init = true;
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- init = false;
- }
- }
- });
-}
-
-protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) {
- getBean().setMappingZoneReproZoneRecru(fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone());
-}
-
-/*public void refresh() {
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- //fieldPopulationMappingZoneReproZoneRecru.removeMatrixPanelListener(listener);
- setFieldPopulationMappingZoneReproZoneRecru();
- //fieldPopulationMappingZoneReproZoneRecru.addMatrixListener(listener);
-}*/
-
-protected void setFieldPopulationMappingZoneReproZoneRecru() {
- if (getBean() != null) {
- if (getBean().getMappingZoneReproZoneRecru() != null) {
- fieldPopulationMappingZoneReproZoneRecru.setMatrix(getBean().getMappingZoneReproZoneRecru().copy());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-protected void setPopulationZonesPresenceModel() {
- if (getBean() != null) {
- java.util.List<Zone> zones = getFisheryRegion().getZone();
- setModel(zones, getBean().getPopulationZone(), populationZonesPresence);
- }
-}
-protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) {
- if (getBean() != null) {
- setModel(zones, getBean().getReproductionZone(), fieldPopulationZonesReproduction);
- }
-}
-protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) {
- if (getBean() != null) {
- setModel(zones, getBean().getRecruitmentZone(), fieldPopulationZonesRecruitment);
- }
-}
+ ]]></script>
-/**
- * Change model of {@code associatedList} with all available zones, but keep
- * selection with {@code selectedZones}.
- */
-protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) {
- GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones);
- associatedList.setModel(zoneModel);
-
- // can be null at population init
- if (selectedZones != null) {
- for (Zone selectedZone : selectedZones) {
- int index = availableZones.indexOf(selectedZone);
- associatedList.addSelectionInterval(index, index);
- }
- }
-}
-
-protected void presenceChanged() {
- if (!init) {
- getBean().setPopulationZone(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-protected void reproductionChanged() {
- if (!init) {
- getBean().setReproductionZone(getSelectedValues(fieldPopulationZonesReproduction));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-protected void recruitementChanged() {
- if (!init) {
- getBean().setRecruitmentZone(getSelectedValues(fieldPopulationZonesRecruitment));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-/**
- * Get selected values for components as list.
- */
-protected List<Zone> getSelectedValues(JList<Zone> component) {
- List<Zone> selectedValues = component.getSelectedValuesList();
- List<Zone> selectedZone = new ArrayList<Zone>(selectedValues);
- return selectedZone;
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -167,19 +56,19 @@
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="populationZonesPresence" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='presenceChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.presenceChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="fieldPopulationZonesReproduction" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='reproductionChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.reproductionChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="fieldPopulationZonesRecruitment" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='recruitementChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.recruitementChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
</row>
@@ -192,7 +81,7 @@
<cell columns='3' fill='both' weightx='1.0' weighty='0.5'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='fieldPopulationMappingZoneReproZoneRecru'
constructorParams='false' enabled='{isActive()}'
- onMatrixChanged="populationMappingZoneReproZoneRecruMatrixChanged(event)"
+ onMatrixChanged="handler.populationMappingZoneReproZoneRecruMatrixChanged(event)"
decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Population.class}' _sensitivityMethod='"MappingZoneReproZoneRecru"' />
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationZonesHandler extends InputContentHandler<PopulationZonesUI> {
+
+ protected void init(final PopulationZonesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,30 +27,25 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
+ <PopulationZonesHandler id="handler" />
+
<BeanValidator id='validator' context="zones"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- getSaveVerifier().addCurrentPanel(popZones);
-}*/
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ popZones.setLayer(active);
+ }
+ ]]></script>
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- popZones.setLayer(active);
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,421 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+
+import javax.swing.JFrame;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationGroupDAO;
+
+/**
+ * wizard group creation handler.
+ */
+public class WizardGroupCreationHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(WizardGroupCreationHandler.class);
+
+ protected WizardGroupCreationUI wizardUI;
+
+ protected String current = null;
+ protected boolean ageType = false;
+ protected boolean inputType = false;
+ protected boolean sameSizeType = false;
+ protected boolean growthCurveType = false;
+
+ protected double first = 0;
+ protected double last = 0;
+
+ protected String maxLength = "";
+ protected int numberOfGroup = 0;
+ protected double groupSize = 0;
+
+ protected double step = 1;
+ protected PopulationBasicsUI popBasic;
+
+ protected void init(final WizardGroupCreationUI wizardUI) {
+ this.wizardUI = wizardUI;
+ }
+
+ public void initParent(PopulationBasicsUI popBasic) {
+ this.popBasic = popBasic;
+ }
+
+ /**
+ * @return Returns the ageType.
+ */
+ public boolean isAgeType() {
+ return this.ageType;
+ }
+
+ /**
+ * @param ageType The ageType to set.
+ */
+ public void setAgeType(boolean ageType) {
+ this.ageType = ageType;
+ }
+
+ /**
+ * @return Returns the inputType.
+ */
+ public boolean isInputType() {
+ return this.inputType;
+ }
+
+ /**
+ * @param inputType The inputType to set.
+ */
+ public void setInputType(boolean inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return Returns the sameSizeType.
+ */
+ public boolean isSameSizeType() {
+ return this.sameSizeType;
+ }
+
+ /**
+ * @param sameSizeType The sameSizeType to set.
+ */
+ public void setSameSizeType(boolean sameSizeType) {
+ this.sameSizeType = sameSizeType;
+ }
+
+ /**
+ * @return Returns the growthCurveType.
+ */
+ public boolean isGrowthCurveType() {
+ return this.growthCurveType;
+ }
+
+ /**
+ * @param growthCurveType The growthCurveType to set.
+ */
+ public void setGrowthCurveType(boolean growthCurveType) {
+ this.growthCurveType = growthCurveType;
+ }
+
+ /**
+ * @return Returns the first.
+ */
+ public double getFirst() {
+ return this.first;
+ }
+
+ /**
+ * @param first The first to set.
+ */
+ public void setFirst(double first) {
+ this.first = first;
+ }
+
+ /**
+ * @return Returns the last.
+ */
+ public double getLast() {
+ return this.last;
+ }
+
+ /**
+ * @param last The last to set.
+ */
+ public void setLast(double last) {
+ this.last = last;
+ }
+
+ /**
+ * @return Returns the maxLength.
+ */
+ public String getMaxLength() {
+ return this.maxLength;
+ }
+
+ /**
+ * @param maxLength The maxLength to set.
+ */
+ public void setMaxLength(String maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ /**
+ * @return Returns the numberOfGroup.
+ */
+ public int getNumberOfGroup() {
+ return this.numberOfGroup;
+ }
+
+ /**
+ * @param numberOfGroup The numberOfGroup to set.
+ */
+ public void setNumberOfGroup(int numberOfGroup) {
+ this.numberOfGroup = numberOfGroup;
+ }
+
+ /**
+ * @return Returns the groupSize.
+ */
+ public double getGroupSize() {
+ return this.groupSize;
+ }
+
+ /**
+ * @param groupSize The groupSize to set.
+ */
+ public void setGroupSize(double groupSize) {
+ this.groupSize = groupSize;
+ }
+
+ /**
+ * @return Returns the step.
+ */
+ public double getStep() {
+ return this.step;
+ }
+
+ /**
+ * @param step The step to set.
+ */
+ public void setStep(double step) {
+ this.step = step;
+ }
+
+ public void setCard(String name) {
+ current = name;
+ ((CardLayout) wizardUI.wizardPanels.getLayout()).show(wizardUI.wizardPanels, name);
+ }
+
+ protected void prev() {
+ if (isAgeType()) {
+ // do nothing only one panel
+ } else {
+ setCard("beginGroupLength");
+ }
+ wizardUI.prev.setEnabled(false);
+ wizardUI.next.setEnabled(true);
+ wizardUI.finish.setEnabled(false);
+ }
+
+ protected void next() {
+ if (isAgeType()) {
+ // do nothing only one panel
+ } else if (isInputType()) {
+ setCard("endInputGroupLength");
+ } else if (isSameSizeType()) {
+ setCard("endSameSizeGroupLength");
+ } else if (isGrowthCurveType()) {
+ setCard("endGrowthCurveGroupLength");
+ }
+ wizardUI.prev.setEnabled(true);
+ wizardUI.next.setEnabled(false);
+ wizardUI.finish.setEnabled(true);
+ }
+
+ protected void finish() {
+ if (log.isDebugEnabled()) {
+ log.debug("wizardGroupFinish called");
+ }
+
+ try {
+ Population pop = popBasic.getBean();
+ // remove all old group
+ pop.clearPopulationGroup();
+
+ TopiaContext isisContext = pop.getTopiaContext();
+ PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext);
+
+ if (isAgeType()) {
+ double ageFirst = getFirst();
+ double ageLast = getLast();
+ for (int id = 0; id + ageFirst <= ageLast; id++) {
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(id);
+ group.setPopulation(pop);
+ group.setAge(ageFirst + id);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ }
+ } else if (isInputType()) {
+ double minLength = getFirst();
+ String[] values = getMaxLength().split(";");
+ for (int i = 0; i < values.length; i++) {
+ if (!"".equals(values[i])) {
+ double length = Double.parseDouble(values[i]);
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(minLength);
+ group.setMaxLength(length);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ minLength = length;
+ }
+ }
+
+ } else if (isSameSizeType()) {
+ double minLength = getFirst();
+ int numberOfGroup = getNumberOfGroup();
+ double step = getGroupSize();
+ if (numberOfGroup < 0) {
+ // return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero"));
+ }
+ if (step == 0) {
+ // return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step"));
+ }
+
+ double maxLength = minLength;
+ for (int i = 0; i < numberOfGroup; i++) {
+ maxLength = minLength + step;
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(minLength);
+ group.setMaxLength(maxLength);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ minLength = maxLength;
+ }
+ } else if (isGrowthCurveType()) {
+ double minLength = getFirst();
+ int numberOfGroup = getNumberOfGroup();
+ int step = (int) getStep();
+
+ Equation equation = pop.getGrowth();
+ if (equation == null) {
+ // return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population"));
+ }
+ double deltat = -1;
+ double Lmin = minLength;
+ for (int i = 0; i < numberOfGroup; i++) {
+ // on creer la classe avec une valeur Lmax fausses ...
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(Lmin);
+ group.setMaxLength(Lmin);
+ pop.addPopulationGroup(group);
+
+ if (deltat < 0) {
+ // premier passage, recuperation de l'age minimum
+ deltat = pop.getAge(minLength, group);
+ }
+ // incrementation pour calculer la longueur max de la classe
+ deltat += step;
+
+ // ... pour pouvoir avoir la classe pour l'equation
+ double Lmax = pop.getLength(deltat, group);
+ group.setMaxLength(Lmax);
+ Lmin = Lmax;
+ }
+ }
+ popBasic.getHandler().refresh();
+ cancel();
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create PopulationGroup", e);
+ }
+ }
+
+ }
+
+ protected void cancel() {
+ wizardUI.getParentContainer(JFrame.class).dispose();
+ }
+
+ protected void refreshChoice() {
+ setInputType(wizardUI.beginGroupLengthTypeInput.isSelected());
+ setSameSizeType(wizardUI.beginGroupLengthTypeSameSize.isSelected());
+ setGrowthCurveType(wizardUI.beginGroupLengthTypeGrowthCurve.isSelected());
+ }
+
+ protected void stepChanged() {
+ if (!wizardUI.fieldStep.getText().equals("")) {
+ setStep(Double.parseDouble(wizardUI.fieldStep.getText()));
+ }
+ }
+
+ protected void firstAgeChanged() {
+ if (!wizardUI.firstAge.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstAge.getText()));
+ }
+ }
+
+ protected void lastAgeChanged() {
+ if (!wizardUI.lastAge.getText().equals("")) {
+ setLast(Double.parseDouble(wizardUI.lastAge.getText()));
+ }
+ }
+
+ protected void firstInputLengthChanged() {
+ if (!wizardUI.firstInputLength.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstInputLength.getText()));
+ }
+ }
+
+ protected void maximalGroupsLengthChanged() {
+ if (!wizardUI.maximalGroupsLength.getText().equals("")) {
+ setMaxLength(wizardUI.maximalGroupsLength.getText());
+ }
+ }
+
+ protected void firstSizeLengthChanged() {
+ if (!wizardUI.firstSizeLength.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstSizeLength.getText()));
+ }
+ }
+
+ protected void sameSizeNumberOfGroupChanged() {
+ if (!wizardUI.sameSizeNumberOfGroup.getText().equals("")) {
+ setNumberOfGroup(Integer.parseInt(wizardUI.sameSizeNumberOfGroup.getText()));
+ }
+ }
+
+ protected void groupWidthChanged() {
+ if (!wizardUI.groupWidth.getText().equals("")) {
+ setGroupSize(Double.parseDouble(wizardUI.groupWidth.getText()));
+ }
+ }
+
+ protected void growthCurveFirstGroupChanged() {
+ if (!wizardUI.growthCurveFirstGroup.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.growthCurveFirstGroup.getText()));
+ }
+ }
+
+ protected void fieldNumberOfGroupChanged() {
+ if (!wizardUI.fieldNumberOfGroup.getText().equals("")) {
+ setNumberOfGroup(Integer.parseInt(wizardUI.fieldNumberOfGroup.getText()));
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -23,375 +23,16 @@
#L%
-->
<JPanel id="wizardGroup" layout='{new BorderLayout()}'>
- <import>
- org.nuiton.topia.TopiaContext
- fr.ifremer.isisfish.IsisFishDAOHelper
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationGroupDAO
- java.awt.CardLayout
- javax.swing.JFrame
- </import>
+ <WizardGroupCreationHandler id="handler" />
+
<script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- protected String current = null;
- protected boolean ageType = false;
- protected boolean inputType = false;
- protected boolean sameSizeType = false;
- protected boolean growthCurveType = false;
-
- protected double first = 0;
- protected double last = 0;
-
- protected String maxLength = "";
- protected int numberOfGroup = 0;
- protected double groupSize = 0;
-
- protected double step = 1;
- protected PopulationBasicsUI popBasic;
-
- public void init(PopulationBasicsUI popBasic) {
- this.popBasic = popBasic;
- }
-
- /**
- * @return Returns the ageType.
- */
- public boolean isAgeType() {
- return this.ageType;
- }
-
- /**
- * @param ageType The ageType to set.
- */
- public void setAgeType(boolean ageType) {
- this.ageType = ageType;
- }
-
- /**
- * @return Returns the inputType.
- */
- public boolean isInputType() {
- return this.inputType;
- }
-
- /**
- * @param inputType The inputType to set.
- */
- public void setInputType(boolean inputType) {
- this.inputType = inputType;
- }
-
- /**
- * @return Returns the sameSizeType.
- */
- public boolean isSameSizeType() {
- return this.sameSizeType;
- }
-
- /**
- * @param sameSizeType The sameSizeType to set.
- */
- public void setSameSizeType(boolean sameSizeType) {
- this.sameSizeType = sameSizeType;
- }
-
- /**
- * @return Returns the growthCurveType.
- */
- public boolean isGrowthCurveType() {
- return this.growthCurveType;
- }
-
- /**
- * @param growthCurveType The growthCurveType to set.
- */
- public void setGrowthCurveType(boolean growthCurveType) {
- this.growthCurveType = growthCurveType;
- }
-
- /**
- * @return Returns the first.
- */
- public double getFirst() {
- return this.first;
- }
-
- /**
- * @param first The first to set.
- */
- public void setFirst(double first) {
- this.first = first;
- }
-
- /**
- * @return Returns the last.
- */
- public double getLast() {
- return this.last;
- }
-
- /**
- * @param last The last to set.
- */
- public void setLast(double last) {
- this.last = last;
- }
-
- /**
- * @return Returns the maxLength.
- */
- public String getMaxLength() {
- return this.maxLength;
- }
-
- /**
- * @param maxLength The maxLength to set.
- */
- public void setMaxLength(String maxLength) {
- this.maxLength = maxLength;
- }
-
- /**
- * @return Returns the numberOfGroup.
- */
- public int getNumberOfGroup() {
- return this.numberOfGroup;
- }
-
- /**
- * @param numberOfGroup The numberOfGroup to set.
- */
- public void setNumberOfGroup(int numberOfGroup) {
- this.numberOfGroup = numberOfGroup;
- }
-
- /**
- * @return Returns the groupSize.
- */
- public double getGroupSize() {
- return this.groupSize;
- }
-
- /**
- * @param groupSize The groupSize to set.
- */
- public void setGroupSize(double groupSize) {
- this.groupSize = groupSize;
- }
-
- /**
- * @return Returns the step.
- */
- public double getStep() {
- return this.step;
- }
-
- /**
- * @param step The step to set.
- */
- public void setStep(double step) {
- this.step = step;
- }
-
- public void setCard(String name){
- current = name;
- ((CardLayout) wizardPanels.getLayout()).show(wizardPanels, name);
- }
- protected void prev(){
- if (isAgeType()) {
- // do nothing only one panel
- } else {
- setCard("beginGroupLength");
- }
- prev.setEnabled(false);
- next.setEnabled(true);
- finish.setEnabled(false);
- }
- protected void next(){
- if (isAgeType()) {
- // do nothing only one panel
- } else if (isInputType()) {
- setCard("endInputGroupLength");
- } else if (isSameSizeType()) {
- setCard("endSameSizeGroupLength");
- } else if (isGrowthCurveType()) {
- setCard("endGrowthCurveGroupLength");
- }
- prev.setEnabled(true);
- next.setEnabled(false);
- finish.setEnabled(true);
- }
- protected void finish() {
- if (log.isDebugEnabled()) {
- log.debug("wizardGroupFinish called");
- }
-
- try {
- Population pop = popBasic.getBean();
- // remove all old group
- pop.clearPopulationGroup();
-
- TopiaContext isisContext = pop.getTopiaContext();
- PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext);
-
- if (isAgeType()) {
- double ageFirst = getFirst();
- double ageLast = getLast();
- for (int id=0; id + ageFirst <= ageLast; id++) {
- PopulationGroup group = populationGroupDAO.create();
- group.setId(id);
- group.setPopulation(pop);
- group.setAge(ageFirst + id);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- }
- } else if (isInputType()) {
- double minLength = getFirst();
- String [] values = getMaxLength().split(";");
- for(int i=0; i<values.length; i++){
- if (!"".equals(values[i])) {
- double length = Double.parseDouble(values[i]);
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(minLength);
- group.setMaxLength(length);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- minLength = length;
- }
- }
-
- } else if (isSameSizeType()) {
- double minLength = getFirst();
- int numberOfGroup = getNumberOfGroup();
- double step = getGroupSize();
- if (numberOfGroup < 0){
-// return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero"));
- }
- if (step == 0){
-// return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step"));
- }
-
- double maxLength = minLength;
- for(int i=0; i<numberOfGroup; i++){
- maxLength = minLength + step;
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(minLength);
- group.setMaxLength(maxLength);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- minLength = maxLength;
- }
- } else if (isGrowthCurveType()) {
- double minLength = getFirst();
- int numberOfGroup = getNumberOfGroup();
- int step = (int)getStep();
-
- Equation equation = pop.getGrowth();
- if(equation == null){
-// return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population"));
- }
- double deltat = -1;
- double Lmin = minLength;
- for(int i=0; i<numberOfGroup; i++){
- // on creer la classe avec une valeur Lmax fausses ...
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(Lmin);
- group.setMaxLength(Lmin);
- pop.addPopulationGroup(group);
-
- if(deltat < 0) {
- // premier passage, recuperation de l'age minimum
- deltat = pop.getAge(minLength, group);
- }
- // incrementation pour calculer la longueur max de la classe
- deltat += step;
-
- // ... pour pouvoir avoir la classe pour l'equation
- double Lmax = pop.getLength(deltat, group);
- group.setMaxLength(Lmax);
- Lmin = Lmax;
- }
- }
- popBasic.refresh();
- cancel();
- }
- catch(Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't create PopulationGroup", e);
- }
- }
-
- }
- protected void cancel(){
- getParentContainer(JFrame.class).dispose();
- }
- protected void refreshChoice(){
- setInputType(beginGroupLengthTypeInput.isSelected());
- setSameSizeType(beginGroupLengthTypeSameSize.isSelected());
- setGrowthCurveType(beginGroupLengthTypeGrowthCurve.isSelected());
- }
- protected void stepChanged(){
- if (!fieldStep.getText().equals("")){
- setStep(Double.parseDouble(fieldStep.getText()));
- }
- }
- protected void firstAgeChanged(){
- if (!firstAge.getText().equals("")){
- setFirst(Double.parseDouble(firstAge.getText()));
- }
- }
- protected void lastAgeChanged(){
- if(!lastAge.getText().equals("")){
- setLast(Double.parseDouble(lastAge.getText()));
- }
- }
- protected void firstInputLengthChanged(){
- if(!firstInputLength.getText().equals("")){
- setFirst(Double.parseDouble(firstInputLength.getText()));
- }
- }
- protected void maximalGroupsLengthChanged(){
- if(!maximalGroupsLength.getText().equals("")){
- setMaxLength(maximalGroupsLength.getText());
- }
- }
- protected void firstSizeLengthChanged(){
- if(!firstSizeLength.getText().equals("")){
- setFirst(Double.parseDouble(firstSizeLength.getText()));
- }
- }
- protected void sameSizeNumberOfGroupChanged(){
- if(!sameSizeNumberOfGroup.getText().equals("")){
- setNumberOfGroup(Integer.parseInt(sameSizeNumberOfGroup.getText()));
- }
- }
- protected void groupWidthChanged(){
- if(!groupWidth.getText().equals("")){
- setGroupSize(Double.parseDouble(groupWidth.getText()));
- }
- }
- protected void growthCurveFirstGroupChanged(){
- if(!growthCurveFirstGroup.getText().equals("")){
- setFirst(Double.parseDouble(growthCurveFirstGroup.getText()));
- }
- }
- protected void fieldNumberOfGroupChanged(){
- if(!fieldNumberOfGroup.getText().equals("")){
- setNumberOfGroup(Integer.parseInt(fieldNumberOfGroup.getText()));
- }
- }
- ]]>
- </script>
- <JPanel id="wizardPanels" layout='{new CardLayout()}' constraints='BorderLayout.CENTER'>
+ <JPanel id="wizardPanels" layout='{new java.awt.CardLayout()}' constraints='BorderLayout.CENTER'>
<Table constraints='"beginGroupLength"'>
<row>
<cell fill='horizontal' weightx='1.0'>
@@ -400,17 +41,20 @@
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allValues" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.allValues" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
</Table>
@@ -425,7 +69,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstAge"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstAge" onFocusLost='firstAgeChanged()'/>
+ <JTextField id="firstAge" onFocusLost='handler.firstAgeChanged()'/>
</cell>
</row>
<row>
@@ -433,7 +77,7 @@
<JLabel text="isisfish.wizardGroupCreation.lastAge"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="lastAge" onFocusLost='lastAgeChanged()'/>
+ <JTextField id="lastAge" onFocusLost='handler.lastAgeChanged()'/>
</cell>
</row>
<row>
@@ -463,7 +107,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstInputLength" onFocusLost='firstInputLengthChanged()'/>
+ <JTextField id="firstInputLength" onFocusLost='handler.firstInputLengthChanged()'/>
</cell>
</row>
<row>
@@ -471,7 +115,7 @@
<JLabel text="isisfish.wizardGroupCreation.maxGroupsLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="maximalGroupsLength" onFocusLost='maximalGroupsLengthChanged()'/>
+ <JTextField id="maximalGroupsLength" onFocusLost='handler.maximalGroupsLengthChanged()'/>
</cell>
</row>
<row>
@@ -491,7 +135,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstSizeLength" onFocusLost='firstSizeLengthChanged()'/>
+ <JTextField id="firstSizeLength" onFocusLost='handler.firstSizeLengthChanged()'/>
</cell>
</row>
<row>
@@ -499,7 +143,7 @@
<JLabel text="isisfish.wizardGroupCreation.numberGroup"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="sameSizeNumberOfGroup" onFocusLost='sameSizeNumberOfGroupChanged()'/>
+ <JTextField id="sameSizeNumberOfGroup" onFocusLost='handler.sameSizeNumberOfGroupChanged()'/>
</cell>
</row>
<row>
@@ -507,7 +151,7 @@
<JLabel text="isisfish.wizardGroupCreation.groupWidth"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="groupWidth" onFocusLost='groupWidthChanged()'/>
+ <JTextField id="groupWidth" onFocusLost='handler.groupWidthChanged()'/>
</cell>
</row>
<row>
@@ -537,7 +181,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstGroup"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="growthCurveFirstGroup" onFocusLost='growthCurveFirstGroupChanged()'/>
+ <JTextField id="growthCurveFirstGroup" onFocusLost='handler.growthCurveFirstGroupChanged()'/>
</cell>
</row>
<row>
@@ -545,7 +189,7 @@
<JLabel text="isisfish.wizardGroupCreation.numberGroups"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="fieldNumberOfGroup" onFocusLost='fieldNumberOfGroupChanged()'/>
+ <JTextField id="fieldNumberOfGroup" onFocusLost='handler.fieldNumberOfGroupChanged()'/>
</cell>
</row>
<row>
@@ -553,7 +197,7 @@
<JLabel text="isisfish.wizardGroupCreation.timeStep"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="fieldStep" onFocusLost='stepChanged()'/>
+ <JTextField id="fieldStep" onFocusLost='handler.stepChanged()'/>
</cell>
</row>
<row>
@@ -566,16 +210,16 @@
<Table id="navButton" constraints='BorderLayout.SOUTH'>
<row>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='prev()'/>
+ <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='handler.prev()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='next' text="isisfish.common.next" onActionPerformed='next()'/>
+ <JButton id='next' text="isisfish.common.next" onActionPerformed='handler.next()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='finish()'/>
+ <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='handler.finish()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/>
+ <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='handler.cancel()'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.port;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import com.bbn.openmap.event.SelectMouseMode;
+
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.map.CellSelectionLayer;
+import fr.ifremer.isisfish.map.OpenMapEvents;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Port handler.
+ */
+public class PortHandler extends InputContentHandler<PortUI> {
+
+ protected boolean init = false;
+
+ protected void init(final PortUI inputContentUI) {
+ super.init(inputContentUI);
+
+ new OpenMapEvents(inputContentUI.portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) {
+ @Override
+ public boolean mouseClicked(MouseEvent e) {
+ if (inputContentUI.getBean() != null) { // impossible de desactiver la carte :(
+ for (Cell c : inputContentUI.portMap.getSelectedCells()) {
+ if (inputContentUI.getBean().getCell() != null) {
+ if (!inputContentUI.getBean().getCell().getTopiaId().equals(c.getTopiaId())){
+ inputContentUI.portCell.setSelectedValue(c, true);
+ return true;
+ }
+ } else {
+ inputContentUI.portCell.setSelectedValue(c, true);
+ return true;
+ }
+ }
+ }
+ return true;
+ }
+ };
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueSpecies"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.species"));
+
+ inputContentUI.addPropertyChangeListener(PortUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPortName.setText("");
+ inputContentUI.fieldPortComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ fillCellList();
+ }
+ });
+ }
+
+ protected void fillCellList() {
+ GenericListModel<Cell> cellModel = new GenericListModel<>();
+ if (inputContentUI.getBean() != null) {
+ init = true;
+ cellModel.setElementList(inputContentUI.getFisheryRegion().getCell());
+ inputContentUI.portCell.setModel(cellModel);
+ inputContentUI.portCell.setSelectedValue(inputContentUI.getBean().getCell(), true);
+ init = false;
+ } else {
+ inputContentUI.portCell.setModel(cellModel);
+ }
+ }
+
+ protected void portChanged() {
+ if (inputContentUI.getBean() != null && !init) {
+ inputContentUI.getBean().setCell(inputContentUI.portCell.getSelectedValue());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Port id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.Port
- fr.ifremer.isisfish.entities.Cell
- fr.ifremer.isisfish.map.CellSelectionLayer
- fr.ifremer.isisfish.map.CopyMapToClipboardListener
- fr.ifremer.isisfish.map.OpenMapEvents
- com.bbn.openmap.event.SelectMouseMode
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.event.MouseEvent
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- </import>
+ <PortHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Port'
@@ -50,79 +37,11 @@
</BeanValidator>
<script><![CDATA[
-boolean init = false;
-
-protected void $afterCompleteSetup() {
-
- //portMap.init(portMapInfo);
- new OpenMapEvents(portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) {
- @Override
- public boolean mouseClicked(MouseEvent e) {
- if (getBean() != null) { // impossible de desactiver la carte :(
- for (Cell c : portMap.getSelectedCells()) {
- if (getBean().getCell() != null) {
- if (!getBean().getCell().getTopiaId().equals(c.getTopiaId())){
- portCell.setSelectedValue(c, true);
- return true;
- }
- }
- else {
- portCell.setSelectedValue(c, true);
- return true;
- }
- }
- }
- return true;
- }
- };
-
- setButtonTitle(t("isisfish.input.continueSpecies"));
- setNextPath(n("isisfish.input.tree.species"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPortName.setText("");
- fieldPortComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- fillCellList();
- }
- });
-}
-
-/*public void refresh() {
- Port port = getSaveVerifier().getEntity(Port.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(port);
- // reload region in map
- refreshRegionInMap(portMap);
-}*/
-
-protected void fillCellList() {
- GenericListModel<Cell> cellModel = new GenericListModel<>();
- if (getBean() != null) {
- init = true;
- cellModel.setElementList(getFisheryRegion().getCell());
- portCell.setModel(cellModel);
- portCell.setSelectedValue(getBean().getCell(), true);
- init = false;
- } else {
- portCell.setModel(cellModel);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-protected void portChanged() {
- if (getBean() != null && !init) {
- getBean().setCell(portCell.getSelectedValue());
- }
-}
]]></script>
+
<JPanel id="body">
<JSplitPane oneTouchExpandable="true" dividerLocation="270" orientation="horizontal">
<Table>
@@ -147,7 +66,7 @@
<JScrollPane id="spPortCell">
<JList id="portCell"
genericType="fr.ifremer.isisfish.entities.Cell" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
- onValueChanged='portChanged()' enabled='{isActive()}' decorator='boxed' />
+ onValueChanged='handler.portChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
@@ -159,7 +78,8 @@
<row>
<cell columns='2' fill='both' weighty='0.3' weightx='1.0' >
<JScrollPane>
- <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/>
+ <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}'
+ onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * set of vessels handler.
+ */
+public class EffortDescriptionHandler extends InputContentHandler<EffortDescriptionUI> {
+
+ protected void init(final EffortDescriptionUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EffortDescriptionUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ GenericListModel<Metier> metierModel = (GenericListModel<Metier>)inputContentUI.fieldEffortDescriptionMetierList.getModel();
+ if (evt.getNewValue() == null) {
+ metierModel.setElementList(null);
+ }
+ if (evt.getNewValue() != null) {
+ metierModel.setElementList(inputContentUI.getFisheryRegion().getMetier());
+ setEffortDescriptionEffortDescriptionList();
+ }
+ }
+ });
+ }
+
+ /**
+ * Get input action from context.
+ */
+ @Deprecated
+ protected InputAction getInputAction() {
+ return inputContentUI.getContextValue(InputAction.class);
+ }
+
+ protected void onFieldEffortDescriptionMetierListValueChanged() {
+ // active le bouton seulement si l'interface est active
+ // dans le cas de sensitivity par exemple
+ if (inputContentUI.isActive()) {
+ inputContentUI.buttonEffortDescriptionAdd.setEnabled(inputContentUI.fieldEffortDescriptionMetierList.getSelectedIndex() != -1);
+ }
+ }
+
+ protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() {
+ // active le bouton seulement si l'interface est active
+ // dans le cas de sensitivity par exemple
+ if (inputContentUI.isActive()) {
+ inputContentUI.removeEffortDescriptionButton.setEnabled(inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1);
+ }
+ }
+
+ protected void setEffortDescriptionEffortDescriptionList() {
+ GenericListModel<EffortDescription> model = new GenericListModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) {
+ List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers());
+ model.setElementList(effortDescriptions);
+ }
+ inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model);
+ }
+
+ protected void addEffortDescriptions() {
+ List<Metier> selectedValues = inputContentUI.fieldEffortDescriptionMetierList.getSelectedValuesList();
+ for (Metier selectedMetier : selectedValues) {
+ getInputAction().addEffortDescription(inputContentUI.getBean(), selectedMetier);
+ }
+ setEffortDescriptionEffortDescriptionList();
+ }
+ protected void removeEffortDescriptions() {
+ List<EffortDescription> selectedValues = inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
+ for (EffortDescription selectedEffortDescription : selectedValues) {
+ getInputAction().removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
+ }
+ setEffortDescriptionEffortDescriptionList();
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+
+/**
+ * Renderer pour liste des {@link EffortDescription}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EffortDescriptionListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ EffortDescription effort = (EffortDescription) value;
+ c.setText(effort.getPossibleMetiers().getName());
+
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * set of vessels handler.
+ */
+public class EffortDescriptionParametersHandler extends InputContentHandler<EffortDescriptionParametersUI> {
+
+ protected void init(final EffortDescriptionParametersUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.setEffortDescription(null);
+ }
+ if (evt.getNewValue() != null) {
+ GenericListModel<EffortDescription> model = new GenericListModel<>();
+ // getBean().getPossibleMetiers() can be null at region creation
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) {
+ List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers());
+ model.setElementList(effortDescriptions);
+ }
+ inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model);
+ }
+ }
+ });
+ inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldEffortDescriptionFishingOperation.setText("");
+ inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText("");
+ inputContentUI.fieldEffortDescriptionGearsNumberPerOperation.setText("");
+ inputContentUI.fieldEffortDescriptionCrewSize.setText("");
+ inputContentUI.fieldEffortDescriptionUnitCostOfFishing.setText("");
+ inputContentUI.fieldEffortDescriptionFixedCrewSalary.setText("");
+ inputContentUI.fieldEffortDescriptionCrewFoodCost.setText("");
+ inputContentUI.fieldEffortDescriptionCrewShareRate.setText("");
+ inputContentUI.fieldEffortDescriptionRepairAndMaintenanceGearCost.setText("");
+ inputContentUI.fieldEffortDescriptionLandingCosts.setText("");
+ inputContentUI.fieldEffortDescriptionOtherRunningCost.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ // FIX non working binding in jaxx 2.4.1
+ if (inputContentUI.getEffortDescription().getFishingOperationDuration() == null) {
+ inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText("");
+ }
+ }
+ }
+ });
+ }
+
+ protected void effortDescriptionSelectionChanged() {
+ EffortDescription selectedEffort = (EffortDescription)inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValue();
+ inputContentUI.setEffortDescription(selectedEffort);
+
+ if (inputContentUI.getEffortDescription() != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getEffortDescription());
+ selectedEffort.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+
+ /* NumberEditor is not working
+ fieldEffortDescriptionFishingOperation.init();
+ fieldEffortDescriptionGearsNumberPerOperation.init();
+ fieldEffortDescriptionCrewSize.init();
+ fieldEffortDescriptionUnitCostOfFishing.init();
+ fieldEffortDescriptionFixedCrewSalary.init();
+ fieldEffortDescriptionCrewFoodCost.init();
+ fieldEffortDescriptionCrewShareRate.init();
+ fieldEffortDescriptionRepairAndMaintenanceGearCost.init();
+ fieldEffortDescriptionLandingCosts.init();
+ fieldEffortDescriptionOtherRunningCost.init();*/
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,18 +29,8 @@
<fr.ifremer.isisfish.entities.EffortDescription id='effortDescription' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- java.util.ArrayList;
- fr.ifremer.isisfish.entities.EffortDescription;
- fr.ifremer.isisfish.entities.SetOfVessels;
- fr.ifremer.isisfish.types.TimeUnit;
- fr.ifremer.isisfish.ui.models.common.GenericListModel;
- fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
-
+ <EffortDescriptionParametersHandler id="handler" />
+
<BeanValidator id='validator' context="effortdescriptionparameters"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -54,89 +44,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorEffort.isChanged()}"
valid="{validator.isValid() && validatorEffort.isValid()}"/>
- <script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setEffortDescription(null);
- }
- if (evt.getNewValue() != null) {
- GenericListModel<EffortDescription> model = new GenericListModel<>();
- // getBean().getPossibleMetiers() can be null at region creation
- if (getBean() != null && getBean().getPossibleMetiers() != null) {
- List<EffortDescription> effortDescriptions = new ArrayList<EffortDescription>(getBean().getPossibleMetiers());
- model.setElementList(effortDescriptions);
- }
- fieldEffortDescriptionEffortDescriptionList.setModel(model);
- }
- }
- });
- addPropertyChangeListener(PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldEffortDescriptionFishingOperation.setText("");
- fieldEffortDescriptionFishingOperationDuration.setText("");
- fieldEffortDescriptionGearsNumberPerOperation.setText("");
- fieldEffortDescriptionCrewSize.setText("");
- fieldEffortDescriptionUnitCostOfFishing.setText("");
- fieldEffortDescriptionFixedCrewSalary.setText("");
- fieldEffortDescriptionCrewFoodCost.setText("");
- fieldEffortDescriptionCrewShareRate.setText("");
- fieldEffortDescriptionRepairAndMaintenanceGearCost.setText("");
- fieldEffortDescriptionLandingCosts.setText("");
- fieldEffortDescriptionOtherRunningCost.setText("");
- }
- if (evt.getNewValue() != null) {
- // FIX non working binding in jaxx 2.4.1
- if (getEffortDescription().getFishingOperationDuration() == null) {
- fieldEffortDescriptionFishingOperationDuration.setText("");
- }
- }
- }
- });
-}
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class);
-
- // twice event for jaxx bindings detection
- setBean(null);
- setBean(setOfVessels);
-}*/
-
-protected void effortDescriptionSelectionChanged() {
- EffortDescription selectedEffort = (EffortDescription)fieldEffortDescriptionEffortDescriptionList.getSelectedValue();
- setEffortDescription(selectedEffort);
-
- if (getEffortDescription() != null) {
- getSaveVerifier().addCurrentEntity(getEffortDescription());
- selectedEffort.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
-
- /* NumberEditor is not working
- fieldEffortDescriptionFishingOperation.init();
- fieldEffortDescriptionGearsNumberPerOperation.init();
- fieldEffortDescriptionCrewSize.init();
- fieldEffortDescriptionUnitCostOfFishing.init();
- fieldEffortDescriptionFixedCrewSalary.init();
- fieldEffortDescriptionCrewFoodCost.init();
- fieldEffortDescriptionCrewShareRate.init();
- fieldEffortDescriptionRepairAndMaintenanceGearCost.init();
- fieldEffortDescriptionLandingCosts.init();
- fieldEffortDescriptionOtherRunningCost.init();*/
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
- ]]>
- </script>
+
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
+ }
+ ]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -144,7 +66,7 @@
<JScrollPane>
<JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
genericType="EffortDescription"
- onValueChanged='effortDescriptionSelectionChanged()'
+ onValueChanged='handler.effortDescriptionSelectionChanged()'
cellRenderer='{new EffortDescriptionListRenderer()}'
enabled='{isActive()}' />
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,18 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- java.util.ArrayList
- fr.ifremer.isisfish.entities.EffortDescription
- fr.ifremer.isisfish.entities.SetOfVessels
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.input.renderer.MetierListRenderer
- fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <EffortDescriptionHandler id="handler" />
<BeanValidator id='validator' context="effortdescription"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
@@ -46,96 +35,30 @@
</BeanValidator>
<script><![CDATA[
-/**
- * Get input action from context.
- */
-protected InputAction getInputAction() {
- return getContextValue(InputAction.class);
-}
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- GenericListModel<Metier> metierModel = (GenericListModel<Metier>)fieldEffortDescriptionMetierList.getModel();
- if (evt.getNewValue() == null) {
- metierModel.setElementList(null);
- }
- if (evt.getNewValue() != null) {
- metierModel.setElementList(getFisheryRegion().getMetier());
- setEffortDescriptionEffortDescriptionList();
- }
- }
- });
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class);
-
- // twice event for jaxx bindings detection
- setBean(null);
- setBean(setOfVessels);
-}*/
-
-protected void onFieldEffortDescriptionMetierListValueChanged() {
- // active le bouton seulement si l'interface est active
- // dans le cas de sensitivity par exemple
- if (isActive()) {
- buttonEffortDescriptionAdd.setEnabled(fieldEffortDescriptionMetierList.getSelectedIndex() != -1);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() {
- // active le bouton seulement si l'interface est active
- // dans le cas de sensitivity par exemple
- if (isActive()) {
- removeEffortDescriptionButton.setEnabled(fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1);
- }
-}
-
-protected void setEffortDescriptionEffortDescriptionList() {
- GenericListModel<EffortDescription> model = new GenericListModel<>();
- if (getBean() != null && getBean().getPossibleMetiers() != null) {
- List<EffortDescription> effortDescriptions = new ArrayList<>(getBean().getPossibleMetiers());
- model.setElementList(effortDescriptions);
- }
- fieldEffortDescriptionEffortDescriptionList.setModel(model);
-}
-
-protected void addEffortDescriptions() {
- List<Metier> selectedValues = fieldEffortDescriptionMetierList.getSelectedValuesList();
- for (Metier selectedMetier : selectedValues) {
- getInputAction().addEffortDescription(getBean(), selectedMetier);
- }
- setEffortDescriptionEffortDescriptionList();
-}
-protected void removeEffortDescriptions() {
- List<EffortDescription> selectedValues = fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
- for (EffortDescription selectedEffortDescription : selectedValues) {
- getInputAction().removeEffortDescription(getBean(), selectedEffortDescription);
- }
- setEffortDescriptionEffortDescriptionList();
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="fieldEffortDescriptionMetierList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- genericType="Metier"
- model='{new GenericListModel<Metier>()}' cellRenderer='{new MetierListRenderer()}'
- onValueChanged='onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' />
+ genericType="fr.ifremer.isisfish.entities.Metier"
+ model='{new fr.ifremer.isisfish.ui.models.common.GenericListModel<fr.ifremer.isisfish.entities.Metier>()}' cellRenderer='{new MetierListRenderer()}'
+ onValueChanged='handler.onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='0.5'>
- <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='addEffortDescriptions()' enabled='false'
+ <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='handler.addEffortDescriptions()' enabled='false'
decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='removeEffortDescriptions()'
+ <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='handler.removeEffortDescriptions()'
enabled='false' decorator='boxed' />
</cell>
</row>
@@ -143,9 +66,9 @@
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- genericType="EffortDescription"
+ genericType="fr.ifremer.isisfish.entities.EffortDescription"
cellRenderer='{new EffortDescriptionListRenderer()}'
- onValueChanged='onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' />
+ onValueChanged='handler.onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Metier;
+
+/**
+ * Renderer pour liste des metiers.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MetierListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ Metier metier = (Metier) value;
+ c.setText(metier.getName());
+
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.Port;
+import fr.ifremer.isisfish.entities.VesselType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * set of vessels handler.
+ */
+public class SetOfVesselsBasicsHandler extends InputContentHandler<SetOfVesselsBasicsUI> {
+
+ protected boolean init;
+
+ protected void init(final SetOfVesselsBasicsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(SetOfVesselsBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+
+ GenericComboModel<Port> modelPort = new GenericComboModel<>(inputContentUI.getFisheryRegion().getPort());
+ inputContentUI.fieldSetOfVesselsPort.setModel(modelPort);
+ inputContentUI.fieldSetOfVesselsPort.setSelectedItem(inputContentUI.getBean().getPort());
+
+ GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getVesselType());
+ inputContentUI.fieldSetOfVesselsVesselType.setModel(modelVessel);
+ inputContentUI.fieldSetOfVesselsVesselType.setSelectedItem(inputContentUI.getBean().getVesselType());
+
+ init=false;
+ }
+ }
+ });
+ }
+
+ protected void portChanged() {
+ if (!init) {
+ inputContentUI.getBean().setPort((Port)inputContentUI.fieldSetOfVesselsPort.getSelectedItem());
+ }
+ }
+ protected void vesselTypeChanged() {
+ if (!init) {
+ inputContentUI.getBean().setVesselType((VesselType)inputContentUI.fieldSetOfVesselsVesselType.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Port
- fr.ifremer.isisfish.entities.VesselType
- fr.ifremer.isisfish.entities.SetOfVessels
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <SetOfVesselsBasicsHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
@@ -43,64 +36,11 @@
</BeanValidator>
<script><![CDATA[
-boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
-
- GenericComboModel<Port> modelPort = new GenericComboModel<>(getFisheryRegion().getPort());
- fieldSetOfVesselsPort.setModel(modelPort);
- fieldSetOfVesselsPort.setSelectedItem(getBean().getPort());
-
- GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(getFisheryRegion().getVesselType());
- fieldSetOfVesselsVesselType.setModel(modelVessel);
- fieldSetOfVesselsVesselType.setSelectedItem(getBean().getVesselType());
-
- init=false;
- }
- }
- });
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = (SetOfVessels)getSaveVerifier().getEntity(SetOfVessels.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(setOfVessels);
-
- if (getBean() != null) {
- init = true;
- jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsPort,getFisheryRegion().getPort(), getBean().getPort(), true);
- jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsVesselType,getFisheryRegion().getVesselType(), getBean().getVesselType(), true);
- init=false;
- getSaveVerifier().addCurrentPanel(technicalEfficiency);
-
- // NumberEditor is not working
- //fieldSetOfVesselsNumberOfVessels.init();
- //fieldSetOfVesselsFixedCosts.init();
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}*/
+ ]]></script>
-protected void portChanged() {
- if (!init) {
- getBean().setPort((Port)fieldSetOfVesselsPort.getSelectedItem());
- }
-}
-protected void vesselTypeChanged() {
- if (!init) {
- getBean().setVesselType((VesselType)fieldSetOfVesselsVesselType.getSelectedItem());
- }
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -119,8 +59,8 @@
<JLabel text="isisfish.common.port" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='portChanged()'
- genericType="Port"
+ <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='handler.portChanged()'
+ genericType="fr.ifremer.isisfish.entities.Port"
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
@@ -129,8 +69,8 @@
<JLabel text="isisfish.setOfVessels.vesselType" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='vesselTypeChanged()'
- genericType="VesselType"
+ <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='handler.vesselTypeChanged()'
+ genericType="fr.ifremer.isisfish.entities.VesselType"
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * set of vessels handler.
+ */
+public class SetOfVesselsHandler extends InputContentHandler<SetOfVesselsUI> {
+
+ protected void init(final SetOfVesselsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueStrategies"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.strategies"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.setOfVesselsTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,40 +26,29 @@
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <SetOfVesselsHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueStrategies"));
- setNextPath(n("isisfish.input.tree.strategies"));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(setOfVesselsTab);
-}
-
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(setOfVesselsBasicsUI, effortDescriptionUI, effortParametersUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- setOfVesselsBasicsUI.setLayer(active);
- effortDescriptionUI.setLayer(active);
- effortParametersUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- setOfVesselsBasicsUI.resetChangeModel();
- effortDescriptionUI.resetChangeModel();
- effortParametersUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ setOfVesselsBasicsUI.setLayer(active);
+ effortDescriptionUI.setLayer(active);
+ effortParametersUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ setOfVesselsBasicsUI.resetChangeModel();
+ effortDescriptionUI.resetChangeModel();
+ effortParametersUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="setOfVesselsTab">
<tab title='isisfish.setOfVessels.title'>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.species;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.InputUI;
+
+/**
+ * Species handler.
+ */
+public class SpeciesHandler extends InputContentHandler<SpeciesUI> {
+
+ protected void init(final SpeciesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continuePopulations"));
+
+ inputContentUI.addPropertyChangeListener(SpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldSpeciesName.setText("");
+ inputContentUI.fieldSpeciesScientificName.setText("");
+ inputContentUI.fieldSpeciesCodeRubbin.setText("");
+ inputContentUI.fieldSpeciesCEE.setText("");
+ inputContentUI.fieldSpeciesComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void goTo() {
+ // FIXME il ne faut pas appeler le parent
+ // on ne sais jamais de quel type est le parent
+ InputUI inputUI = inputContentUI.getParentContainer(InputUI.class);
+ if (inputUI != null) {
+ if (inputContentUI.getBean() == null) {
+ inputUI.getHandler().setTreeSelection(inputContentUI, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations"));
+ }
+ else {
+ inputUI.getHandler().setTreeSelection(inputContentUI, inputContentUI.getBean().getTopiaId(), n("isisfish.input.tree.populations"));
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,42 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.species;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Species structured handler.
+ */
+public class SpeciesStructuredHandler extends InputContentHandler<SpeciesStructuredUI> {
+
+ protected void init(final SpeciesStructuredUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ protected void dynamicChanged() {
+ if (inputContentUI.getBean() != null) {
+ inputContentUI.getBean().setAgeGroupType(inputContentUI.fieldSpeciesDynamicAge.isSelected());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,20 +26,20 @@
<fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/>
+ <SpeciesStructuredHandler id="handler" />
+
<script><![CDATA[
- protected void dynamicChanged() {
- if (getBean() != null) {
- getBean().setAgeGroupType(fieldSpeciesDynamicAge.isSelected());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().isAgeGroupType()}'
- buttonGroup="structuredGroup" onItemStateChanged='dynamicChanged()' enabled='{isActive()}'/>
+ buttonGroup="structuredGroup" onItemStateChanged='handler.dynamicChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().isAgeGroupType()}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,15 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.Species
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.input.InputUI
- </import>
+ <SpeciesHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Species'
@@ -44,56 +36,16 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continuePopulations"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldSpeciesName.setText("");
- fieldSpeciesScientificName.setText("");
- fieldSpeciesCodeRubbin.setText("");
- fieldSpeciesCEE.setText("");
- fieldSpeciesComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-@Override
-protected void goTo() {
- // FIXME il ne faut pas appeler le parent
- // on ne sais jamais de quel type est le parent
- InputUI inputUI = getParentContainer(InputUI.class);
- if (inputUI != null) {
- if (getBean() == null) {
- inputUI.getHandler().setTreeSelection(this, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations"));
- }
- else {
- inputUI.getHandler().setTreeSelection(this, getBean().getTopiaId(), n("isisfish.input.tree.populations"));
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-/*public void refresh() {
- Species species = (Species)getSaveVerifier().getEntity(Species.class);
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(species);
-
- if (getBean() != null) {
- setNextPath("$root/$species/" + getBean().getTopiaId() + "/$populations");
- // Number Editor is not working
- //fieldSpeciesCEE.init();
+ @Override
+ protected void goTo() {
+ handler.goTo();
}
-}*/
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Strategy handler.
+ */
+public class StrategyHandler extends InputContentHandler<StrategyUI> {
+
+ protected void init(final StrategyUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueObservations"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.observations"));
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.strategyTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,93 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Strategy handler.
+ */
+public class StrategyMonthInfoHandler extends InputContentHandler<StrategyMonthInfoUI> {
+
+ protected void init(final StrategyMonthInfoUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyMonthInfoUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.setStrategyMonthInfo0(null);
+ inputContentUI.setStrategyMonthInfo1(null);
+ inputContentUI.setStrategyMonthInfo2(null);
+ inputContentUI.setStrategyMonthInfo3(null);
+ inputContentUI.setStrategyMonthInfo4(null);
+ inputContentUI.setStrategyMonthInfo5(null);
+ inputContentUI.setStrategyMonthInfo6(null);
+ inputContentUI.setStrategyMonthInfo7(null);
+ inputContentUI.setStrategyMonthInfo8(null);
+ inputContentUI.setStrategyMonthInfo9(null);
+ inputContentUI.setStrategyMonthInfo10(null);
+ inputContentUI.setStrategyMonthInfo11(null);
+ inputContentUI.fieldStrategyProportion.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ inputContentUI.setStrategyMonthInfo0(inputContentUI.getBean().getStrategyMonthInfo().get(0));
+ inputContentUI.setStrategyMonthInfo1(inputContentUI.getBean().getStrategyMonthInfo().get(1));
+ inputContentUI.setStrategyMonthInfo2(inputContentUI.getBean().getStrategyMonthInfo().get(2));
+ inputContentUI.setStrategyMonthInfo3(inputContentUI.getBean().getStrategyMonthInfo().get(3));
+ inputContentUI.setStrategyMonthInfo4(inputContentUI.getBean().getStrategyMonthInfo().get(4));
+ inputContentUI.setStrategyMonthInfo5(inputContentUI.getBean().getStrategyMonthInfo().get(5));
+ inputContentUI.setStrategyMonthInfo6(inputContentUI.getBean().getStrategyMonthInfo().get(6));
+ inputContentUI.setStrategyMonthInfo7(inputContentUI.getBean().getStrategyMonthInfo().get(7));
+ inputContentUI.setStrategyMonthInfo8(inputContentUI.getBean().getStrategyMonthInfo().get(8));
+ inputContentUI.setStrategyMonthInfo9(inputContentUI.getBean().getStrategyMonthInfo().get(9));
+ inputContentUI.setStrategyMonthInfo10(inputContentUI.getBean().getStrategyMonthInfo().get(10));
+ inputContentUI.setStrategyMonthInfo11(inputContentUI.getBean().getStrategyMonthInfo().get(11));
+ setProportionMetierMatrix();
+ }
+ }
+ });
+ }
+
+ protected void setProportionMetierMatrix() {
+ MatrixND prop = inputContentUI.getBean().getProportionMetier();
+ if (prop != null) {
+ inputContentUI.fieldStrategyProportion.setMatrix(prop.copy());
+ } else {
+ inputContentUI.fieldStrategyProportion.setMatrix(null);
+ }
+ }
+
+ protected void strategyProportionMatrixChanged(MatrixPanelEvent event) {
+ MatrixND mat = inputContentUI.fieldStrategyProportion.getMatrix();
+ if (inputContentUI.getBean() != null && mat != null) {
+ inputContentUI.getBean().setProportionMetier(mat.copy());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -39,15 +39,7 @@
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo10' javaBean='null'/>
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo11' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- org.apache.commons.lang3.StringUtils
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- static org.nuiton.i18n.I18n.t
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.MatrixND
- </import>
+ <StrategyMonthInfoHandler id="handler" />
<BeanValidator id='validator' context="month"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy'
@@ -105,90 +97,39 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator0.isChanged() || validator1.isChanged() || validator2.isChanged() || validator3.isChanged() || validator4.isChanged() || validator5.isChanged() || validator6.isChanged() || validator7.isChanged() || validator8.isChanged() || validator9.isChanged() || validator10.isChanged() || validator11.isChanged()}"
valid="{validator0.isValid() && validator1.isValid() && validator2.isValid() && validator3.isValid() && validator4.isValid() && validator5.isValid() && validator6.isValid() && validator7.isValid() && validator8.isValid() && validator9.isValid() && validator10.isValid() && validator11.isValid()}" />
-
- <script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setStrategyMonthInfo0(null);
- setStrategyMonthInfo1(null);
- setStrategyMonthInfo2(null);
- setStrategyMonthInfo3(null);
- setStrategyMonthInfo4(null);
- setStrategyMonthInfo5(null);
- setStrategyMonthInfo6(null);
- setStrategyMonthInfo7(null);
- setStrategyMonthInfo8(null);
- setStrategyMonthInfo9(null);
- setStrategyMonthInfo10(null);
- setStrategyMonthInfo11(null);
- fieldStrategyProportion.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- setStrategyMonthInfo0(getBean().getStrategyMonthInfo().get(0));
- setStrategyMonthInfo1(getBean().getStrategyMonthInfo().get(1));
- setStrategyMonthInfo2(getBean().getStrategyMonthInfo().get(2));
- setStrategyMonthInfo3(getBean().getStrategyMonthInfo().get(3));
- setStrategyMonthInfo4(getBean().getStrategyMonthInfo().get(4));
- setStrategyMonthInfo5(getBean().getStrategyMonthInfo().get(5));
- setStrategyMonthInfo6(getBean().getStrategyMonthInfo().get(6));
- setStrategyMonthInfo7(getBean().getStrategyMonthInfo().get(7));
- setStrategyMonthInfo8(getBean().getStrategyMonthInfo().get(8));
- setStrategyMonthInfo9(getBean().getStrategyMonthInfo().get(9));
- setStrategyMonthInfo10(getBean().getStrategyMonthInfo().get(10));
- setStrategyMonthInfo11(getBean().getStrategyMonthInfo().get(11));
- setProportionMetierMatrix();
- }
- }
- });
-}
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
+ <import>
+ org.apache.commons.lang3.StringUtils
+ </import>
-/*@Override
-public void refresh() {
- //getSaveVerifier().addCurrentPanel(strategyJanuary, strategyFebuary, strategyMarch,
- // strategyApril, strategyMay, strategyJune,
- // strategyJuly, strategyAugust, strategySeptember,
- // strategyOctober, strategyNovember, strategyDecember);
-}*/
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- strategyJanuary.setLayer(active);
- strategyFebuary.setLayer(active);
- strategyMarch.setLayer(active);
- strategyApril.setLayer(active);
- strategyMay.setLayer(active);
- strategyJune.setLayer(active);
- strategyJuly.setLayer(active);
- strategyAugust.setLayer(active);
- strategySeptember.setLayer(active);
- strategyOctober.setLayer(active);
- strategyNovember.setLayer(active);
- strategyDecember.setLayer(active);
-}
-protected void setProportionMetierMatrix() {
- MatrixND prop = getBean().getProportionMetier();
- if (prop != null) {
- fieldStrategyProportion.setMatrix(prop.copy());
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
- else {
- fieldStrategyProportion.setMatrix(null);
+
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ strategyJanuary.setLayer(active);
+ strategyFebuary.setLayer(active);
+ strategyMarch.setLayer(active);
+ strategyApril.setLayer(active);
+ strategyMay.setLayer(active);
+ strategyJune.setLayer(active);
+ strategyJuly.setLayer(active);
+ strategyAugust.setLayer(active);
+ strategySeptember.setLayer(active);
+ strategyOctober.setLayer(active);
+ strategyNovember.setLayer(active);
+ strategyDecember.setLayer(active);
}
-}
-protected void strategyProportionMatrixChanged(MatrixPanelEvent event) {
- MatrixND mat = fieldStrategyProportion.getMatrix();
- if (getBean() != null && mat != null) {
- getBean().setProportionMetier(mat.copy());
- }
-}
]]></script>
+
<JPanel id='body'>
<Table constraints='BorderLayout.CENTER'>
<row>
@@ -253,7 +194,7 @@
<row>
<cell fill='both' weightx='1' weighty='1' columns="4">
<org.nuiton.math.matrix.gui.MatrixPanelEditor id="fieldStrategyProportion"
- onMatrixChanged="strategyProportionMatrixChanged(event)"
+ onMatrixChanged="handler.strategyProportionMatrixChanged(event)"
enabled='{isActive()}' decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Strategy.class}' _sensitivityMethod='"ProportionMetier"'/>
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,73 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Strategy one month info handler.
+ */
+public class StrategyOneMonthInfoHandler extends InputContentHandler<StrategyOneMonthInfoUI> {
+
+ protected boolean init;
+
+ protected void init(final StrategyOneMonthInfoUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyOneMonthInfoUI.PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ refresh();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void refresh() {
+ if (inputContentUI.getStrategyMonthInfo() != null) {
+ inputContentUI.numberOfTrips.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId());
+ inputContentUI.fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId());
+
+ GenericComboModel<TripType> model = new GenericComboModel<>(inputContentUI.getFisheryRegion().getTripType());
+ inputContentUI.fieldStrategyMonthInfoTripType.setModel(model);
+ inputContentUI.fieldStrategyMonthInfoTripType.setSelectedItem(inputContentUI.getStrategyMonthInfo().getTripType());
+ }
+ else {
+ // don't put in addPropertyChangeListener
+ // if called after, remove content :(
+ inputContentUI.numberOfTrips.setText("");
+ inputContentUI.fieldStrategyMonthInfoMinInactivityDays.setText("");
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,51 +31,14 @@
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Strategy
- fr.ifremer.isisfish.entities.StrategyMonthInfo
- fr.ifremer.isisfish.entities.TripType
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <StrategyOneMonthInfoHandler id="handler" />
<script><![CDATA[
-protected boolean init;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
- refresh();
- init = false;
- }
- }
- });
-}
-
-public void refresh() {
- if (getStrategyMonthInfo() != null) {
- numberOfTrips.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId());
- fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId());
-
- GenericComboModel<TripType> model = new GenericComboModel<>(getFisheryRegion().getTripType());
- fieldStrategyMonthInfoTripType.setModel(model);
- fieldStrategyMonthInfoTripType.setSelectedItem(getStrategyMonthInfo().getTripType());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- else {
- // don't put in addPropertyChangeListener
- // if called after, remove content :(
- numberOfTrips.setText("");
- fieldStrategyMonthInfoMinInactivityDays.setText("");
- }
-}
-
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -88,7 +51,7 @@
<JComboBox id="fieldStrategyMonthInfoTripType"
genericType="fr.ifremer.isisfish.entities.TripType"
onActionPerformed='getStrategyMonthInfo().setTripType((TripType)fieldStrategyMonthInfoTripType.getSelectedItem())'
- renderer='{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer(true)}'
+ renderer='{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer(true)}'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.SetOfVessels;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Strategy tab handler.
+ */
+public class StrategyTabHandler extends InputContentHandler<StrategyTabUI> {
+
+ protected boolean init;
+
+ protected void init(final StrategyTabUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldStrategyName.setText("");
+ inputContentUI.fieldStrategyProportionSetOfVessels.setText("");
+ inputContentUI.fieldStrategyComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ setSetOfVesselsModel();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void setSetOfVesselsModel() {
+ GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getSetOfVessels());
+ inputContentUI.fieldStrategySetOfVessels.setModel(modelVessel);
+ inputContentUI.fieldStrategySetOfVessels.setSelectedItem(inputContentUI.getBean().getSetOfVessels());
+ }
+
+ protected void setOfVesselsChanged() {
+ if (!init) {
+ inputContentUI.getBean().setSetOfVessels((SetOfVessels)inputContentUI.fieldStrategySetOfVessels.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,13 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Strategy
- fr.ifremer.isisfish.entities.SetOfVessels
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <StrategyTabHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy'
@@ -42,66 +36,11 @@
</BeanValidator>
<script><![CDATA[
-protected boolean init;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldStrategyName.setText("");
- fieldStrategyProportionSetOfVessels.setText("");
- fieldStrategyComment.setText("");
- }
- if (evt.getNewValue() != null) {
- init = true;
- setSetOfVesselsModel();
- init = false;
- }
- }
- });
-}
-
-/*public void refresh() {
- //Strategy strategy = (Strategy)getSaveVerifier().getEntity(Strategy.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(strategy);
-
- if (getBean() != null) {
- setSetOfVesselsModel();
- //fieldStrategyProportionSetOfVessels.init();
-
- // code to replace bindings :
- strategyInactivity.setActive(isActive() && getBean().isInactivityEquationUsed());
-
- //getSaveVerifier().addCurrentPanel(strategyInactivity);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- else {
- // listener seam to be called after refresh and remove content :(
- fieldStrategyName.setText("");
- //fieldStrategyProportionSetOfVessels.setModelText("0.0");
- fieldStrategyProportionSetOfVessels.setText("0.0");
- fieldStrategyComment.setText("");
-
- // code to replace bindings :
- strategyInactivity.setActive(isActive());
- }
-}*/
-
-protected void setSetOfVesselsModel() {
- GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(getFisheryRegion().getSetOfVessels());
- fieldStrategySetOfVessels.setModel(modelVessel);
- fieldStrategySetOfVessels.setSelectedItem(getBean().getSetOfVessels());
-}
-
-protected void setOfVesselsChanged() {
- if (!init) {
- getBean().setSetOfVessels((SetOfVessels)fieldStrategySetOfVessels.getSelectedItem());
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -122,7 +61,7 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldStrategySetOfVessels"
genericType="fr.ifremer.isisfish.entities.SetOfVessels"
- onItemStateChanged='setOfVesselsChanged()'
+ onItemStateChanged='handler.setOfVesselsChanged()'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
@@ -147,7 +86,8 @@
<cell fill='horizontal' weightx='1.0'>
<JCheckBox id="fieldUseEquationInactivity" selected='{getBean().isInactivityEquationUsed()}'
text="isisfish.strategy.inactivityEquationUsed"
- onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActive()}' decorator='boxed'/>
+ onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())'
+ enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
<row>
@@ -166,7 +106,8 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.5'>
<JScrollPane>
- <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/>
+ <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}'
+ onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,37 +26,27 @@
<fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <StrategyHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueObservations"));
- setNextPath(n("isisfish.input.tree.observations"));
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(strategyTab);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(strategyMonthInfoUI, strategyTabUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- strategyTabUI.setLayer(active);
- strategyMonthInfoUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- strategyTabUI.resetChangeModel();
- strategyMonthInfoUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ strategyTabUI.setLayer(active);
+ strategyMonthInfoUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ strategyTabUI.resetChangeModel();
+ strategyMonthInfoUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="strategyTab">
<tab title='isisfish.strategy.title'>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -23,7 +23,6 @@
package fr.ifremer.isisfish.ui.input.tree;
-import javax.swing.JOptionPane;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
@@ -104,7 +103,7 @@
// check for non validated modification
InputSaveVerifier inputSaveVerifier = ui.getContextValue(InputSaveVerifier.class);
- if (inputSaveVerifier.checkEdit() == JOptionPane.CANCEL_OPTION) {
+ if (inputSaveVerifier.checkEdit() == InputSaveVerifier.CANCEL_OPTION) {
result = false;
}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.triptype;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Trip type handler.
+ */
+public class TripTypeHandler extends InputContentHandler<TripTypeUI> {
+
+ protected void init(final TripTypeUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueVesselTypes"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.vesseltypes"));
+
+ inputContentUI.addPropertyChangeListener(TripTypeUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldTripTypeName.setText("");
+ inputContentUI.fieldTripTypeDuration.setText("");
+ inputContentUI.fieldTripTypeMinTimeBetweenTrip.setText("");
+ inputContentUI.fieldTripTypeComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,85 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.triptype;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.TripType;
+
+/**
+ * Renderer pour liste des trip types.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TripTypeListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /** Append trip type details. */
+ protected boolean appendDetails;
+
+ public TripTypeListRenderer() {
+ this(false);
+ }
+
+ public TripTypeListRenderer(boolean appendDetails) {
+ this.appendDetails = appendDetails;
+ }
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alternated highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ TripType tripType = (TripType) value;
+ if (tripType != null) {
+ if (appendDetails) {
+ c.setText(tripType.getName() + "(" + tripType.getTripDuration() + ":"
+ + tripType.getMinTimeBetweenTrip() + ")");
+ } else {
+ c.setText(tripType.getName());
+ }
+ }
+
+ return c;
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.TripType id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.TripType
- fr.ifremer.isisfish.types.TimeUnit
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <TripTypeHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.TripType'
@@ -42,36 +35,16 @@
<field name="name" component="fieldTripTypeName" />
</BeanValidator>
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
+
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueVesselTypes"));
- setNextPath(n("isisfish.input.tree.vesseltypes"));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldTripTypeName.setText("");
- fieldTripTypeDuration.setText("");
- fieldTripTypeMinTimeBetweenTrip.setText("");
- fieldTripTypeComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-/*public void refresh() {
- TripType tripType = (TripType)getSaveVerifier().getEntity(TripType.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(tripType);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -42,6 +42,8 @@
import fr.ifremer.isisfish.entities.Variable;
import fr.ifremer.isisfish.entities.VariableDAO;
import fr.ifremer.isisfish.entities.VariableType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.vesseltype.VesselTypeUI;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
/**
@@ -53,28 +55,44 @@
* Last update : $Date$
* By : $Author$
*/
-public class EntityVariableHandler {
+public class EntityVariableHandler extends InputContentHandler<EntityVariableUI> {
/** Class logger. */
private static final Log log = LogFactory.getLog(EntityVariableHandler.class);
+ protected void init(final EntityVariableUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_BEAN, new java.beans.PropertyChangeListener() {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ reloadVariables();
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.matrixPanel.setMatrix(null);
+ }
+ }
+ });
+ }
+
/**
* Init view with currently entity variables.
- *
- * @param view view
*/
- public void initView(EntityVariableUI view) {
+ protected void reloadVariables() {
// clear previous
- view.getVariablesList().clearSelection();
+ inputContentUI.getVariablesList().clearSelection();
// fill current list
List<Variable> variables = null;
- GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
- TopiaEntity bean = view.getBean();
+ GenericListModel<Variable> model = (GenericListModel<Variable>)inputContentUI.getVariablesList().getModel();
+ TopiaEntity bean = inputContentUI.getBean();
if (bean != null) {
try {
- TopiaContext context = view.getTopiaContext();
+ TopiaContext context = inputContentUI.getTopiaContext();
VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
variables = dao.findAllByEntityId(bean.getTopiaId());
} catch (TopiaException ex) {
@@ -83,15 +101,15 @@
// try to set entity name in label
try {
- String name = BeanUtils.getProperty(view.getBean(), "name");
- view.getVariableEntityName().setText(name);
+ String name = BeanUtils.getProperty(inputContentUI.getBean(), "name");
+ inputContentUI.getVariableEntityName().setText(name);
} catch (Exception ex) {
if (log.isWarnEnabled()) {
log.warn("Can't get entity name", ex);
}
}
} else {
- view.getVariableEntityName().setText("");
+ inputContentUI.getVariableEntityName().setText("");
}
model.setElementList(variables);
@@ -162,20 +180,6 @@
view.setVariable(variable);
view.getSaveVerifier().addCurrentEntity(variable);
- /*if (variable != null) {
- view.getVariableNameField().setText(variable.getName());
-
- String type = variable.getType();
- view.getVariableTypeCombo().setSelectedItem(type); // fire showSelectedType
-
- if ("double".equals(type)) {
- view.getVariableDoubleValue().setText(String.valueOf(variable.getDoubleValue()));
- } else if ("matrix".equals(type)) {
- //view.get
- } else if ("equation".equals(type)) {
- //cardLayout.show(view.getVariableTypePanel(), "equationtype");
- }
- }*/
}
/**
@@ -228,20 +232,11 @@
break;
} // equation already set by ui component
- //try {
- // save in db
- //TopiaContext context = view.getTopiaContext();
- //VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
- //dao.update(variable);
- //context.commitTransaction();
- view.getSaveVerifier().save();
+ view.getSaveVerifier().save();
- // refresh ui (name change)
- GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
- List<Variable> variables = model.getElementList();
- model.setElementList(variables);
- /*} catch (TopiaException ex) {
- throw new IsisFishRuntimeException("Can't save variable", ex);
- }*/
+ // refresh ui (name change)
+ GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
+ List<Variable> variables = model.getElementList();
+ model.setElementList(variables);
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -23,46 +23,31 @@
#L%
-->
<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
- <EntityVariableHandler id="varHandler" />
<!-- bean property -->
<org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.Variable id="variable" javaBean='null' />
+
+ <EntityVariableHandler id="handler" />
<script><![CDATA[
protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new java.beans.PropertyChangeListener() {
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- varHandler.initView(EntityVariableUI.this);
- }
- });
-
- addPropertyChangeListener(PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() {
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- matrixPanel.setMatrix(null);
- }
- }
- });
+ handler.init(this);
}
]]></script>
<Table>
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
- <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variableslist"))}'>
+ <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variableslist"))}'>
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="variablesList" cellRenderer="{new VariableListRenderer()}"
genericType='fr.ifremer.isisfish.entities.Variable'
model="{new fr.ifremer.isisfish.ui.models.common.GenericListModel<Variable>()}"
- onValueChanged="getVarHandler().showSelectedVariable(this)"
+ onValueChanged="handler.showSelectedVariable(this)"
selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
enabled='{isActive()}'/>
</JScrollPane>
@@ -70,14 +55,14 @@
</row>
<row>
<cell fill="horizontal">
- <JButton text="isisfish.variables.addvariable" onActionPerformed="getVarHandler().addNewVariable(this)"
+ <JButton text="isisfish.variables.addvariable" onActionPerformed="handler.addNewVariable(this)"
enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
</Table>
</cell>
<cell fill="both" weightx='3.0' weighty='1.0' rows="2">
- <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variabledetail"))}'>
+ <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variabledetail"))}'>
<row>
<cell fill="horizontal">
<JLabel text="isisfish.variables.entityname"
@@ -95,11 +80,8 @@
</cell>
<cell fill="horizontal" weightx='1.0'>
<JTextField id="variableNameField" text="{getVariable().getName()}"
- enabled='{isActive() && getVariable() != null}' decorator='boxed' />
- <javax.swing.text.Document
- initializer="variableNameField.getDocument()"
- onInsertUpdate='getVariable().setName(variableNameField.getText())'
- onRemoveUpdate='getVariable().setName(variableNameField.getText())' />
+ enabled='{isActive() && getVariable() != null}' decorator='boxed'
+ onKeyReleased="getVariable().setName(variableNameField.getText())" />
</cell>
</row>
<row>
@@ -108,10 +90,11 @@
enabled='{isActive() && getVariable() != null}'/>
</cell>
<cell fill="horizontal" weightx='1.0'>
- <JComboBox id="variableTypeCombo" model="{new GenericComboModel<fr.ifremer.isisfish.entities.Variable>()}"
- genericType="fr.ifremer.isisfish.entities.Variable"
+ <JComboBox id="variableTypeCombo"
+ model="{new fr.ifremer.isisfish.ui.models.common.EnumComboModel<fr.ifremer.isisfish.entities.VariableType>(fr.ifremer.isisfish.entities.VariableType.class)}"
+ genericType="fr.ifremer.isisfish.entities.VariableType"
selectedItem="{getVariable().getType()}"
- onActionPerformed="getVarHandler().showSelectedType(this)"
+ onActionPerformed="handler.showSelectedType(this)"
enabled='{isActive() && getVariable() != null}' decorator='boxed' />
</cell>
</row>
@@ -121,9 +104,9 @@
<JPanel id="variableTypePanel" layout="{variableTypeLayout}">
<!-- double -->
- <Table constraints='"doubletype"'>
+ <Table constraints='"doubletype"' insets="0">
<row>
- <cell fill="horizontal" anchor="northeast" weighty='1.0'>
+ <cell fill="horizontal" anchor="east" weighty='1.0'>
<JLabel text="isisfish.variables.double.value" enabled='{isActive() && getVariable() != null}' />
</cell>
<cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'>
@@ -136,7 +119,7 @@
</Table>
<!-- matrix -->
- <Table constraints='"matrixtype"'>
+ <Table constraints='"matrixtype"' insets="0">
<row>
<cell fill="horizontal">
<JLabel text="isisfish.variables.matrix.value"
@@ -155,7 +138,7 @@
</Table>
<!-- equation -->
- <Table constraints='"equationtype"'>
+ <Table constraints='"equationtype"' insets="0">
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue"
@@ -181,24 +164,21 @@
<JScrollPane>
<JTextArea id="variableComment" rows="3"
text="{jaxx.runtime.SwingUtil.getStringValue(getVariable().getComment())}"
- enabled='{isActive() && getVariable() != null}' decorator='boxed' />
- <javax.swing.text.Document
- initializer="variableComment.getDocument()"
- onInsertUpdate='getVariable().setComment(variableComment.getText())'
- onRemoveUpdate='getVariable().setComment(variableComment.getText())' />
+ enabled='{isActive() && getVariable() != null}' decorator='boxed'
+ onKeyReleased="getVariable().setComment(variableComment.getText())" />
</JScrollPane>
</cell>
</row>
<row>
<cell anchor="west">
<JButton text="isisfish.variables.deletevariable"
- onActionPerformed="getVarHandler().deleteVariable(this)"
+ onActionPerformed="handler.deleteVariable(this)"
enabled='{isActive() && getVariable() != null}'
decorator='boxed' />
</cell>
<cell anchor="east" weightx='1.0'>
<JButton text="isisfish.variables.savevariable"
- onActionPerformed="getVarHandler().saveVariable(this)"
+ onActionPerformed="handler.saveVariable(this)"
enabled='{isActive() && getVariable() != null}'
decorator='boxed' />
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,91 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.vesseltype;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Trip type handler.
+ */
+public class VesselTypeHandler extends InputContentHandler<VesselTypeUI> {
+
+ protected boolean init;
+
+ protected void init(final VesselTypeUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueSetOfVessels"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.setofvessels"));
+
+ inputContentUI.addPropertyChangeListener(VesselTypeUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldVesselTypeName.setText("");
+ inputContentUI.fieldVesselTypeLength.setText("");
+ inputContentUI.fieldVesselTypeSpeed.setText("");
+ inputContentUI.fieldVesselTypeMaxTripDuration.setText("");
+ inputContentUI.fieldVesselTypeActivityRange.setText("");
+ inputContentUI.fieldVesselTypeMinCrewSize.setText("");
+ inputContentUI.fieldVesselTypeSpeed.setText("");
+ inputContentUI.fieldVesselTypeUnitFuelCostOfTravel.setText("");
+ inputContentUI.fieldVesselTypeComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ setTripTypeListModel();
+ }
+ }
+ });
+ }
+
+ protected void setTripTypeListModel() {
+ init = true;
+ List<TripType> tripTypes = inputContentUI.getFisheryRegion().getTripType();
+ GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes);
+ inputContentUI.vesselTypeTripType.setModel(tripTypeModel);
+
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getTripType() != null) {
+ for (TripType tripType : inputContentUI.getBean().getTripType()) {
+ int index = tripTypes.indexOf(tripType);
+ inputContentUI.vesselTypeTripType.addSelectionInterval(index, index);
+ }
+ }
+ init = false;
+ }
+ protected void tripTypeChanged() {
+ if (!init) {
+ List<TripType> tripTypes = new ArrayList<>(inputContentUI.vesselTypeTripType.getSelectedValuesList());
+ inputContentUI.getBean().setTripType(tripTypes);
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,16 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.VesselType id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.VesselType
- fr.ifremer.isisfish.entities.TripType
- fr.ifremer.isisfish.types.TimeUnit
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <VesselTypeHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.VesselType'
@@ -44,76 +35,16 @@
<field name="name" component="fieldVesselTypeName" />
</BeanValidator>
- <script><![CDATA[
-protected boolean init;
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueSetOfVessels"));
- setNextPath(n("isisfish.input.tree.setofvessels"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldVesselTypeName.setText("");
- fieldVesselTypeLength.setText("");
- fieldVesselTypeSpeed.setText("");
- fieldVesselTypeMaxTripDuration.setText("");
- fieldVesselTypeActivityRange.setText("");
- fieldVesselTypeMinCrewSize.setText("");
- fieldVesselTypeSpeed.setText("");
- fieldVesselTypeUnitFuelCostOfTravel.setText("");
- fieldVesselTypeComment.setText("");
- }
- if (evt.getNewValue() != null) {
- setTripTypeListModel();
- }
- }
- });
-}
-
-/*public void refresh() {
- VesselType vesselType = getSaveVerifier().getEntity(VesselType.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(vesselType);
-
- if (getBean() != null) {
- setListModel();
-
- // NumberEditor is not working
- //fieldVesselTypeLength.init();
- //fieldVesselTypeLength.init();
- //fieldVesselTypeSpeed.init();
- //fieldVesselTypeActivityRange.init();
- //fieldVesselTypeMinCrewSize.init();
- //fieldVesselTypeSpeed.init();
- //fieldVesselTypeUnitFuelCostOfTravel.init();
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}*/
-
-protected void setTripTypeListModel() {
- init = true;
- List<TripType> tripTypes = getFisheryRegion().getTripType();
- GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes);
- vesselTypeTripType.setModel(tripTypeModel);
-
- if (getBean() != null && getBean().getTripType() != null) {
- for (TripType tripType : getBean().getTripType()) {
- int index = tripTypes.indexOf(tripType);
- vesselTypeTripType.addSelectionInterval(index, index);
- }
- }
- init = false;
-}
-protected void tripTypeChanged() {
- if (!init) {
- List<TripType> tripTypes = new ArrayList<TripType>(vesselTypeTripType.getSelectedValuesList());
- getBean().setTripType(tripTypes);
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -214,9 +145,9 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane>
- <JList id="vesselTypeTripType" onValueChanged='tripTypeChanged()'
+ <JList id="vesselTypeTripType" onValueChanged='handler.tripTypeChanged()'
genericType="fr.ifremer.isisfish.entities.TripType"
- cellRenderer="{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer()}"
+ cellRenderer="{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer()}"
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{VesselType.class}' _sensitivityMethod='"TripType"'/>
</JScrollPane>
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,124 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+
+package fr.ifremer.isisfish.ui.input.zone;
+
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.event.ListSelectionEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.bbn.openmap.event.SelectMouseMode;
+
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.map.CellSelectionLayer;
+import fr.ifremer.isisfish.map.OpenMapEvents;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Zone handler.
+ */
+public class ZoneBasicsHandler extends InputContentHandler<ZoneBasicsUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ZoneBasicsHandler.class);
+
+ protected void init(final ZoneBasicsUI zoneBasicsUI) {
+ super.init(zoneBasicsUI);
+
+ new OpenMapEvents(zoneBasicsUI.zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) {
+ @Override
+ public boolean mouseClicked(MouseEvent e) {
+ boolean result = false;
+ if (zoneBasicsUI.getBean() != null) { // impossible de desactiver la carte :(
+ zoneBasicsUI.getBean().setCell(zoneBasicsUI.zoneMap.getSelectedCells());
+ setZoneCells();
+ }
+ return result;
+ }
+ };
+
+ zoneBasicsUI.addPropertyChangeListener(ZoneBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ zoneBasicsUI.fieldZoneName.setText("");
+ zoneBasicsUI.fieldZoneComment.setText("");
+ zoneBasicsUI.zoneMap.setSelectedCells();
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setZoneCells();
+ }
+ });
+ }
+
+ protected void setZoneCells() {
+ GenericListModel<Cell> zoneModel = new GenericListModel<>();
+ if (inputContentUI.getBean() != null) {
+
+ // build model
+ List<Cell> cells = inputContentUI.getFisheryRegion().getCell();
+ zoneModel.setElementList(cells);
+ inputContentUI.zoneCells.setModel(zoneModel);
+
+ // restore selection
+ int firstIndex = -1;
+ if (inputContentUI.getBean().getCell() != null) {
+ for (Cell selectedCell : inputContentUI.getBean().getCell()) {
+ int index = cells.indexOf(selectedCell);
+ inputContentUI.zoneCells.addSelectionInterval(index, index);
+
+ if (firstIndex == -1) {
+ firstIndex = index;
+ }
+ }
+ }
+
+ // sroll to visible
+ if (firstIndex != -1) {
+ inputContentUI.zoneCells.ensureIndexIsVisible(firstIndex);
+ }
+ } else {
+ inputContentUI.zoneCells.setModel(zoneModel);
+ }
+ }
+
+ public void zoneCellsChange(ListSelectionEvent event) {
+ // sans ca, ca boucle (modification depuis la carte)
+ if (event.getValueIsAdjusting()) {
+ // pas a faie dans le cas d'une AS
+ if (inputContentUI.isActive()) {
+ List<Cell> cells = new ArrayList<>(inputContentUI.zoneCells.getSelectedValuesList());
+ inputContentUI.getBean().setCell(cells);
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Zone id='bean' javaBean='null'/>
- <import>
- javax.swing.event.ListSelectionEvent
- fr.ifremer.isisfish.entities.Cell
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.map.CellSelectionLayer
- fr.ifremer.isisfish.map.CopyMapToClipboardListener
- fr.ifremer.isisfish.map.OpenMapEvents
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- com.bbn.openmap.event.SelectMouseMode
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.event.MouseEvent
- java.util.ArrayList
- </import>
+ <ZoneBasicsHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Zone'
@@ -50,68 +37,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
-
- //zoneMap.init(zoneMapInfo);
- new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) {
- @Override
- public boolean mouseClicked(MouseEvent e) {
- boolean result = false;
- if (getBean() != null) { // impossible de desactiver la carte :(
- getBean().setCell(zoneMap.getSelectedCells());
- setZoneCells();
- }
- return result;
- }
- };
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldZoneName.setText("");
- fieldZoneComment.setText("");
- zoneMap.setSelectedCells();
- }
- if (evt.getNewValue() != null) {
-
- }
- setZoneCells();
- }
- });
-}
-
-protected void setZoneCells() {
- GenericListModel<Cell> zoneModel = new GenericListModel<Cell>();
- if (getBean() != null) {
- List<Cell> cells = getFisheryRegion().getCell();
- zoneModel.setElementList(cells);
- zoneCells.setModel(zoneModel);
- if (getBean().getCell() != null) {
- for (Cell selectedCell : getBean().getCell()) {
- int index = cells.indexOf(selectedCell);
- zoneCells.addSelectionInterval(index, index);
- }
- }
- } else {
- zoneCells.setModel(zoneModel);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void zoneCellsChange(ListSelectionEvent event) {
- // sans ca, ca boucle (modification depuis la carte)
- if (event.getValueIsAdjusting()) {
- // pas a faie dans le cas d'une AS
- if (isActive()) {
- List<Cell> cells = new ArrayList<Cell>();
- for (Cell o : zoneCells.getSelectedValuesList()) {
- cells.add(o);
- }
- getBean().setCell(cells);
- }
- }
-}
-]]>
- </script>
<JPanel id='body'>
<JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="horizontal">
<Table>
@@ -138,7 +68,7 @@
<JScrollPane id="spZoneCells">
<JList id="zoneCells" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Cell"
- onValueChanged='zoneCellsChange(event)' decorator='boxed'/>
+ onValueChanged='handler.zoneCellsChange(event)' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,9 +26,6 @@
import static org.nuiton.i18n.I18n.n;
import static org.nuiton.i18n.I18n.t;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import fr.ifremer.isisfish.ui.input.InputContentHandler;
/**
@@ -36,17 +33,14 @@
*/
public class ZoneHandler extends InputContentHandler<ZoneUI> {
- /** Class logger. */
- private static final Log log = LogFactory.getLog(ZoneHandler.class);
+ protected void init(final ZoneUI inputContentUI) {
+ super.init(inputContentUI);
- protected void init(final ZoneUI zoneUI) {
- super.init(zoneUI);
+ inputContentUI.setButtonTitle(t("isisfish.input.continuePorts"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.ports"));
- zoneUI.setButtonTitle(t("isisfish.input.continuePorts"));
- zoneUI.setNextPath(n("isisfish.input.tree.ports"));
-
// install change listener
// (depends on sensitivity can't be done on constructor)
- zoneUI.installChangeListener(zoneUI.zoneTab);
+ inputContentUI.installChangeListener(inputContentUI.zoneTab);
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,22 +29,22 @@
<ZoneHandler id="handler" />
<script><![CDATA[
- protected void $afterCompleteSetup() {
- handler.init(this);
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- @Override
- public void setLayer(boolean active) {
- super.setLayer(active);
- zoneBasicsUI.setLayer(active);
- variablesUI.setLayer(active);
- }
-
- @Override
- public void resetChangeModel() {
- zoneBasicsUI.resetChangeModel();
- variablesUI.resetChangeModel();
- }
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ zoneBasicsUI.setLayer(active);
+ variablesUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ zoneBasicsUI.resetChangeModel();
+ variablesUI.resetChangeModel();
+ }
]]></script>
<JPanel id="body">
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric
+ * %%
+ * 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%
+ */
+package fr.ifremer.isisfish.ui.models.common;
+
+import org.jdesktop.swingx.combobox.EnumComboBoxModel;
+
+/**
+ * Just a delegator class to not use external API in Isis.
+ *
+ * @author Eric Chatellier
+ *
+ * @param <E> enum type
+ */
+public class EnumComboModel<E extends Enum<E>> extends EnumComboBoxModel<E>{
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -912859822412819321L;
+
+ public EnumComboModel(Class<E> en) {
+ super(en);
+ }
+
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/resources/i18n/isis-fish_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-20 12:09:09 UTC (rev 4227)
@@ -990,7 +990,7 @@
isisfish.variables.variabledetail=Variable details
isisfish.variables.variablename=Variable name \:
isisfish.variables.variableslist=Variables
-isisfish.variables.variabletype=Variable type
+isisfish.variables.variabletype=Variable type \:
isisfish.vcs.ask.passphrase=Enter your pass phrase (if your private key have one).
isisfish.vcs.ask.passphrase.title=Ask your pass phrase
isisfish.vcs.commit=vcs.commit
1
0
r4226 - in trunk: . src/test/java/fr/ifremer/isisfish/ui src/test/java/fr/ifremer/isisfish/ui/input
by echatellier@users.forge.codelutin.com 18 May '15
by echatellier@users.forge.codelutin.com 18 May '15
18 May '15
Author: echatellier
Date: 2015-05-18 09:52:01 +0000 (Mon, 18 May 2015)
New Revision: 4226
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4226
Log:
Update libs.
Move from fest to assertj.
Modified:
trunk/pom.xml
trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/pom.xml 2015-05-18 09:52:01 UTC (rev 4226)
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
- <version>5.0.3</version>
+ <version>5.0.4</version>
<scope>compile</scope>
</dependency>
@@ -237,29 +237,29 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-jcl</artifactId>
- <version>2.2</version>
- <scope>runtime</scope>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jcl</artifactId>
+ <version>2.3</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <version>2.2</version>
- <scope>runtime</scope>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>2.3</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
@@ -387,13 +387,19 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
- <groupId>org.easytesting</groupId>
- <artifactId>fest-swing</artifactId>
- <version>1.2.1</version>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-swing</artifactId>
+ <version>2.0.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-swing-junit</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
===================================================================
--- trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-18 09:52:01 UTC (rev 4226)
@@ -24,11 +24,11 @@
*/
package fr.ifremer.isisfish.ui;
-import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
-import org.fest.swing.edt.GuiActionRunner;
-import org.fest.swing.edt.GuiQuery;
-import org.fest.swing.exception.WaitTimedOutError;
-import org.fest.swing.fixture.FrameFixture;
+import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
+import org.assertj.swing.edt.GuiActionRunner;
+import org.assertj.swing.edt.GuiQuery;
+import org.assertj.swing.exception.WaitTimedOutError;
+import org.assertj.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@@ -47,7 +47,7 @@
protected FrameFixture mainWindow;
@BeforeClass
- public static void setUpOnce() {
+ public static void setUpOnce() throws Exception {
Assume.assumeTrue(!java.awt.GraphicsEnvironment.isHeadless());
FailOnThreadViolationRepaintManager.install();
}
Modified: trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java
===================================================================
--- trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java 2015-05-18 09:52:01 UTC (rev 4226)
@@ -28,7 +28,7 @@
import java.io.IOException;
import org.apache.commons.lang3.SystemUtils;
-import org.fest.swing.core.matcher.JButtonMatcher;
+import org.assertj.swing.core.matcher.JButtonMatcher;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -83,9 +83,10 @@
public void testImportRegion() throws IOException {
openDemoRegion();
mainWindow.menuItem("menuRegionExport").click();
- File f = new File(SystemUtils.JAVA_IO_TMPDIR, "isis-export.zip");
+ File f = File.createTempFile("isis-export", ".zip"); // bug file exists
f.deleteOnExit();
mainWindow.fileChooser().selectFile(f).approve();
+ mainWindow.optionPane().yesButton().click(); // bug file exists
mainWindow.menuItem("menuRegionImportRename").click();
mainWindow.fileChooser().selectFile(f).approve();
1
0