Author: echatellier Date: 2015-06-08 13:47:32 +0000 (Mon, 08 Jun 2015) New Revision: 4246 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4246 Log: Commit *Action classes refactoring to branch Added: branches/isis-fish-4.4.0-ui-refactoring/ branches/isis-fish-4.4.0-ui-refactoring/pom.xml branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationHandler.java Removed: branches/isis-fish-4.4.0-ui-refactoring/pom.xml branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/aspect/AspectJWeavingAdaptor.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationUI.jaxx branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java Deleted: branches/isis-fish-4.4.0-ui-refactoring/pom.xml =================================================================== --- trunk/pom.xml 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/pom.xml 2015-06-08 13:47:32 UTC (rev 4246) @@ -1,849 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.nuiton</groupId> - <artifactId>mavenpom4redmine</artifactId> - <version>6.1</version> - </parent> - - <groupId>fr.ifremer</groupId> - <artifactId>isis-fish</artifactId> - <version>4.4.0.0-SNAPSHOT</version> - - <!-- POM Relationships : Inheritance : Dependencies --> - <dependencies> - - <!-- Nuiton librairies --> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-utils</artifactId> - <version>3.0-rc-8</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-config</artifactId> - <version>3.0-rc-2</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-validator</artifactId> - <version>3.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - <version>${nuitonI18nVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-persistence</artifactId> - <version>${topiaVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-service-migration</artifactId> - <version>${topiaVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-core</artifactId> - <version>${hibernateVersion}</version> - <scope>compile</scope> - </dependency> - - <!-- Temp update for log4j 2 detection --> - <dependency> - <groupId>org.jboss.logging</groupId> - <artifactId>jboss-logging</artifactId> - <version>3.2.1.Final</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - <version>5.0.4</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-profiling</artifactId> - <version>3.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.matrix</groupId> - <artifactId>nuiton-matrix</artifactId> - <version>2.5.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.matrix</groupId> - <artifactId>nuiton-matrix-gui</artifactId> - <version>2.5.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-widgets</artifactId> - <version>${nuitonWidgetsVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>com.fifesoft</groupId> - <artifactId>rsyntaxtextarea</artifactId> - <version>2.5.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>com.fifesoft</groupId> - <artifactId>rstaui</artifactId> - <version>2.5.0</version> - </dependency> - - <dependency> - <groupId>javax.mail</groupId> - <artifactId>mail</artifactId> - <version>1.4.7</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <artifactId>activation</artifactId> - <groupId>javax.activation</groupId> - </exclusion> - </exclusions> - </dependency> - - <!-- Jaxx --> - <dependency> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-runtime</artifactId> - <version>${jaxxVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-config</artifactId> - <version>${jaxxVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-validator</artifactId> - <version>${jaxxVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-widgets</artifactId> - <version>${jaxxVersion}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.swinglabs</groupId> - <artifactId>jxlayer</artifactId> - <version>3.0.4</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-j2r</artifactId> - <version>1.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>3.4</version> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> - <version>4.0</version> - </dependency> - - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>1.9.2</version> - </dependency> - - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.4</version> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-math3</artifactId> - <version>3.5</version> - <scope>runtime</scope> <!--script --> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-email</artifactId> - <version>1.4</version> - <exclusions> - <exclusion> - <artifactId>activation</artifactId> - <groupId>javax.activation</groupId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.7.12</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.2</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>2.3</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <version>2.3</version> - <scope>compile</scope> - </dependency> - - <dependency> - <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.3</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>dom4j</groupId> - <artifactId>dom4j</artifactId> - <version>1.6.1</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <artifactId>xml-apis</artifactId> - <groupId>xml-apis</groupId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>jaxen</groupId> - <artifactId>jaxen</artifactId> - <version>1.1.6</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>com.bbn</groupId> - <artifactId>openmap</artifactId> - <version>5.1.10</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>com.jcraft</groupId> - <artifactId>jsch</artifactId> - <version>0.1.52</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.swinglabs.swingx</groupId> - <artifactId>swingx-core</artifactId> - <version>1.6.5-1</version> - <scope>compile</scope> - </dependency> - - <!-- Change this dependence if you change database --> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>1.3.176_autocommitpatch</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjweaver</artifactId> - <version>1.8.5</version> - </dependency> - - <dependency> - <groupId>net.sourceforge</groupId> - <artifactId>jdistlib</artifactId> - <version>0.3.9</version> - </dependency> - - <!-- ssj pour les calculs stockastiques --> - <dependency> - <groupId>ca.umontreal.iro</groupId> - <artifactId>ssj</artifactId> - <version>2.5</version> - <scope>runtime</scope> - <exclusions> - <exclusion> - <groupId>dsol</groupId> - <artifactId>dsol-xml</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- fin ssj pour les calculs stockastiques --> - - <!-- debut svnkit pour communication subversion --> - <dependency> - <groupId>org.tmatesoft.svnkit</groupId> - <artifactId>svnkit</artifactId> - <version>1.8.10</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <artifactId>jna</artifactId> - <groupId>net.java.dev.jna</groupId> - </exclusion> - <exclusion> - <artifactId>jsch.agentproxy.connector-factory</artifactId> - <groupId>com.jcraft</groupId> - </exclusion> - <exclusion> - <artifactId>platform</artifactId> - <groupId>net.java.dev.jna</groupId> - </exclusion> - </exclusions> - </dependency> - <!-- fin svnkit pour communication subversion --> - - <dependency> - <groupId>org.freemarker</groupId> - <artifactId>freemarker</artifactId> - <version>2.3.22</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.eclipse.jdt.core.compiler</groupId> - <artifactId>ecj</artifactId> - <version>4.4.2</version> - </dependency> - - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>18.0</version> - </dependency> - - <!-- Tests --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> - </dependency> - - <dependency> - <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> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - <name>ISIS-Fish</name> - <description>Simulateur de pecherie complexe.</description> - <inceptionYear>1999</inceptionYear> - - <url>http://doc.codelutin.com/isis-fish</url> - - <organization> - <name>CodeLutin</name> - <url>http://www.codelutin.com/</url> - </organization> - - <licenses> - <license> - <name>GPL</name> - <url>http://www.gnu.org/copyleft/gpl.html</url> - <distribution>repo</distribution> - </license> - </licenses> - - <mailingLists> - <mailingList> - <name>isis-fish-commits</name> - <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits</subscribe> - <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits</unsubscribe> - <post>isis-fish-commits@list.isis-fish.org</post> - <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits/</archive> - </mailingList> - <mailingList> - <name>isis-fish-devel</name> - <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel</subscribe> - <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel</unsubscribe> - <post>isis-fish-devel@list.isis-fish.org</post> - <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel/</archive> - </mailingList> - <mailingList> - <name>isis-fish-user</name> - <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users</subscribe> - <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users</unsubscribe> - <post>isis-fish-users@list.isis-fish.org</post> - <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users/</archive> - </mailingList> - </mailingLists> - - <issueManagement> - <system>redmine</system> - <url>http://forge.codelutin.com/projects/isis-fish/issues</url> - </issueManagement> - - <ciManagement> - <system>hudson</system> - <url>http://ci.codelutin.com/jenkins/job/isis-fish-ci</url> - </ciManagement> - - <developers> - <developer> - <id>bpoussin</id> - <name>Benjamin Poussin</name> - <email>poussin@codelutin.com</email> - <organization>CodeLutin</organization> - <roles> - <role>Développeur</role> - <role>Debian packager</role> - </roles> - <timezone>+2</timezone> - </developer> - <developer> - <id>echatellier</id> - <name>Eric Chatellier</name> - <email>chatellier@codelutin.com</email> - <organization>CodeLutin</organization> - <roles> - <role>Développeur</role> - </roles> - <timezone>+2</timezone> - </developer> - <developer> - <id>tchemit</id> - <name>Tony Chemit</name> - <email>chemit@codelutin.com</email> - <organization>CodeLutin</organization> - <roles> - <role>Développeur</role> - </roles> - <timezone>+2</timezone> - </developer> - <developer> - <id>jcouteau</id> - <name>Jean Couteau</name> - <email>couteau@codelutin.com</email> - <organization>CodeLutin</organization> - <roles> - <role>Développeur</role> - </roles> - <timezone>+2</timezone> - </developer> - </developers> - - <contributors> - <contributor> - <name>Sylvain Letellier</name> - <email>letellier@codelutin.com</email> - <organization>CodeLutin</organization> - <roles> - <role>Développeur</role> - </roles> - <timezone>+2</timezone> - </contributor> - </contributors> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - <packaging>jar</packaging> - - <properties> - <!-- Super pom properties --> - <projectId>isis-fish</projectId> - <platform>codelutin.com</platform> - <siteLocales>fr,en</siteLocales> - <siteDeployClassifier /> - <maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class> - <license.licenseName>gpl_v3</license.licenseName> - <license.organizationName>Ifremer, Codelutin</license.organizationName> - <maven.compiler.source>1.7</maven.compiler.source> - <maven.compiler.target>1.7</maven.compiler.target> - <signatureArtifactId>java17</signatureArtifactId> - <signatureVersion>1.0</signatureVersion> - - <!-- issues status to include in changelog --> - <redmine.statusIds>3,10,11,18,19</redmine.statusIds> - - <!-- Dependencies version --> - <jaxxVersion>2.24</jaxxVersion> - <eugeneVersion>2.14</eugeneVersion> - <topiaVersion>2.9.5.5</topiaVersion> - <hibernateVersion>4.3.10.Final</hibernateVersion> - <nuitonI18nVersion>3.3</nuitonI18nVersion> - <nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion> - - <redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles> - <skipPostRelease>false</skipPostRelease> - <releaseEmailDomain>forge.codelutin.com</releaseEmailDomain> - <releaseEmail>noreply@forge.codelutin.com</releaseEmail> - - <!-- jnlp (disabled until retested) - <keystorepath>${codelutin.keystorepath}</keystorepath> - <keystorealias>CodeLutin</keystorealias> - <keystorepass>codelutin</keystorepass> - <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory> - <jnlpCodebase>${project.url}</jnlpCodebase> - <jnlpCodebase>file://${jnlp.build.directory}</jnlpCodebase>--> - </properties> - - <distributionManagement> - <site> - <id>${siteDeployId}</id> - <url>${siteDeployUrl}</url> - </site> - </distributionManagement> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - <includes> - <include>isis-config-4</include> - </includes> - <filtering>true</filtering> - </resource> - <resource> - <directory>src/main/resources</directory> - <excludes> - <exclude>isis-config-4</exclude> - </excludes> - <filtering>false</filtering> - </resource> - </resources> - - <pluginManagement> - <plugins> - <plugin> - <groupId>org.nuiton.eugene</groupId> - <artifactId>eugene-maven-plugin</artifactId> - <version>${eugeneVersion}</version> - </plugin> - - <plugin> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-maven-plugin</artifactId> - <version>${jaxxVersion}</version> - <dependencies> - <dependency> - <groupId>com.fifesoft</groupId> - <artifactId>rsyntaxtextarea</artifactId> - <version>2.5.0</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <version>${nuitonI18nVersion}</version> - </plugin> - - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <mainClass>${maven.jar.main.class}</mainClass> - <classpathPrefix>lib/</classpathPrefix> - </manifest> - </archive> - </configuration> - </plugin> - - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <systemPropertyVariables> - <java.io.tmpdir>${project.build.directory}/surefire-workdir</java.io.tmpdir> - </systemPropertyVariables> - </configuration> - <executions> - <execution> - <id>surefire-it</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <includes> - <include>**/*IT.java</include> - </includes> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-site-plugin</artifactId> - <dependencies> - <dependency> - <groupId>org.nuiton.jrst</groupId> - <artifactId>doxia-module-jrst</artifactId> - <version>${jrstPluginVersion}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </pluginManagement> - - <plugins> - <plugin> - <groupId>org.nuiton.eugene</groupId> - <artifactId>eugene-maven-plugin</artifactId> - <executions> - <execution> - <id>eugene-generation</id> - <phase>generate-sources</phase> - <configuration> - <inputs>zargo</inputs> - <fullPackagePath>fr.ifremer.isisfish</fullPackagePath> - <defaultPackage>fr.ifremer.isisfish</defaultPackage> - <!--<extractedPackages>fr.ifremer.isisfish</extractedPackages> --> - <templates>org.nuiton.topia.generator.TopiaMetaTransformer</templates> - </configuration> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-persistence</artifactId> - <version>${topiaVersion}</version> - <scope>runtime</scope> - </dependency> - </dependencies> - </plugin> - - <plugin> - <groupId>org.nuiton.jaxx</groupId> - <artifactId>jaxx-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <src>${basedir}/src/main/java</src> - <addSourcesToClassPath>true</addSourcesToClassPath> - <addProjectClassPath>true</addProjectClassPath> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <configuration> - <entries> - <entry> - <basedir>${project.build.directory}/generated-sources/java/</basedir> - </entry> - </entries> - </configuration> - <executions> - <execution> - <goals> - <goal>parserJava</goal> - <goal>parserValidation</goal> - <goal>gen</goal> - <goal>bundle</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy-dependencies</id> - <configuration> - <silent>true</silent> - <outputDirectory>${project.build.directory}/lib</outputDirectory> - <useBaseVersion>false</useBaseVersion> - </configuration> - <goals> - <goal>copy-dependencies</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <scm> - <connection>scm:svn:https://svn.codelutin.com/isis-fish/trunk</connection> - <developerConnection>scm:svn:https://svn.codelutin.com/isis-fish/trunk</developerConnection> - <url>https://svn.codelutin.com/isis-fish/trunk</url> - </scm> - - <repositories> - <repository> - <id>nuiton.public</id> - <url>http://nexus.nuiton.org/nexus/content/groups/public</url> - </repository> - </repositories> - - <pluginRepositories> - <pluginRepository> - <id>nuiton.plugin.public</id> - <url>http://nexus.nuiton.org/nexus/content/groups/public</url> - </pluginRepository> - </pluginRepositories> - - <profiles> - - <!-- profile to make assembly (included in release process) --> - <profile> - <id>assembly</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <build> - <defaultGoal>package</defaultGoal> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>src/main/assembly/bin.xml</descriptor> - </descriptors> - <attach>false</attach> - <recompressZippedFiles>true</recompressZippedFiles> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - - <!-- profile with all reports (included in release process) --> - <profile> - <id>reporting</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <properties> - <!-- pmd config --> - <minimumTokens>100</minimumTokens> - <targetJdk>1.7</targetJdk> - </properties> - - <build> - <defaultGoal>site</defaultGoal> - </build> - - <reporting> - <plugins> - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <links> - <link>http://docs.oracle.com/javase/7/docs/api/</link> - <link>http://maven-site.nuiton.org/nuiton-utils/nuiton-utils/apidocs/</link> - <link>http://maven-site.nuiton.org/nuiton-matrix/nuiton-matrix/apidocs/</link> - <link>http://maven-site.nuiton.org/nuiton-j2r/apidocs/</link> - <link>http://maven-site.nuiton.org/topia/topia-persistence/apidocs/</link> - </links> - </configuration> - </plugin> - </plugins> - </reporting> - </profile> - </profiles> -</project> Copied: branches/isis-fish-4.4.0-ui-refactoring/pom.xml (from rev 4245, trunk/pom.xml) =================================================================== --- branches/isis-fish-4.4.0-ui-refactoring/pom.xml (rev 0) +++ branches/isis-fish-4.4.0-ui-refactoring/pom.xml 2015-06-08 13:47:32 UTC (rev 4246) @@ -0,0 +1,849 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>mavenpom4redmine</artifactId> + <version>6.1</version> + </parent> + + <groupId>fr.ifremer</groupId> + <artifactId>isis-fish</artifactId> + <version>4.4.0.0-SNAPSHOT</version> + + <!-- POM Relationships : Inheritance : Dependencies --> + <dependencies> + + <!-- Nuiton librairies --> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + <version>3.0-rc-8</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config</artifactId> + <version>3.0-rc-2</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-validator</artifactId> + <version>3.0</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + <version>${nuitonI18nVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-persistence</artifactId> + <version>${topiaVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-service-migration</artifactId> + <version>${topiaVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>${hibernateVersion}</version> + <scope>compile</scope> + </dependency> + + <!-- Temp update for log4j 2 detection --> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + <version>3.2.1.Final</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + <version>5.0.4</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-profiling</artifactId> + <version>3.0</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.matrix</groupId> + <artifactId>nuiton-matrix</artifactId> + <version>2.5.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.matrix</groupId> + <artifactId>nuiton-matrix-gui</artifactId> + <version>2.5.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-widgets</artifactId> + <version>${nuitonWidgetsVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>com.fifesoft</groupId> + <artifactId>rsyntaxtextarea</artifactId> + <version>2.5.0</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>com.fifesoft</groupId> + <artifactId>rstaui</artifactId> + <version>2.5.0</version> + </dependency> + + <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + <version>1.4.7</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <artifactId>activation</artifactId> + <groupId>javax.activation</groupId> + </exclusion> + </exclusions> + </dependency> + + <!-- Jaxx --> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-config</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-validator</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>jxlayer</artifactId> + <version>3.0.4</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-j2r</artifactId> + <version>1.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>4.0</version> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.9.2</version> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-math3</artifactId> + <version>3.5</version> + <scope>runtime</scope> <!--script --> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-email</artifactId> + <version>1.4</version> + <exclusions> + <exclusion> + <artifactId>activation</artifactId> + <groupId>javax.activation</groupId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.12</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.2</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.3</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.3</version> + <scope>compile</scope> + </dependency> + + <dependency> + <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.3</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + <version>1.6.1</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <artifactId>xml-apis</artifactId> + <groupId>xml-apis</groupId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>jaxen</groupId> + <artifactId>jaxen</artifactId> + <version>1.1.6</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>com.bbn</groupId> + <artifactId>openmap</artifactId> + <version>5.1.10</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>com.jcraft</groupId> + <artifactId>jsch</artifactId> + <version>0.1.53</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.swinglabs.swingx</groupId> + <artifactId>swingx-core</artifactId> + <version>1.6.5-1</version> + <scope>compile</scope> + </dependency> + + <!-- Change this dependence if you change database --> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.3.176_autocommitpatch</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>1.8.6</version> + </dependency> + + <dependency> + <groupId>net.sourceforge</groupId> + <artifactId>jdistlib</artifactId> + <version>0.3.9</version> + </dependency> + + <!-- ssj pour les calculs stockastiques --> + <dependency> + <groupId>ca.umontreal.iro</groupId> + <artifactId>ssj</artifactId> + <version>2.5</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>dsol</groupId> + <artifactId>dsol-xml</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- fin ssj pour les calculs stockastiques --> + + <!-- debut svnkit pour communication subversion --> + <dependency> + <groupId>org.tmatesoft.svnkit</groupId> + <artifactId>svnkit</artifactId> + <version>1.8.10</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <artifactId>jna</artifactId> + <groupId>net.java.dev.jna</groupId> + </exclusion> + <exclusion> + <artifactId>jsch.agentproxy.connector-factory</artifactId> + <groupId>com.jcraft</groupId> + </exclusion> + <exclusion> + <artifactId>platform</artifactId> + <groupId>net.java.dev.jna</groupId> + </exclusion> + </exclusions> + </dependency> + <!-- fin svnkit pour communication subversion --> + + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.22</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jdt.core.compiler</groupId> + <artifactId>ecj</artifactId> + <version>4.4.2</version> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>18.0</version> + </dependency> + + <!-- Tests --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + + <dependency> + <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> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + <name>ISIS-Fish</name> + <description>Simulateur de pecherie complexe.</description> + <inceptionYear>1999</inceptionYear> + + <url>http://doc.codelutin.com/isis-fish</url> + + <organization> + <name>CodeLutin</name> + <url>http://www.codelutin.com/</url> + </organization> + + <licenses> + <license> + <name>GPL</name> + <url>http://www.gnu.org/copyleft/gpl.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <mailingLists> + <mailingList> + <name>isis-fish-commits</name> + <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits</subscribe> + <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits</unsubscribe> + <post>isis-fish-commits@list.isis-fish.org</post> + <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-commits/</archive> + </mailingList> + <mailingList> + <name>isis-fish-devel</name> + <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel</subscribe> + <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel</unsubscribe> + <post>isis-fish-devel@list.isis-fish.org</post> + <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-devel/</archive> + </mailingList> + <mailingList> + <name>isis-fish-user</name> + <subscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users</subscribe> + <unsubscribe>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users</unsubscribe> + <post>isis-fish-users@list.isis-fish.org</post> + <archive>http://list.isis-fish.org/cgi-bin/mailman/listinfo/isis-fish-users/</archive> + </mailingList> + </mailingLists> + + <issueManagement> + <system>redmine</system> + <url>http://forge.codelutin.com/projects/isis-fish/issues</url> + </issueManagement> + + <ciManagement> + <system>hudson</system> + <url>http://ci.codelutin.com/jenkins/job/isis-fish-ci</url> + </ciManagement> + + <developers> + <developer> + <id>bpoussin</id> + <name>Benjamin Poussin</name> + <email>poussin@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + <role>Debian packager</role> + </roles> + <timezone>+2</timezone> + </developer> + <developer> + <id>echatellier</id> + <name>Eric Chatellier</name> + <email>chatellier@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + <developer> + <id>tchemit</id> + <name>Tony Chemit</name> + <email>chemit@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + <developer> + <id>jcouteau</id> + <name>Jean Couteau</name> + <email>couteau@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + </developers> + + <contributors> + <contributor> + <name>Sylvain Letellier</name> + <email>letellier@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </contributor> + </contributors> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + <packaging>jar</packaging> + + <properties> + <!-- Super pom properties --> + <projectId>isis-fish</projectId> + <platform>codelutin.com</platform> + <siteLocales>fr,en</siteLocales> + <siteDeployClassifier /> + <maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class> + <license.licenseName>gpl_v3</license.licenseName> + <license.organizationName>Ifremer, Codelutin</license.organizationName> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + <signatureArtifactId>java17</signatureArtifactId> + <signatureVersion>1.0</signatureVersion> + + <!-- issues status to include in changelog --> + <redmine.statusIds>3,10,11,18,19</redmine.statusIds> + + <!-- Dependencies version --> + <jaxxVersion>2.24</jaxxVersion> + <eugeneVersion>2.14</eugeneVersion> + <topiaVersion>2.9.5.5</topiaVersion> + <hibernateVersion>4.3.10.Final</hibernateVersion> + <nuitonI18nVersion>3.3</nuitonI18nVersion> + <nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion> + + <redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles> + <skipPostRelease>false</skipPostRelease> + <releaseEmailDomain>forge.codelutin.com</releaseEmailDomain> + <releaseEmail>noreply@forge.codelutin.com</releaseEmail> + + <!-- jnlp (disabled until retested) + <keystorepath>${codelutin.keystorepath}</keystorepath> + <keystorealias>CodeLutin</keystorealias> + <keystorepass>codelutin</keystorepass> + <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory> + <jnlpCodebase>${project.url}</jnlpCodebase> + <jnlpCodebase>file://${jnlp.build.directory}</jnlpCodebase>--> + </properties> + + <distributionManagement> + <site> + <id>${siteDeployId}</id> + <url>${siteDeployUrl}</url> + </site> + </distributionManagement> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>isis-config-4</include> + </includes> + <filtering>true</filtering> + </resource> + <resource> + <directory>src/main/resources</directory> + <excludes> + <exclude>isis-config-4</exclude> + </excludes> + <filtering>false</filtering> + </resource> + </resources> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>eugene-maven-plugin</artifactId> + <version>${eugeneVersion}</version> + </plugin> + + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-maven-plugin</artifactId> + <version>${jaxxVersion}</version> + <dependencies> + <dependency> + <groupId>com.fifesoft</groupId> + <artifactId>rsyntaxtextarea</artifactId> + <version>2.5.0</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + <version>${nuitonI18nVersion}</version> + </plugin> + + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <mainClass>${maven.jar.main.class}</mainClass> + <classpathPrefix>lib/</classpathPrefix> + </manifest> + </archive> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <java.io.tmpdir>${project.build.directory}/surefire-workdir</java.io.tmpdir> + </systemPropertyVariables> + </configuration> + <executions> + <execution> + <id>surefire-it</id> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/*IT.java</include> + </includes> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-site-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.nuiton.jrst</groupId> + <artifactId>doxia-module-jrst</artifactId> + <version>${jrstPluginVersion}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>eugene-maven-plugin</artifactId> + <executions> + <execution> + <id>eugene-generation</id> + <phase>generate-sources</phase> + <configuration> + <inputs>zargo</inputs> + <fullPackagePath>fr.ifremer.isisfish</fullPackagePath> + <defaultPackage>fr.ifremer.isisfish</defaultPackage> + <!--<extractedPackages>fr.ifremer.isisfish</extractedPackages> --> + <templates>org.nuiton.topia.generator.TopiaMetaTransformer</templates> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-persistence</artifactId> + <version>${topiaVersion}</version> + <scope>runtime</scope> + </dependency> + </dependencies> + </plugin> + + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <src>${basedir}/src/main/java</src> + <addSourcesToClassPath>true</addSourcesToClassPath> + <addProjectClassPath>true</addProjectClassPath> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + <configuration> + <entries> + <entry> + <basedir>${project.build.directory}/generated-sources/java/</basedir> + </entry> + </entries> + </configuration> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>parserValidation</goal> + <goal>gen</goal> + <goal>bundle</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <configuration> + <silent>true</silent> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + <useBaseVersion>false</useBaseVersion> + </configuration> + <goals> + <goal>copy-dependencies</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:https://svn.codelutin.com/isis-fish/trunk</connection> + <developerConnection>scm:svn:https://svn.codelutin.com/isis-fish/trunk</developerConnection> + <url>https://svn.codelutin.com/isis-fish/trunk</url> + </scm> + + <repositories> + <repository> + <id>nuiton.public</id> + <url>http://nexus.nuiton.org/nexus/content/groups/public</url> + </repository> + </repositories> + + <pluginRepositories> + <pluginRepository> + <id>nuiton.plugin.public</id> + <url>http://nexus.nuiton.org/nexus/content/groups/public</url> + </pluginRepository> + </pluginRepositories> + + <profiles> + + <!-- profile to make assembly (included in release process) --> + <profile> + <id>assembly</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <build> + <defaultGoal>package</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/main/assembly/bin.xml</descriptor> + </descriptors> + <attach>false</attach> + <recompressZippedFiles>true</recompressZippedFiles> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + + <!-- profile with all reports (included in release process) --> + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <properties> + <!-- pmd config --> + <minimumTokens>100</minimumTokens> + <targetJdk>1.7</targetJdk> + </properties> + + <build> + <defaultGoal>site</defaultGoal> + </build> + + <reporting> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <links> + <link>http://docs.oracle.com/javase/7/docs/api/</link> + <link>http://maven-site.nuiton.org/nuiton-utils/nuiton-utils/apidocs/</link> + <link>http://maven-site.nuiton.org/nuiton-matrix/nuiton-matrix/apidocs/</link> + <link>http://maven-site.nuiton.org/nuiton-j2r/apidocs/</link> + <link>http://maven-site.nuiton.org/topia/topia-persistence/apidocs/</link> + </links> + </configuration> + </plugin> + </plugins> + </reporting> + </profile> + </profiles> +</project> Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/aspect/AspectJWeavingAdaptor.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/aspect/AspectJWeavingAdaptor.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/aspect/AspectJWeavingAdaptor.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -57,7 +57,7 @@ * Cette classe étend {@link WeavingAdaptor} pour avoir une instance personnalisée du champ {@link #weaver}. * * Toutes la logique consiste ensuite à pouvoir appeler le code {@code weaver.weave(wcp);} pour pouvoir déployer un - * apect à l'execution dans le {@code weaver} qui servira ensuite à "aspectiser une classe" via la méthode + * aspect à l'execution dans le {@code weaver} qui servira ensuite à "aspectiser une classe" via la méthode * {@link #weaveClass(String, byte[])}. * * Elle utilise pour l'instant de l'introspection agressive pour acceder aux attributs privés de la classe parentes et Added: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationHandler.java =================================================================== --- branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationHandler.java (rev 0) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -0,0 +1,135 @@ +/* + * #%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 static org.nuiton.i18n.I18n.t; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.Properties; + +import javax.swing.JFileChooser; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.simulator.SimulationParameter; +import fr.ifremer.isisfish.ui.simulator.RuleChooserHandler; +import fr.ifremer.isisfish.ui.util.ErrorHelper; + +/** + * Common action for all handler. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SimulationHandler { + + private static final Log log = LogFactory.getLog(SimulationHandler.class); + + public SimulationUI simulationUI; + + public SimulationHandler(SimulationUI simulationUI) { + this.simulationUI = simulationUI; + } + + protected SimulationParameter getParameters() { + return simulationUI.getContextValue(SimulationParameter.class); + } + + /** + * Open user dialog to selected a parameter file. + * Reload it, and call {@link SimulationUI#refresh()}. + */ + public void importSimulation() { + JFileChooser fc = new JFileChooser(); + int returnVal = fc.showOpenDialog(simulationUI); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + //This is where a real application would open the file. + importSimulation(file); + simulationUI.refresh(); + } + } + + /** + * Save current parameter in user selected parameter output file. + */ + public void saveSimulation() { + JFileChooser fc = new JFileChooser(); + int returnVal = fc.showSaveDialog(simulationUI); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + //This is where a real application would open the file. + saveSimulation(file); + } + } + + /** + * Load simulation parameter file. + * + * @param f + * + * TODO public just for sensitivity + */ + protected void importSimulation(File f) { + + try (FileInputStream fos = new FileInputStream(f)) { + + Properties proper = new Properties(); + proper.load(fos); + getParameters().fromProperties(proper); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't import simulation", e); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.importparameter"), e); + } + } + + /** + * Save current simulation to given file. + * + * @param f file to save simulation to + * + * TODO public just for sensitivity + */ + protected void saveSimulation(File f) { + try (FileOutputStream fos = new FileOutputStream(f)) { + getParameters().toProperties().store(fos, null); // XXX: was simulName instead of null + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't save simulation", e); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.savesimulation"), e); + } + } +} Property changes on: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/SimulationUI.jaxx 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/SimulationUI.jaxx 2015-06-08 13:47:32 UTC (rev 4246) @@ -23,10 +23,12 @@ #L% --> <JPanel layout='{new BorderLayout()}' abstract="true"> + + <SimulationHandler id="handler" constructorParams="this" /> + <import> - fr.ifremer.isisfish.ui.simulator.SimulAction; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener javax.swing.JFileChooser java.io.File </import> @@ -74,36 +76,6 @@ public abstract void setEnabledOptimizationTab(boolean selected); /** - * Open user dialog to selected a parameter file. - * Reload it, and call {@link #refresh()}. - */ - protected void importSimulation() { - JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - //This is where a real application would open the file. - getContextValue(SimulAction.class).importSimulation(file); - refresh(); - } - } - - /** - * Save current parameter in user selected parameter output file. - */ - public void saveSimulation() { - JFileChooser fc = new JFileChooser(); - int returnVal = fc.showSaveDialog(this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - //This is where a real application would open the file. - getContextValue(SimulAction.class).saveSimulation(file); - } - } - - /** * Rafraichit l'arbre des facteurs. */ public void refreshFactorTree() { @@ -112,8 +84,8 @@ ]]></script> <JMenuBar constraints='BorderLayout.NORTH'> <JMenu text="isisfish.simulation.menu.simulation"> - <JMenuItem id="miSave" text="isisfish.simulation.menu.save" onActionPerformed="saveSimulation()"/> - <JMenuItem id="miImport" text="isisfish.simulation.menu.import" onActionPerformed="importSimulation()"/> + <JMenuItem id="miSave" text="isisfish.simulation.menu.save" onActionPerformed="handler.saveSimulation()"/> + <JMenuItem id="miImport" text="isisfish.simulation.menu.import" onActionPerformed="handler.importSimulation()"/> </JMenu> </JMenuBar> <JTabbedPane id="bodyTabbedPane" constraints='BorderLayout.CENTER' decorator="boxed"/> Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/models/rule/RuleParametersFactorTableCellEditor.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -25,6 +25,12 @@ package fr.ifremer.isisfish.ui.models.rule; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY; +import static org.nuiton.i18n.I18n.t; + import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -42,9 +48,11 @@ import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.datastore.RuleStorage; import fr.ifremer.isisfish.rule.Rule; +import fr.ifremer.isisfish.simulator.sensitivity.Factor; import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils; +import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardHandler; +import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI; import fr.ifremer.isisfish.ui.simulator.RuleChooser; -import fr.ifremer.isisfish.ui.simulator.SimulAction; /** * Specific editor for rule parameters. @@ -70,7 +78,7 @@ /** * Constructor. * - * Super dependant de l'ui {@link RuleChooser} et de {@link SimulAction}. + * Super dependant de l'ui {@link RuleChooser}. * * @param ruleChooser rule chooser ui * @param rule rule @@ -96,8 +104,7 @@ @Override public void actionPerformed(ActionEvent e) { cancelCellEditing(); - SimulAction simulAction = ruleChooser.getContextValue(SimulAction.class); - simulAction.addRuleParameterFactor(ruleChooser, rule, paramName); + addRuleParameterFactor(ruleChooser, rule, paramName); } }); comp = button; @@ -122,4 +129,62 @@ public Object getCellEditorValue() { return null; } + + /** + * Ajout d'un nouveau facteur sur un parametres de règles. + * + * Le facteur est directement crée avec un nom et un path correct. + * + * @param ruleChooser rule chooser + * @param rule rule + * @param paramName rule parameter name + */ + public void addRuleParameterFactor(RuleChooser ruleChooser, Rule rule, String paramName) { + + // get index of rule in rule list + // warning, factor path must always be cohérent + // with rule list, if a rule is deleted, factor on it must + // be deleted too, et next factor must be renamed + int index = ruleChooser.getRulesList().indexOf(rule); + String factorPath = PARAMETERS_KEY + DOT + RULE_KEY + DOT + index + DOT + + PARAMETER_KEY + DOT + paramName; + //try { + + /*// on a besoin de la valeur pour savoir s'il peut être continue + Object paramValue = RuleStorage.getParameterValue(rule, paramName); + + if (!SensitivityUtils.canBeContinue(paramValue)) { + // dans le cas ou il ne peut pas être continue, on le gere + // differement et on utilise sont type comme + // valeur + Class paramType = RuleStorage.getParameterType(rule, paramName); + factorPath += "." + paramType.getName(); + paramValue = paramType; + } + + // init new factor wizard ui + FactorWizardUI factorWizardUI = new FactorWizardUI(ruleChooser); + factorWizardUI.getFactorNameField().setText(t("isisfish.sensitivity.ruleparameterfactorname", + rule.getClass().getSimpleName(), paramName)); + factorWizardUI.setFactorPath(factorPath); + SensitivityWizardHandler handler = factorWizardUI.getHandler(); + handler.initNewFactorWithValue(factorWizardUI, paramValue); + factorWizardUI.pack(); + factorWizardUI.setLocationRelativeTo(ruleChooser); + factorWizardUI.setVisible(true);*/ + + Factor factor = new Factor(t("isisfish.sensitivity.ruleparameterfactorname", + rule.getClass().getSimpleName(), paramName)); + factor.setPath(factorPath); + FactorWizardUI factorWizardUI = new FactorWizardUI(ruleChooser); + FactorWizardHandler handler = factorWizardUI.getHandler(); + handler.initExistingFactor(factorWizardUI, factor); + factorWizardUI.pack(); + factorWizardUI.setLocationRelativeTo(ruleChooser); + factorWizardUI.setVisible(true); + + /*} catch (IsisFishException ex) { + throw new IsisFishRuntimeException("Can't add factor on rule", ex); + }*/ + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -10,14 +10,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.IsisFishException; 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.SimulationParameter; import fr.ifremer.isisfish.simulator.sensitivity.Domain; import fr.ifremer.isisfish.simulator.sensitivity.Factor; +import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup; import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis; import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain; import fr.ifremer.isisfish.ui.models.common.GenericComboModel; @@ -27,7 +30,7 @@ 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; +import fr.ifremer.isisfish.ui.widget.editor.ScriptParameterDialog; public class SensitivityChooserHandler { @@ -42,7 +45,29 @@ public SensitivityChooserHandler(SensitivityChooserUI sensitivityChooserUI) { this.sensitivityChooserUI = sensitivityChooserUI; } + + /** + * Return simulation parameters from context. + * + * @return SimulationParameter + * @deprecated maybe be inherited + */ + @Deprecated + protected SimulationParameter getParameters() { + return sensitivityChooserUI.getContextValue(SimulationParameter.class); + } + /** + * Return factor group from context. + * + * @return FactorGroup + * @deprecated maybe be inherited + */ + @Deprecated + protected FactorGroup getFactorGroup() { + return sensitivityChooserUI.getContextValue(FactorGroup.class); + } + protected void afterInit() { // listener to listen for modification on sensitivity analysis sensitivityAnalysisListener = new StorageChangeListener() { @@ -62,14 +87,9 @@ }; SensitivityExportStorage.addStorageChangeListener(sensitivityExportListener); } - - @Deprecated - protected SimulAction getSimulAction() { - return sensitivityChooserUI.getContextValue(SimulAction.class); - } public ComboBoxModel<String> getSensitivityAnalysisModel() { - List<String> sensitivityNames = getSimulAction().getSensitivityAnalysisNames(); + List<String> sensitivityNames = getSensitivityAnalysisNames(); GenericComboModel<String> model = new GenericComboModel<>(sensitivityNames); return model; } @@ -81,7 +101,7 @@ * Used by "reloadOldSimulation" operation. */ public void refreshSelectedSensitivityAnalysis() { - SensitivityAnalysis sensitivityAnalysis = getSimulAction().getSensitivityAnalysis(); + SensitivityAnalysis sensitivityAnalysis = getSensitivityAnalysis(); if (sensitivityAnalysis != null) { if (log.isDebugEnabled()) { log.debug("Refreshing sensitivity analysis list"); @@ -99,16 +119,16 @@ // 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(); + SensitivityAnalysis sensitivityAnalysis = getSensitivityAnalysis(); if (sensitivityAnalysis != null && sensitivityAnalysis.getClass().getSimpleName().equals(sensitivityName)) { - sensitivityAnalysis = getSimulAction().getSensitivityAnalysis(); + sensitivityAnalysis = getSensitivityAnalysis(); } else { - sensitivityAnalysis = getSimulAction().getSensitivityAnalysisInstance(sensitivityName); + sensitivityAnalysis = getSensitivityAnalysisInstance(sensitivityName); } // can be null for example if analysis can't be compiled if (sensitivityAnalysis != null) { - getSimulAction().setSensitivityAnalysis(sensitivityAnalysis); + setSensitivityAnalysis(sensitivityAnalysis); CardLayout factorPanelLayout = (CardLayout)sensitivityChooserUI.factorCardinalityPanel.getLayout(); if (sensitivityAnalysis.canManageCardinality()) { @@ -126,13 +146,13 @@ } public void setFactorCardinalityTableModel() { - List<Factor> factors = getSimulAction().getFactorGroup().getFactors(); + List<Factor> factors = 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; + //ContinuousDomain continuousDomain = (ContinuousDomain)domain; factorsContinue.add(f); } } @@ -141,7 +161,7 @@ } protected GenericListModel<String> getAvailableExportListModel() { - List<String> exportNames = getSimulAction().getSensitivityExportNames(); + List<String> exportNames = getSensitivityExportNames(); GenericListModel<String> model = new GenericListModel<>(exportNames); return model; } @@ -154,7 +174,7 @@ protected void addExports() { List<String> exportNames = sensitivityChooserUI.availableSensitivityExports.getSelectedValuesList(); for (String exportName : exportNames) { - getSimulAction().addSensitivityExport(sensitivityChooserUI, exportName); + addSensitivityExport(sensitivityChooserUI, exportName); } setSensitivityExportListModel(); } @@ -165,7 +185,7 @@ protected void removeExports() { List<SensitivityExport> exports = sensitivityChooserUI.selectedSensitivityExports.getSelectedValuesList(); for (SensitivityExport export : exports) { - getSimulAction().removeSensitivityExport(export); + removeSensitivityExport(export); } setSensitivityExportListModel(); } @@ -174,7 +194,7 @@ * Clear all export. */ protected void clearExports() { - getSimulAction().clearSensitivityExport(); + clearSensitivityExport(); setSensitivityExportListModel(); } @@ -182,7 +202,7 @@ * Set model (refresh export JList). */ public void setSensitivityExportListModel() { - List<SensitivityExport> exports = getSimulAction().getSensitivityExports(); + List<SensitivityExport> exports = getSensitivityExports(); GenericListModel<SensitivityExport> model = new GenericListModel<>(exports); sensitivityChooserUI.selectedSensitivityExports.setModel(model); sensitivityChooserUI.selectedSensitivityExports.setCellRenderer(new SensitivityExportListRenderer()); @@ -212,8 +232,6 @@ * 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); @@ -226,4 +244,102 @@ sensitivityChooserUI.exportParamsTable.setModel(new DefaultTableModel()); } } + + public List<String> getSensitivityExportNames() { + List<String> result = new ArrayList<>(); + List<String> exportNames = SensitivityExportStorage.getSensitivityExportNames(); + for (String export : exportNames) { + result.add(export); + } + return result; + } + + public List<SensitivityExport> getSensitivityExports() { + List<SensitivityExport> result = getParameters().getSensitivityExport(); + return result; + } + + public void addSensitivityExport(SensitivityChooserUI sensitivityChooserUI, String name) { + try { + SensitivityExportStorage storage = SensitivityExportStorage.getSensitivityExport(name); + SensitivityExport sensitivityExport = storage.getNewInstance(); + + // add it after autoconfiguration (if enabled) + sensitivityExport = (SensitivityExport)ScriptParameterDialog.displayConfigurationFrame(sensitivityChooserUI, sensitivityExport); + if (sensitivityExport != null) { + getParameters().getSensitivityExport().add(sensitivityExport); + } + } catch (IsisFishException e) { + if (log.isErrorEnabled()) { + log.error("Can't add sensitivity export", e); + } + } + } + + /** + * Remove an export. + * + * @param export export to remove + */ + public void removeSensitivityExport(SensitivityExport export) { + getParameters().getSensitivityExport().remove(export); + } + + public void clearSensitivityExport() { + getParameters().getSensitivityExport().clear(); + } + + /** + * Return sensitivity analysis name without .java extension. + * + * @return sensitivity analysis names list + */ + public List<String> getSensitivityAnalysisNames() { + List<String> result = new ArrayList<String>(); + for (String r : SensitivityAnalysisStorage.getSensitivityAnalysisNames()) { + // there is some non java files in sensitivity directory + if (r.endsWith(".java")) { + // Remove .java extention + // for example SensitivityStorage.getRuleName(String) + result.add(r.substring(0, r.length() - 5)); + } + } + return result; + } + + /** + * Get current sensitivity calculator instance. + * @return sensitivity calculator + */ + public SensitivityAnalysis getSensitivityAnalysis() { + return getParameters().getSensitivityAnalysis(); + } + + /** + * Build a new sensitivity calculator instance by his name. + * + * @param name calculator name + * @return instance + */ + public SensitivityAnalysis getSensitivityAnalysisInstance(String name) { + SensitivityAnalysis sensitivityAnalysis = null; + try { + SensitivityAnalysisStorage sensitivityStorage = SensitivityAnalysisStorage.getSensitivityAnalysis(name); + sensitivityAnalysis = sensitivityStorage.getNewInstance(); + } catch (IsisFishException e) { + if (log.isErrorEnabled()) { + log.error("Can't set sensitivity analysis", e); + } + } + return sensitivityAnalysis; + } + + /** + * Set calculator instance to use. + * + * @param sensitivityAnalysis new instance + */ + public void setSensitivityAnalysis(SensitivityAnalysis sensitivityAnalysis) { + getParameters().setSensitivityAnalysis(sensitivityAnalysis); + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityContext.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -23,29 +23,27 @@ package fr.ifremer.isisfish.ui.sensitivity; import fr.ifremer.isisfish.ui.WelcomeSaveVerifier; -import fr.ifremer.isisfish.ui.simulator.SimulAction; +import fr.ifremer.isisfish.ui.simulator.SimulatorContext; import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXInitialContext; /** * Ce contexte regroupe les élements qui servent à une hierachie d'interfaces Sensitivity. * + * C'est globalement un context de simulation + input (pour la selection des fateurs). + * * @author Eric Chatellier */ -public class SensitivityContext extends JAXXInitialContext { +public class SensitivityContext extends SimulatorContext { public SensitivityContext(JAXXContext parent) { - setParentContext(parent); + super(parent); - // add save verifier for this hierarchy + // add save verifier for this hierarchy (input) SensitivitySaveVerifier sensitivitySaveVerifier = new SensitivitySaveVerifier(); add(sensitivitySaveVerifier); - // this verifier is linked to global verifier + // this verifier is linked to global verifier (input) WelcomeSaveVerifier welcomeSaveVerifier = getContextValue(WelcomeSaveVerifier.class); welcomeSaveVerifier.addSaveVerifier(sensitivitySaveVerifier); - - // FIXME remove this - add(new SimulAction()); } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -67,7 +67,6 @@ 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.simulator.SimulAction; /** * Handler for sensitivity tab ui (fishery region factors). @@ -93,11 +92,6 @@ } - @Deprecated - protected SimulAction getSimulAction() { - return sensitivityInputUI.getContextValue(SimulAction.class); - } - protected InputSaveVerifier getVerifier() { return sensitivityInputUI.getContextValue(InputSaveVerifier.class); } @@ -105,6 +99,10 @@ protected RegionStorage getRegionStorage() { return sensitivityInputUI.getContextValue(RegionStorage.class); } + + protected FactorGroup getFactorGroup() { + return sensitivityInputUI.getContextValue(FactorGroup.class); + } public void setTreeModel() { if (sensitivityInputUI.getFisheryRegion() != null) { @@ -126,7 +124,7 @@ } public void setFactorModel() { - FactorGroup factorGroup = getSimulAction().getFactorGroup(); + FactorGroup factorGroup = getFactorGroup(); FactorTreeModel model = new FactorTreeModel(factorGroup); sensitivityInputUI.factorsTree.setModel(model); sensitivityInputUI.getParentContainer(SensitivityUI.class).getSensitivityChooserUI().getHandler().setFactorCardinalityTableModel(); @@ -228,7 +226,7 @@ t("isisfish.sensitivity.title"), JOptionPane.QUESTION_MESSAGE); if (StringUtils.isNotBlank(factorName)) { - FactorGroup rootFactorGroup = getSimulAction().getFactorGroup(); + FactorGroup rootFactorGroup = getFactorGroup(); FactorGroup factorGroup = new FactorGroup(factorName, continuous); rootFactorGroup.addFactor(factorGroup); setFactorModel(); @@ -248,7 +246,7 @@ selectedFactorGroup.addAllFactors(movedFactors); // remove duplicated from factor group - FactorGroup rootFactorGroup = getSimulAction().getFactorGroup(); + FactorGroup rootFactorGroup = getFactorGroup(); if (!rootFactorGroup.equals(selectedFactorGroup)) { rootFactorGroup.removeAll(movedFactors); } @@ -371,10 +369,8 @@ xmlFile = new File(xmlFile.getAbsolutePath() + ".xml"); } - SimulAction simulAction = sensitivityInputUI.getContextValue(SimulAction.class); - DesignPlan designPlan = new DesignPlan(); - designPlan.setFactorGroup(simulAction.getFactorGroup()); + designPlan.setFactorGroup(getFactorGroup()); //String xml = MexicoHelper.getDesignPlanAsXML(designPlan); MexicoHelper.writeDesignPlanToFile(xmlFile, designPlan); } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputUI.jaxx 2015-06-08 13:47:32 UTC (rev 4246) @@ -65,7 +65,7 @@ <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())}' + model='{new fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeModel(handler.getFactorGroup())}' cellRenderer='{new fr.ifremer.isisfish.ui.sensitivity.model.FactorTreeCellRenderer()}' onMouseClicked='handler.factorsTreeMouseClicked(event)'/> </JScrollPane> Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -5,17 +5,21 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; 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.SimulationParameter; 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.sensitivity.SensitivityAnalysis; +import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException; import fr.ifremer.isisfish.ui.models.common.GenericComboModel; -import fr.ifremer.isisfish.ui.simulator.SimulAction; public class SensitivitySecondPassHandler { @@ -79,14 +83,9 @@ 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()); + runSensitivitySecondPass((String)sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedItem()); displaySensitivitySecondPass(event); } } @@ -96,7 +95,7 @@ try { String selectedSimulationName = (String)sensitivitySecondPassUI.fieldSensitivitySimulationSelect.getSelectedItem(); - List<File> files = getSimulAction().getSensitivitySecondPassResults(selectedSimulationName); + List<File> files = getSensitivitySecondPassResults(selectedSimulationName); String content = ""; for(File file : files) { @@ -113,4 +112,85 @@ } } } + + /** + * Lance la second passe d'une analyse de sensibilité. + * + * @param masterSensitivitySimulationName nom du prefix de toutes les simulations (without _) + */ + public void runSensitivitySecondPass(String masterSensitivitySimulationName) { + + // sensitivity analysis found + SensitivityAnalysis sensitivityAnalysis = null; + //List<SimulationStorage> simulationStorageForAnalyze = new ArrayList<SimulationStorage>(); + SortedMap<Integer, SimulationStorage> simulationStorageForAnalyze = new TreeMap<Integer, SimulationStorage>(); + File simuationDirectory = SimulationStorage.getSimulationDirectory(); + for (File simuation : simuationDirectory.listFiles()) { + if (simuation.isDirectory() + && simuation.getName().startsWith( + masterSensitivitySimulationName + "_")) { + SimulationStorage storage = SimulationStorage + .getSimulation(simuation.getName()); + String suffix = simuation.getName().substring( + simuation.getName().lastIndexOf("_") + 1); + simulationStorageForAnalyze.put(Integer.valueOf(suffix), + storage); + + if (sensitivityAnalysis == null) { + // try to find find calculator name in one storage + SimulationParameter params = storage.getParameter(); + sensitivityAnalysis = params.getSensitivityAnalysis(); + } + } + } + + if (sensitivityAnalysis != null) { + try { + // build master sensitivity export directory + File masterExportDirectory = new File(SimulationStorage.getSensitivityResultsDirectory(), + masterSensitivitySimulationName); + if (!masterExportDirectory.isDirectory()) { + masterExportDirectory.mkdirs(); + } + List<SimulationStorage> simulationStorageForAnalyzeList = new ArrayList<SimulationStorage>( + simulationStorageForAnalyze.values()); + sensitivityAnalysis.analyzeResult( + simulationStorageForAnalyzeList, masterExportDirectory); + } catch (SensitivityException e) { + if (log.isErrorEnabled()) { + log.error("Can't call analyse result", e); + } + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't run sensitivity second pass"); + } + } + } + + /** + * Renvoie les resultats de la seconde pass. + * + * @param masterSensitivitySimulationName nom du prefix de toutes les simulations (without _) + * + * @return les fichiers genere lors de la seconde passe (seulement ceux qui ne commence pas par ".") + */ + public List<File> getSensitivitySecondPassResults( + String masterSensitivitySimulationName) { + + List<File> result = new ArrayList<File>(); + + // build master sensitivity export directory + File masterExportDirectory = new File(SimulationStorage.getSensitivityResultsDirectory(), masterSensitivitySimulationName); + if (masterExportDirectory.isDirectory()) { + for (File exportFile : masterExportDirectory.listFiles()) { + if (exportFile.isFile() + && !exportFile.getName().startsWith(".")) { + result.add(exportFile); + } + } + } + + return result; + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/FactorWizardHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -31,8 +31,10 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.SortedMap; +import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -61,8 +63,10 @@ import fr.ifremer.isisfish.entities.Equation; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.rule.Rule; +import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.simulator.sensitivity.Domain; import fr.ifremer.isisfish.simulator.sensitivity.Factor; +import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup; import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils; import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain; import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain; @@ -75,7 +79,6 @@ 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; @@ -515,8 +518,7 @@ } TopiaContext topiaContext = getTopiaContext(factorWizardUI); Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName); - SimulAction action = factorWizardUI.getContextValue(SimulAction.class); - MatrixND N = action.getSimulationParameter().getNumberOf(pop); + MatrixND N = getParameters().getNumberOf(pop); result = new MatrixPanelEditor(); ((MatrixPanelEditor)result).setMatrix(N.clone()); topiaContext.closeContext(); @@ -526,8 +528,7 @@ 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); + Rule rule = getParameters().getRules().get(ruleIndex); Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2)); Object value = RuleStorage.getParameterValue(rule, matcher.group(2)); result = getTypeDiscreteComponent(factorWizardUI, valueClazz, value); @@ -583,12 +584,12 @@ //DefaultContinuousPanelUI ui = new DefaultContinuousPanelUI(); String values = rangeOfValues.getValues(); String min = "0"; - String max = "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); + //max = values.substring(first + 1); } } result = new ContinuousDistributionPanel(min); @@ -634,8 +635,7 @@ } TopiaContext topiaContext = getTopiaContext(factorWizardUI); Population pop = IsisFishDAOHelper.getPopulationDAO(topiaContext).findByName(populationName); - SimulAction action = factorWizardUI.getContextValue(SimulAction.class); - MatrixND N = action.getSimulationParameter().getNumberOf(pop); + MatrixND N = getParameters().getNumberOf(pop); result = new ContinuousDistributionPanel(N.clone()); topiaContext.closeContext(); } @@ -644,8 +644,7 @@ 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); + Rule rule = getParameters().getRules().get(ruleIndex); Class valueClazz = RuleStorage.getParameterType(rule, matcher.group(2)); Object value = RuleStorage.getParameterValue(rule, matcher.group(2)); result = getTypeContinousComponent(factorWizardUI, valueClazz, value); @@ -754,12 +753,12 @@ if (factorWizardUI.getContinueRadio().isSelected()) { saveContinue(factorWizardUI.getFactorNameField().getText(), factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), continuousPanel, - factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState()); + factorWizardUI.isEditingState()); } else { Component[] discreteComponents = factorWizardUI.getTabPane().getComponents(); saveDiscret(factorWizardUI.getFactorNameField().getText(), factorWizardUI.getComment().getText(), factorWizardUI.getFactorPath(), discreteComponents, - factorWizardUI.getContextValue(SimulAction.class), factorWizardUI.isEditingState()); + factorWizardUI.isEditingState()); } // refresh factor list @@ -776,12 +775,10 @@ * @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) { + String comment, String path, ContinuousPanel panel, boolean exist) { if (panel instanceof EquationContinuousPanelUI) { try { EquationContinuousPanelUI equationPanel = (EquationContinuousPanelUI) panel; @@ -799,7 +796,7 @@ factor.setName(name); factor.setComment(comment); factor.setPath(path); - action.addContinuousEquationFactor(factor, exist); + addContinuousEquationFactor(factor, exist); } } catch (Exception ex) { if (log.isErrorEnabled()) { @@ -809,7 +806,7 @@ } else if (panel instanceof ContinuousDistributionPanel) { ContinuousDistributionPanel defaultPanel = (ContinuousDistributionPanel) panel; ContinuousDomain domain = defaultPanel.generateDomain(); - action.addContinuousFactor(name, comment, path, domain, exist); + addContinuousFactor(name, comment, path, domain, exist); } } @@ -820,12 +817,10 @@ * @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) { + String comment, String path, Component[] components, boolean exist) { List<Object> values = new ArrayList<Object>(); boolean ruleFactor = false; @@ -861,11 +856,11 @@ } if (ruleFactor) { - action.addDiscreteRuleFactor(name, comment, path, values, exist); + addDiscreteRuleFactor(name, comment, path, values, exist); } else if (equationFactor) { - action.addDiscreteEquationFactor(name, comment, path, values, exist); + addDiscreteEquationFactor(name, comment, path, values, exist); } else { - action.addDiscreteFactor(name, comment, path, values, exist); + addDiscreteFactor(name, comment, path, values, exist); } } @@ -875,8 +870,120 @@ * @param factorWizardUI factorWizardUI */ public void remove(FactorWizardUI factorWizardUI) { - factorWizardUI.getContextValue(SimulAction.class).removeFactor(factorWizardUI.getFactorPath()); + removeFactor(factorWizardUI.getFactorPath()); factorWizardUI.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree(); factorWizardUI.dispose(); } + + protected void addFactor(Factor f) { + if (log.isDebugEnabled()) { + log.debug("Add factor (" + f.getName() + ") : " +f.getPath()); + } + getFactorGroup().addFactor(f); + } + + /** + * Ajout d'un facteur continue de type (min/max). + * + * @param name + * @param comment + * @param path + * @param domain + * @param exist + */ + public void addContinuousFactor(String name, String comment, String path, + ContinuousDomain domain, boolean exist) { + Factor f = new Factor(name); + f.setDomain(domain); + f.setComment(comment); + f.setPath(path); + if (exist) { + removeFactor(path); + } + addFactor(f); + } + + public void addDiscreteFactor(String name, String comment, String path, + List<Object> values, boolean exist) { + addDiscreteFactor(new DiscreteDomain(), name, comment, path, values, exist); + } + + public void addDiscreteRuleFactor(String name, String comment, String path, + List<Object> values, boolean exist) { + addDiscreteFactor(new RuleDiscreteDomain(), name, comment, path, values, exist); + } + + public void addDiscreteEquationFactor(String name, String comment, String path, + List<Object> values, boolean exist) { + addDiscreteFactor(new EquationDiscreteDomain(), name, comment, path, values, exist); + } + + protected void addDiscreteFactor(DiscreteDomain domain, String name, String comment, String path, + List<Object> values, boolean exist) { + Factor f = new Factor(name); + SortedMap<Object, Object> domainValues = new TreeMap<Object, Object>(); + int label = 0; + for (Object value : values) { + // FIXME test when integer + // Don't work with String ;( + domainValues.put(label, value); + // and start at 0 + label++; + } + domain.setValues(domainValues); + f.setDomain(domain); + f.setComment(comment); + f.setPath(path); + if (exist) { + removeFactor(path); + } + addFactor(f); + } + + public void addContinuousEquationFactor(Factor f, boolean exist) { + // factor name need to be composed + //Factor f = new Factor(name + "." + domain.getVariableName()); + //f.setDomain(domain); + //f.setComment(comment); + //f.setPath(path); + if (exist) { + removeFactor(f.getPath()); + } + addFactor(f); + } + + /** + * Remove factor in factor group tree by path. + * + * @param factorPath factor path to remove + */ + public void removeFactor(String factorPath) { + removeFactor(getFactorGroup(), factorPath); + } + + /** + * Recursive remove for factor in factor group by path. + * + * @param factorGroup factor group to search to + * @param factorPath factor path to remove + */ + protected void removeFactor(FactorGroup factorGroup, String factorPath) { + Collection<Factor> factorCopy = new ArrayList<Factor>(factorGroup.getFactors()); + for (Factor factor : factorCopy) { + if (factor instanceof FactorGroup) { + removeFactor((FactorGroup)factor, factorPath); + } + if (factorPath.equals(factor.getPath())) { + factorGroup.remove(factor); + } + } + } + + protected FactorGroup getFactorGroup() { + return factorWizardUI.getContextValue(FactorGroup.class); + } + + protected SimulationParameter getParameters() { + return factorWizardUI.getContextValue(SimulationParameter.class); + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -25,6 +25,7 @@ import static org.nuiton.i18n.I18n.t; import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.swing.event.ListSelectionEvent; @@ -34,6 +35,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.SimulatorStorage; +import fr.ifremer.isisfish.simulator.SimulationParameter; + /** * AdvancedParams UI handler. * @@ -66,56 +71,58 @@ } 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()); + SimulationParameter params = getParameters(); - 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.fieldSimulAdvParamsSimulatorSelect.setSelectedItem(params.getSimulatorName()); + tabUI.fieldSimulationStatistique.setSelected(params.getUseStatistic()); + tabUI.fieldSimulationCache.setSelected(params.getUseCache()); - 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.fieldSimulAdvParamsSimulLoggerError.setSelected(params.isSimulErrorLevel()); + tabUI.fieldSimulAdvParamsSimulLoggerWarn.setSelected(params.isSimulWarnLevel()); + tabUI.fieldSimulAdvParamsSimulLoggerInfo.setSelected(params.isSimulInfoLevel()); + tabUI.fieldSimulAdvParamsSimulLoggerDebug.setSelected(params.isSimulDebugLevel()); - 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()); + tabUI.fieldSimulAdvParamsScriptLoggerError.setSelected(params.isScriptErrorLevel()); + tabUI.fieldSimulAdvParamsScriptLoggerWarn.setSelected(params.isScriptWarnLevel()); + tabUI.fieldSimulAdvParamsScriptLoggerInfo.setSelected(params.isScriptInfoLevel()); + tabUI.fieldSimulAdvParamsScriptLoggerDebug.setSelected(params.isScriptDebugLevel()); + tabUI.fieldSimulAdvParamsLibLoggerError.setSelected(params.isLibErrorLevel()); + tabUI.fieldSimulAdvParamsLibLoggerWarn.setSelected(params.isLibWarnLevel()); + tabUI.fieldSimulAdvParamsLibLoggerInfo.setSelected(params.isLibInfoLevel()); + tabUI.fieldSimulAdvParamsLibLoggerDebug.setSelected(params.isLibDebugLevel()); + setTableTagValues(); } protected void addTagValue() { - tabUI.getContextValue(SimulAction.class).addTagValue(tabUI.fieldTag.getText(), tabUI.fieldValue.getText()); + 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()); + 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()); + 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()); + getParameters().setSimulatorName(tabUI.fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString()); valueChanged(true); } } protected void setTableTagValues() { - Map<String, String> tagValues = tabUI.getContextValue(SimulAction.class).getSimulationParameter().getTagValue(); + Map<String, String> tagValues = getParameters().getTagValue(); // TODO make a table model for it String columnName[] = { t("isisfish.common.tag"), t("isisfish.common.value")}; @@ -141,4 +148,29 @@ protected void valueChanged(boolean b) { tabUI.setChanged(b); } + + public void addTagValue(String tag, String value) { + getParameters().getTagValue().put(tag, value); + } + + public void removeTagValue(String tag) { + if (log.isDebugEnabled()) { + log.debug("removeTagValue: " + tag); + } + getParameters().getTagValue().remove(tag); + } + + public void saveTagValue(String simulatorName) { + Map<String, String> tagValues = getParameters().getTagValue(); + if (log.isDebugEnabled()) { + log.debug("call saveTagValue: " + tagValues); + } + IsisFish.config.setDefaultTagValues(tagValues); + + IsisFish.config.setSimulatorClassfile(simulatorName); + } + + public List<String> getSimulatorNames() { + return SimulatorStorage.getSimulatorNames(); + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-06-08 13:47:32 UTC (rev 4246) @@ -48,7 +48,7 @@ <cell columns="4" fill="horizontal"> <JComboBox id="fieldSimulAdvParamsSimulatorSelect" genericType="String" - model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulatorNames().toArray())}' + model='{new DefaultComboBoxModel(handler.getSimulatorNames().toArray())}' onActionPerformed='handler.setSimulatorName()'/> </cell> </row> @@ -56,12 +56,13 @@ <cell columns="2" fill="horizontal"> <JCheckBox id="fieldSimulationStatistique" text="isisfish.advancedParams.simulationStatistique" - selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setUseStatistic(fieldSimulationStatistique.isSelected());'/> + selected='{handler.getParameters().getUseStatistic()}' + onActionPerformed='handler.getParameters().setUseStatistic(fieldSimulationStatistique.isSelected());'/> </cell> <cell columns="2" fill="horizontal"> - <JCheckBox id="fieldSimulationCache" text="isisfish.advancedParams.simulationCache" selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseCache()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setUseCache(fieldSimulationCache.isSelected());'/> + <JCheckBox id="fieldSimulationCache" text="isisfish.advancedParams.simulationCache" + selected='{handler.getParameters().getUseCache()}' + onActionPerformed='handler.getParameters().setUseCache(fieldSimulationCache.isSelected());'/> </cell> </row> <row> @@ -70,23 +71,23 @@ </cell> <cell fill="horizontal" weightx="1.0"> <JRadioButton id="fieldSimulAdvParamsSimulLoggerError" text="isisfish.common.error" - buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isSimulErrorLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setSimulLogLevel("error");'/> + buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{handler.getParameters().isSimulErrorLevel()}' + onActionPerformed='handler.getParameters().setSimulLogLevel("error");'/> </cell> <cell fill="horizontal" weightx="1.0"> <JRadioButton id="fieldSimulAdvParamsSimulLoggerWarn" text="isisfish.common.warn" - buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isSimulWarnLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setSimulLogLevel("warn");'/> + buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{handler.getParameters().isSimulWarnLevel()}' + onActionPerformed='handler.getParameters().setSimulLogLevel("warn");'/> </cell> <cell fill="horizontal" weightx="1.0"> <JRadioButton id="fieldSimulAdvParamsSimulLoggerInfo" text="isisfish.common.info" - buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isSimulInfoLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setSimulLogLevel("info");'/> + buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{handler.getParameters().isSimulInfoLevel()}' + onActionPerformed='handler.getParameters().setSimulLogLevel("info");'/> </cell> <cell fill="horizontal" weightx="1.0"> <JRadioButton id="fieldSimulAdvParamsSimulLoggerDebug" text="isisfish.common.debug" - buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isSimulDebugLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setSimulLogLevel("debug");'/> + buttonGroup="fieldSimulAdvParamsSimulLoggerGroup" selected='{handler.getParameters().isSimulDebugLevel()}' + onActionPerformed='handler.getParameters().setSimulLogLevel("debug");'/> </cell> </row> <row> @@ -95,23 +96,23 @@ </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsScriptLoggerError" text="isisfish.common.error" - buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isScriptErrorLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setScriptLogLevel("error");'/> + buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{handler.getParameters().isScriptErrorLevel()}' + onActionPerformed='handler.getParameters().setScriptLogLevel("error");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsScriptLoggerWarn" text="isisfish.common.warn" - buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isScriptWarnLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setScriptLogLevel("warn");'/> + buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{handler.getParameters().isScriptWarnLevel()}' + onActionPerformed='handler.getParameters().setScriptLogLevel("warn");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsScriptLoggerInfo" text="isisfish.common.info" - buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isScriptInfoLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setScriptLogLevel("info");'/> + buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{handler.getParameters().isScriptInfoLevel()}' + onActionPerformed='handler.getParameters().setScriptLogLevel("info");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsScriptLoggerDebug" text="isisfish.common.debug" - buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isScriptDebugLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setScriptLogLevel("debug");'/> + buttonGroup="fieldSimulAdvParamsScriptLoggerGroup" selected='{handler.getParameters().isScriptDebugLevel()}' + onActionPerformed='handler.getParameters().setScriptLogLevel("debug");'/> </cell> </row> <row> @@ -120,23 +121,23 @@ </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsLibLoggerError" text="isisfish.common.error" - buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isLibErrorLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setLibLogLevel("error");'/> + buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{handler.getParameters().isLibErrorLevel()}' + onActionPerformed='handler.getParameters().setLibLogLevel("error");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsLibLoggerWarn" text="isisfish.common.warn" - buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isLibWarnLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setLibLogLevel("warn");'/> + buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{handler.getParameters().isLibWarnLevel()}' + onActionPerformed='handler.getParameters().setLibLogLevel("warn");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsLibLoggerInfo" text="isisfish.common.info" - buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isLibInfoLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setLibLogLevel("info");'/> + buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{handler.getParameters().isLibInfoLevel()}' + onActionPerformed='handler.getParameters().setLibLogLevel("info");'/> </cell> <cell fill="horizontal"> <JRadioButton id="fieldSimulAdvParamsLibLoggerDebug" text="isisfish.common.debug" - buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{getContextValue(SimulAction.class).getSimulationParameter().isLibDebugLevel()}' - onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setLibLogLevel("debug");'/> + buttonGroup="fieldSimulAdvParamsLibLoggerGroup" selected='{handler.getParameters().isLibDebugLevel()}' + onActionPerformed='handler.getParameters().setLibLogLevel("debug");'/> </cell> </row> <row> Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -24,6 +24,7 @@ import static org.nuiton.i18n.I18n.t; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -32,6 +33,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.ExportStorage; +import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.ui.WelcomePanelUI; import fr.ifremer.isisfish.ui.models.common.GenericListModel; @@ -56,10 +60,6 @@ refresh(); } - protected SimulAction getSimulAction() { - return tabUI.getContextValue(SimulAction.class); - } - public void refresh() { // FIXME listen for export modification here @@ -69,12 +69,12 @@ } protected void setListSimulExportChooseModel() { - java.util.List<String> availableExports = getSimulAction().getExportNames(); - java.util.List<String> userExports = getSimulAction().getSimulationParameter().getExportNames(); + java.util.List<String> availableExports = getExportNames(); + java.util.List<String> userExports = getParameters().getExportNames(); // userExports = intersection(userExports,availableExports) userExports.retainAll(availableExports); - GenericListModel<String> exportModel = new GenericListModel<String>(availableExports); + GenericListModel<String> exportModel = new GenericListModel<>(availableExports); tabUI.listSimulExportChoose.setModel(exportModel); for (String userExport : userExports) { @@ -90,7 +90,7 @@ for (String o : values) { exportNames.add(o); } - getSimulAction().getSimulationParameter().setExportNames(exportNames); + getParameters().setExportNames(exportNames); if (log.isDebugEnabled()) { log.debug("Set exports in simulation : " + exportNames); @@ -100,13 +100,13 @@ 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>(); + List<String> exportNames = new LinkedList<>(); for (String o : values) { exportNames.add(o); } - getSimulAction().getSimulationParameter().setExportNames(exportNames); + getParameters().setExportNames(exportNames); - getSimulAction().saveExport(); + saveExport(); setInfoText(t("isisfish.export.saved")); } @@ -115,4 +115,30 @@ WelcomePanelUI root = tabUI.getParentContainer(WelcomePanelUI.class); root.setStatusMessage(txt); } + + /* + * ExportUI + */ + + public List<String> getExportNames() { + List<String> exportNames = ExportStorage.getExportNames(); + List<String> result = new ArrayList<>(exportNames); + return result; + } + + /** + * Save current parameters exports names in configuration. + */ + public void saveExport() { + + SimulationParameter param = getParameters(); + if (param.getExportNames() != null) { + + if (log.isDebugEnabled()) { + log.debug("Set exports in configuration : " + param.getExportNames()); + } + + IsisFish.config.setDefaultExportNames(param.getExportNames()); + } + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -26,6 +26,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -83,8 +84,7 @@ public void refresh() { // get info - SimulAction simulAction = tabUI.getContextValue(SimulAction.class); - SimulationParameter param = simulAction.getSimulationParameter(); + SimulationParameter param = getParameters(); RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class); // refresh after simulation storage set @@ -106,17 +106,6 @@ } /** - * Get simulation parameter from ui context. - * - * @return simulation parameters - */ - protected SimulationParameter getSimulationParameter() { - SimulAction simulAction = tabUI.getContextValue(SimulAction.class); - SimulationParameter param = simulAction.getSimulationParameter(); - return param; - } - - /** * Optimization model for combo box. * * @return model @@ -141,7 +130,7 @@ */ public void objectiveChanged() { String objectiveName = (String)tabUI.getFieldObjectiveMethodSelect().getSelectedItem(); - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class); // creation new instance only when name change to not lose parameters value @@ -211,12 +200,12 @@ @Override public void windowClosing(WindowEvent e) { // get first factor - FactorGroup factorGroup = sensitivityTabUI.getContextValue(SimulAction.class).getFactorGroup(); + FactorGroup factorGroup = getFactorGroup(); if (factorGroup.size() > 0) { Factor factor = factorGroup.get(factorGroup.size() - 1); // useless, but clear for next call - sensitivityTabUI.getContextValue(SimulAction.class).removeFactor(factor.getPath()); + removeFactor(factor.getPath()); setSelectedFactor(factor); } } @@ -227,8 +216,39 @@ } return factorEditorListener; } + + /** + * Remove factor in factor group tree by path. + * + * @param factorPath factor path to remove + * @deprecated this is a hack i think, should not be here and not used at all + */ + @Deprecated + public void removeFactor(String factorPath) { + removeFactor(getFactorGroup(), factorPath); + } /** + * Recursive remove for factor in factor group by path. + * + * @param factorGroup factor group to search to + * @param factorPath factor path to remove + * @deprecated this is a hack i think, should not be here and not used at all + */ + @Deprecated + protected void removeFactor(FactorGroup factorGroup, String factorPath) { + Collection<Factor> factorCopy = new ArrayList<Factor>(factorGroup.getFactors()); + for (Factor factor : factorCopy) { + if (factor instanceof FactorGroup) { + removeFactor((FactorGroup)factor, factorPath); + } + if (factorPath.equals(factor.getPath())) { + factorGroup.remove(factor); + } + } + } + + /** * Optimization model for combo box. * * @return model @@ -253,7 +273,7 @@ */ public void optimizationChanged() { String optimizationName = (String)tabUI.getFieldOptimizationMethodSelect().getSelectedItem(); - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); RegionStorage regionStorage = tabUI.getContextValue(RegionStorage.class); // creation new instance only when name change to not lose parameters value @@ -311,7 +331,7 @@ * @return model */ public ExportObservationTableModel getExportObservationTableModel() { - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); Map<ExportInfo, Observation> optimizationExportsObservations = param.getOptimizationExportsObservations(); ExportObservationTableModel model = new ExportObservationTableModel(optimizationExportsObservations); return model; @@ -322,7 +342,7 @@ */ public void addExports() { // get elements - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel(); // add all selected exports @@ -349,7 +369,7 @@ */ public void removeExports() { // get element - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); Map<ExportInfo, Observation> optimizationExports = param.getOptimizationExportsObservations(); ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel(); @@ -371,7 +391,7 @@ */ public void clearExports() { // get elements - SimulationParameter param = getSimulationParameter(); + SimulationParameter param = getParameters(); Map<ExportInfo, Observation> optimizationExports = param.getOptimizationExportsObservations(); ExportObservationTableModel tableModel = (ExportObservationTableModel)tabUI.getExportObservationTable().getModel(); Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -22,38 +22,73 @@ */ package fr.ifremer.isisfish.ui.simulator; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULES_KEY; import static org.nuiton.i18n.I18n.t; +import java.awt.BorderLayout; +import java.awt.CardLayout; import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.io.File; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.ComboBoxModel; import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.SwingUtilities; +import org.apache.commons.collections4.CollectionUtils; 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 fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.IsisFishRuntimeException; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.datastore.SimulatorStorage; 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.Species; import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.mexico.MexicoHelper; +import fr.ifremer.isisfish.simulator.SimulationParameter; 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.simulator.sensitivity.DesignPlan; +import fr.ifremer.isisfish.simulator.sensitivity.Factor; +import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup; +import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis; 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; +import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardHandler; +import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI; +import fr.ifremer.isisfish.ui.util.ErrorHelper; +import jaxx.runtime.SwingUtil; /** * Params UI handler. @@ -65,6 +100,8 @@ /** Class logger. */ private static final Log log = LogFactory.getLog(ParamsHandler.class); + private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd-HH-mm"); + protected ParamsUI tabUI; // instances variables déclaration @@ -73,6 +110,8 @@ protected List<String> oldSimulNames = null; + protected String simulationName; + protected ParamsHandler(ParamsUI tabUI) { super(tabUI); this.tabUI = tabUI; @@ -113,19 +152,102 @@ // la gestion des regles est maintenant independante de SimulAction // il faut faire la lié aux parametres de simulations - getSimulAction().getSimulationParameter().setRules(tabUI.ruleChooser.getRulesList()); + getParameters().setRules(tabUI.ruleChooser.getRulesList()); } + public void setSimulationName(String simulationName) { + this.simulationName = simulationName; + } + public void refresh() { - if (getSimulAction().getSimulationStorage() != null) { - tabUI.fieldSimulParamsName.setText(getSimulAction().getSimulationStorage().getName()); - } - tabUI.fieldSimulParamsDesc.setText(getSimulAction().getSimulationParameter().getDescription()); + tabUI.fieldSimulParamsDesc.setText(getParameters().getDescription()); setListSimulParamsStrategiesItems(); setListSimulParamsPopulationsItems(); } /** + * Change region in simulation launcher + * + * @param regionName region name + */ + public void regionChange(String regionName) { + RegionStorage regionStorage = RegionStorage.getRegion(regionName); + // TODO this could be changed by setting storage into simulation context + tabUI.getParentContainer(SimulationUI.class).setContextValue(regionStorage); + tabUI.getParentContainer(SimulationUI.class).setRegionStorage(regionStorage); + getParameters().setRegionName(regionName); + } + + /** + * Load old simulation. + * + * Reset some field to empty default values: + * <ul> + * <li>params</li> + * <li>simulation plans</li> + * <li>factors list</li> + * </ul> + * + * Open old simulation: + * <ul> + * <li>params copy</li> + * <li>factors</li> + * </ul> + * + * @param simulName name of simulation to load + */ + public void loadOldSimulation(String simulName) { + if (log.isDebugEnabled()) { + log.debug("call loadOldSimulation: " + simulName); + } + try { + SimulatorContext context = tabUI.getContextValue(SimulatorContext.class); + + // read storage to get name + SimulationStorage simulStorage = SimulationStorage.getSimulation(simulName); + tabUI.getFieldSimulParamsName().setText(simulStorage.getName()); + + SimulationParameter param = simulStorage.getParameter().copy(); + // all time reset number after load + param.setSimulationPlanNumber(-1); + context.setSimulationParameter(param); + + + RegionStorage regionStorage = param.getRegion(); + context.setRegionStorage(regionStorage); + + // Chargement des facteurs + // clear list even if mexico file doesn't exists + getFactorGroup().clearFactors(); + File f = SimulationStorage.getMexicoDesignPlan(SimulationStorage.getSimulationDirectory(simulName)); + if (f != null && f.canRead()) { + if (log.isInfoEnabled()) { + log.info("Import design plan from : " + f.getAbsolutePath()); + } + TopiaContext topiaContext = regionStorage.getStorage(); + DesignPlan designPlan = MexicoHelper.getDesignPlanFromXML(f, topiaContext); + for (Factor factor : designPlan.getFactors()) { + if (log.isDebugEnabled()) { + log.debug("Find factor : " + factor.getName()); + } + //factors.put(factor.getPath() + factor.getName(), factor); + FactorGroup factorGroup = designPlan.getFactorGroup(); + context.setFactorGroup(factorGroup); + } + } + else if (log.isInfoEnabled()) { + log.info("No xml design plan file found"); + } + } catch (Exception eee) { + throw new IsisFishRuntimeException(t("isisfish.error.simulation.loadoldsimulation"), eee); + } + } + + public List<SimulatorLauncher> getSimulationLauncher() { + return SimulationService.getService().getSimulationLaunchers(); + } + + /** * Called on user region selection change. */ protected void regionChange() { @@ -139,7 +261,7 @@ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - getSimulAction().regionChange(tabUI, selected); + regionChange(selected); // FIXME fix this if (!tabUI.isSensitivity()) { tabUI.getParentContainer(SimulUI.class).refresh(); @@ -156,16 +278,16 @@ protected void initSimulationParams() { if (!tabUI.isSensitivity()){ // prescript - String preScript = getSimulAction().getSimulationParameter().getPreScript(); + String preScript = getParameters().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.fieldSimulUseSimulationPlan.setSelected(getParameters().getUseSimulationPlan()); tabUI.getParentContainer(SimulUI.class).getPlanUI().getHandler().refresh(); // optimization - tabUI.fieldSimulUseOptimization.setSelected(getSimulAction().getSimulationParameter().getUseOptimization()); + tabUI.fieldSimulUseOptimization.setSelected(getParameters().getUseOptimization()); tabUI.getParentContainer(SimulUI.class).getOptimizationUI().getHandler().refresh(); } @@ -175,8 +297,8 @@ if (tabUI.isSensitivity()) { try { // FIXME this transaction in never closed - // and can't be closed because used in - TopiaContext tx = getSimulAction().getRegionStorage().getStorage().beginTransaction(); + // and can't be closed because used in + TopiaContext tx = tabUI.getContextValue(RegionStorage.class).getStorage().beginTransaction(); FisheryRegion fisheryRegion = RegionStorage.getFisheryRegion(tx); tabUI.getParentContainer(SensitivityUI.class).getSensitivityInputUI().setFisheryRegion(fisheryRegion); tabUI.getParentContainer(SensitivityUI.class).getSensitivityInputUI().getHandler().setTreeModel(); @@ -196,7 +318,7 @@ 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()); + tabUI.sensitivityOnlyKeepFirstResultCheckBox.setSelected(getParameters().isSensitivityAnalysisOnlyKeepFirst()); } } @@ -215,8 +337,8 @@ @Override public void run() { - getSimulAction().loadOldSimulation(selected); - tabUI.fieldSimulParamsRegion.setSelectedItem(tabUI.getContextValue(SimulAction.class).getSimulationParameter().getRegionName()); + loadOldSimulation(selected); + tabUI.fieldSimulParamsRegion.setSelectedItem(getParameters().getRegionName()); // FIXME fix this if (!tabUI.isSensitivity()) { @@ -226,12 +348,12 @@ } // mise a jour des années - tabUI.fieldSimulParamsNbMois.setText(String.valueOf(getSimulAction().getNumberOfMonths())); + tabUI.fieldSimulParamsNbMois.setText(String.valueOf(getNumberOfMonths())); initSimulationParams(); initSensitivityParams(); // regles - tabUI.ruleChooser.setRulesList(getSimulAction().getSimulationParameter().getRules()); + tabUI.ruleChooser.setRulesList(getParameters().getRules()); tabUI.getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.old.simulation.loaded")); tabUI.setCursor(Cursor.getDefaultCursor()); @@ -246,9 +368,9 @@ protected void launchSimulation() { if (!tabUI.isSensitivity()) { - getSimulAction().launchSimulation(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem()); + launchSimulation(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem()); } else { - getSimulAction().launchSimulationWithSensibility(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem()); + launchSimulationWithSensibility(tabUI.fieldSimulParamsName.getText(), (SimulatorLauncher)tabUI.comboSelLauncher.getSelectedItem()); } // dans le cas d'une fenetre independante, il n'y a pas de ParentContainer @@ -257,27 +379,261 @@ parent.setQueueTabSelection(); } } + + /** + * Launch simulation with factors variations parameters. + * + * @param simulationId id of the simulation to simulate + * @param launcher launcher to use + * + * @see SimulatorLauncher + * @see SensitivityAnalysis + * @see DesignPlan + */ + public void launchSimulationWithSensibility(String simulationId, + SimulatorLauncher launcher) { + + String fullSimulationId = "as_" + simulationId + "_" + + DATEFORMAT.format(new java.util.Date()); + + SensitivityAnalysis sensitivityAnalysis = getParameters().getSensitivityAnalysis(); + + // log + if (log.isDebugEnabled()) { + log.debug("Launch factor simulation with custom launcher " + + launcher.toString()); + log.debug("Using sensitivityCalculator : " + + sensitivityAnalysis.getDescription()); + } + + try { + if (checkAndPrepare(fullSimulationId)) { + DesignPlan designPlan = new DesignPlan(); + designPlan.setFactorGroup(getFactorGroup()); + SimulationService.getService().submit(fullSimulationId, getParameters(), + launcher, 0, sensitivityAnalysis, designPlan); + } + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't start simulation", eee); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.launchsimulation"), eee); + } + } + + protected boolean checkAndPrepare(String fullSimulationId) { + boolean result = !("".equals(fullSimulationId) + || SimulationStorage.localyExists(fullSimulationId) + || SimulationService.getService().exists(fullSimulationId)); + + if (result) { + // force all necessary config simulation in tag value + Map<String, String> m = new HashMap<String, String>( + IsisFish.config.getDefaultSimulationConfig()); + Map<String, String> tv = getParameters().getTagValue(); + m.putAll(tv); + getParameters().setTagValue(m); + } else { + ErrorHelper.showErrorDialog(t("isisfish.simulator.simulaction.badid", + fullSimulationId), null); + } + + return result; + } + /** + * Launch automatically the simulation, when is possible (no other simulation) + * or wait for the last automatically simulation ended. + * + * @param simulationId id of the simulation to simulate + * @param launcher launcher to use + * + * @see SimulatorLauncher + */ + public void launchSimulation(String simulationId, SimulatorLauncher launcher) { + + String fullSimulationId = "sim_" + simulationId + "_" + + DATEFORMAT.format(new java.util.Date()); + + // log + if (log.isDebugEnabled()) { + log.debug("Launch simulation with custom launcher " + + launcher.toString()); + } + + try { + if (checkAndPrepare(fullSimulationId)) { + SimulationService.getService().submit(fullSimulationId, getParameters(), + launcher, 0); + } + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't start simulation", eee); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.launchsimulation"), eee); + } + } + + /** + * Population selection changed. + * + * Fill matrix panel with population effective of selected population. + */ + public void populationSelected() { + CardLayout layout = (CardLayout)tabUI.getPopulationEffectivesPanel().getLayout(); + + List<Population> selectedPopulationsValues = tabUI.getListSimulParamsPopulations().getSelectedValuesList(); + if (CollectionUtils.isNotEmpty(selectedPopulationsValues)) { + tabUI.getPopulationEffectivesTabbedPane().removeAll(); + setPopulations(selectedPopulationsValues); + + for (Population selectedPopulation : selectedPopulationsValues) { + final MatrixPanelEditor matrixPanel = new MatrixPanelEditor(); + MatrixND populationEffectives = getParameters().getNumberOf(selectedPopulation); + matrixPanel.setMatrix(populationEffectives); + + JPanel matrixPanelComponent = new JPanel(new BorderLayout()); + matrixPanelComponent.add(matrixPanel, BorderLayout.CENTER); + + // add addFactorButton with matrixPanel (just in sensitivity cas) + if (tabUI.isSensitivity()) { + matrixPanel.putClientProperty("sensitivityPopulation", selectedPopulation); + // TODO add another thing that action + JButton addFactorButton = new JButton(); + addFactorButton.setAction(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + addFactorWithComponent(matrixPanel); + } + @Override + public Object getValue(String key) { + Object result = null; + if (key.equals(Action.SMALL_ICON)) { + result = SwingUtil.createImageIcon("building_add.png"); + } + return result; + } + }); + matrixPanelComponent.add(addFactorButton, BorderLayout.EAST); + } + + tabUI.getPopulationEffectivesTabbedPane().add(matrixPanelComponent, + t("isisfish.params.populationEffectives", selectedPopulation.getName())); + } + + layout.show(tabUI.getPopulationEffectivesPanel(), "specific"); + } + else { + layout.show(tabUI.getPopulationEffectivesPanel(), "default"); + } + } + + /** + * Action appelée lors du clic sur les boutons a coté des composants factorisables. + * + * Contrairement à l'interface 'input', on edite ici des facteurs existants, + * (créé à la première demande). + * + * @param source la source de l'event + */ + public void addFactorWithComponent(JComponent source) { + + if (log.isDebugEnabled()) { + log.debug("Event intercepted on " + source); + } + + Factor selectedFactor = null; + + // new factor with rule domain + if (source instanceof RuleChooser) { + String factorPath = PARAMETERS_KEY + DOT + RULES_KEY; + selectedFactor = getFactor(factorPath); + if (selectedFactor == null) { + selectedFactor = new Factor(t("isisfish.sensitivity.rulesfactorname")); + selectedFactor.setPath(factorPath); + //selectedFactor.setDomain(new RuleDiscreteDomain()); + } + } + + // new factor with matrix continous domain + else if (source instanceof MatrixPanelEditor) { + Population population = (Population)source.getClientProperty("sensitivityPopulation"); + String factorPath = PARAMETERS_KEY + DOT + POPULATION_KEY + DOT + population.getName() + DOT + NUMBER_KEY; + selectedFactor = getFactor(factorPath); + if (selectedFactor == null) { + selectedFactor = new Factor(t("isisfish.sensitivity.populationfactorname", population.getName())); + selectedFactor.setPath(factorPath); + //MatrixND populationEffectives = getSimulationParameter().getNumberOf(population); + /*MatrixContinuousDomain factorDomain = new MatrixContinuousDomain(); + factorDomain.setReferenceValue(populationEffectives.copy()); + factorDomain.setCoefficient(0.0); + ContinuousDomain domain = new ContinuousDomain(Distribution.QUNIFPC); + domain.addDistributionParam(Distribution.QUNIFPC.getDistibutionParams()[0].getName(), populationEffectives.copy()); + domain.addDistributionParam(Distribution.QUNIFPC.getDistibutionParams()[1].getName(), 0.0d); + selectedFactor.setDomain(domain);*/ + } + } + + if (selectedFactor != null) { + FactorWizardUI wizard = new FactorWizardUI(tabUI); + FactorWizardHandler handler = wizard.getHandler(); + handler.initExistingFactor(wizard, selectedFactor); + wizard.pack(); + wizard.setLocationRelativeTo(tabUI); + wizard.setVisible(true); + } + } + + /** + * Search factor in factor group tree by path. + * + * @param factorPath factor path to search + * @return found factor + */ + public Factor getFactor(String factorPath) { + return getFactor(getFactorGroup(), factorPath); + } + + /** + * Recursive search for factor in factor group by path. + * + * @param factorGroup factor group to search to + * @param factorPath factor path to search + * @return found factor + */ + protected Factor getFactor(FactorGroup factorGroup, String factorPath) { + Factor result = null; + for (Factor factor : factorGroup.getFactors()) { + if (factor instanceof FactorGroup) { + result = getFactor((FactorGroup)factor, factorPath); + } + if (factorPath.equals(factor.getPath())) { + result = factor; + } + } + return result; + } + protected void enablePreScript() { - getSimulAction().getSimulationParameter().setUsePreScript(tabUI.fieldUseSimulPreScripts.isSelected()); + getParameters().setUsePreScript(tabUI.fieldUseSimulPreScripts.isSelected()); SimulationUI simulationUI = tabUI.getParentContainer(SimulationUI.class); simulationUI.setEnabledPrescriptTab(tabUI.fieldUseSimulPreScripts.isSelected()); } + protected void enableSimulationPlan() { - getSimulAction().getSimulationParameter().setUseSimulationPlan(tabUI.fieldSimulUseSimulationPlan.isSelected()); + getParameters().setUseSimulationPlan(tabUI.fieldSimulUseSimulationPlan.isSelected()); SimulationUI simulationUI = tabUI.getParentContainer(SimulationUI.class); simulationUI.setEnabledSimulationPlanTab(tabUI.fieldSimulUseSimulationPlan.isSelected()); } protected void enableOptimization() { - getSimulAction().getSimulationParameter().setUseOptimization(tabUI.fieldSimulUseOptimization.isSelected()); + getParameters().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<Strategy> listSimulParamsStrategiesModel = new DefaultListModel<Strategy>(); - List<Strategy> strategies = getSimulAction().getStrategies(); + List<Strategy> strategiesSelected = getParameters().getStrategies(); + DefaultListModel<Strategy> listSimulParamsStrategiesModel = new DefaultListModel<>(); + List<Strategy> strategies = getStrategies(); for (Strategy s : strategies){ listSimulParamsStrategiesModel.addElement(s); } @@ -291,9 +647,9 @@ } } protected void setListSimulParamsPopulationsItems(){ - List<Population> populationsSelected = getSimulAction().getSimulationParameter().getPopulations(); - DefaultListModel<Population> listSimulParamsPopulationsModel = new DefaultListModel<Population>(); - List<Population> populations = getSimulAction().getPopulations(); + List<Population> populationsSelected = getParameters().getPopulations(); + DefaultListModel<Population> listSimulParamsPopulationsModel = new DefaultListModel<>(); + List<Population> populations = getPopulations(); for (Population p : populations){ listSimulParamsPopulationsModel.addElement(p); } @@ -307,8 +663,8 @@ } } - protected void strategySelected(){ - getSimulAction().setStrategies(tabUI.listSimulParamsStrategies.getSelectedValuesList()); + protected void strategySelected() { + setStrategies(tabUI.listSimulParamsStrategies.getSelectedValuesList()); } protected ComboBoxModel<String> getSimulParamsSelectModel() { @@ -380,4 +736,98 @@ public void resetOldSimulatorNames() { oldSimulNames = getOldSimulationItem(); } + + /** + * Get strategies list to fill Jlist in ParamUI. + * + * @return strategies list + */ + public List<Strategy> getStrategies() { + List<Strategy> result = new ArrayList<>(); + try { + TopiaContext tx = getParameters().getRegion().getStorage().beginTransaction(); + result = RegionStorage.getFisheryRegion(tx).getStrategy(); + tx.rollbackTransaction(); + tx.closeContext(); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't get strategies", e); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.liststrategies"), e); + } + return result; + } + + /** + * Set parameters strategies. + * + * @param strategies + */ + public void setStrategies(List<Strategy> strategies) { + List<Strategy> result = new ArrayList<>(strategies); + getParameters().setStrategies(result); + } + + /** + * Get population list to fill JList in paramUI. + * + * @return populations list + */ + public List<Population> getPopulations() { + + List<Population> result = new ArrayList<>(); + try { + TopiaContext tx = getParameters().getRegion().getStorage().beginTransaction(); + List<Species> species = RegionStorage.getFisheryRegion(tx) + .getSpecies(); + for (Species s : species) { + Collection<Population> populations = s.getPopulation(); + + // FIXME initialiaze lazy hibernate collection + for (Population p : populations) { + p.getPopulationGroup().size(); + p.getPopulationZone().size(); + } + + result.addAll(populations); + } + tx.rollbackTransaction(); + tx.closeContext(); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't get population", e); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listpopulation"), e); + } + return result; + } + + /** + * Set parameter population. + * + * @param populations populations to set + */ + public void setPopulations(List<Population> populations) { + List<Population> result = new ArrayList<>(populations); + getParameters().setPopulations(result); + } + + public int getNumberOfMonths() { + return getParameters().getNumberOfMonths(); + } + + /** + * Change number of simulation month by parsing string value. + * Default to 1 if value is not parsable. + * + * @param months number of months to set + */ + public void setNumberOfMonths(String months) { + try { + getParameters().setNumberOfMonths(Integer.parseInt(months)); + } catch (NumberFormatException ex) { + // defaut to one year + getParameters().setNumberOfMonths(1); + } + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-06-08 13:47:32 UTC (rev 4246) @@ -80,8 +80,8 @@ <JTextField id="fieldSimulParamsName" /> <javax.swing.text.Document javaBean="fieldSimulParamsName.getDocument()" - onInsertUpdate='getContextValue(SimulAction.class).setName(fieldSimulParamsName.getText())' - onRemoveUpdate='getContextValue(SimulAction.class).setName(fieldSimulParamsName.getText())' /> + onInsertUpdate='handler.setSimulationName(fieldSimulParamsName.getText())' + onRemoveUpdate='handler.setSimulationName(fieldSimulParamsName.getText())' /> </cell> </row> </Table> @@ -95,7 +95,7 @@ <cell fill="horizontal" weightx="1.0"> <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()}' + selectedItem='{handler.getParameters().getRegionName()}' onActionPerformed='handler.regionChange()' /> </cell> </row> @@ -112,11 +112,11 @@ weighty="0.3"> <JScrollPane> <JTextArea id="fieldSimulParamsDesc" - text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' /> + text='{handler.getParameters().getDescription()}' /> <javax.swing.text.Document javaBean="fieldSimulParamsDesc.getDocument()" - onInsertUpdate='getContextValue(SimulAction.class).getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())' - onRemoveUpdate='getContextValue(SimulAction.class).getSimulationParameter().setDescription(fieldSimulParamsDesc.getText())' /> + onInsertUpdate='handler.getParameters().setDescription(fieldSimulParamsDesc.getText())' + onRemoveUpdate='handler.getParameters().setDescription(fieldSimulParamsDesc.getText())' /> </JScrollPane> </cell> </row> @@ -132,11 +132,11 @@ <cell fill="both" weightx="1.0"> <JTextField id="fieldSimulParamsNbMois" - text='{String.valueOf(getContextValue(SimulAction.class).getSimulationParameter().getNumberOfMonths())}' /> + text='{String.valueOf(handler.getParameters().getNumberOfMonths())}' /> <javax.swing.text.Document javaBean="fieldSimulParamsNbMois.getDocument()" - onInsertUpdate='getContextValue(SimulAction.class).setNumberOfMonths(fieldSimulParamsNbMois.getText())' - onRemoveUpdate='getContextValue(SimulAction.class).setNumberOfMonths(fieldSimulParamsNbMois.getText())' /> + onInsertUpdate='handler.setNumberOfMonths(fieldSimulParamsNbMois.getText())' + onRemoveUpdate='handler.setNumberOfMonths(fieldSimulParamsNbMois.getText())' /> </cell> </row> </Table> @@ -177,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='getContextValue(SimulAction.class).populationSelected(this)' + onValueChanged='handler.populationSelected()' enabled="{getRegionStorage() != null}" /> </JScrollPane> </cell> @@ -211,7 +211,7 @@ <cell anchor="north"> <JButton id="addRuleFactorButton" icon='{SwingUtil.createImageIcon("building_add.png")}' - onActionPerformed="getContextValue(SimulAction.class).addFactorWithComponent(this, ruleChooser)" + onActionPerformed="handler.addFactorWithComponent(ruleChooser)" visible="{isSensitivity()}" enabled="{getRegionStorage() != null}" /> </cell> @@ -231,14 +231,14 @@ <cell fill="horizontal" weightx="1"> <JCheckBox text="isisfish.params.usePreSimulationScript" id="fieldUseSimulPreScripts" - selected='{getContextValue(SimulAction.class).getSimulationParameter().getUsePreScript()}' + selected='{handler.getParameters().getUsePreScript()}' visible='{!isSensitivity()}' onItemStateChanged='handler.enablePreScript()' /> </cell> <cell fill="horizontal" weightx="1"> <JCheckBox text="isisfish.params.useSimulationPlan" id="fieldSimulUseSimulationPlan" - selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseSimulationPlan()}' + selected='{handler.getParameters().getUseSimulationPlan()}' visible='{!isSensitivity()}' onItemStateChanged='handler.enableSimulationPlan()' enabled="{getRegionStorage() != null}" /> @@ -246,7 +246,7 @@ <cell fill="horizontal" weightx="1"> <JCheckBox text="isisfish.params.useOptimization" id="fieldSimulUseOptimization" - selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseOptimization()}' + selected='{handler.getParameters().getUseOptimization()}' visible='{!isSensitivity()}' onItemStateChanged='handler.enableOptimization()' enabled="{getRegionStorage() != null}" /> @@ -254,9 +254,9 @@ <cell fill="horizontal" weightx="1"> <JCheckBox text="isisfish.params.sensitivityOnlyKeepFirstResult" id="sensitivityOnlyKeepFirstResultCheckBox" - selected='{getContextValue(SimulAction.class).getSimulationParameter().isSensitivityAnalysisOnlyKeepFirst()}' + selected='{handler.getParameters().isSensitivityAnalysisOnlyKeepFirst()}' visible='{isSensitivity()}' - onItemStateChanged='getContextValue(SimulAction.class).getSimulationParameter().setSensitivityAnalysisOnlyKeepFirst(sensitivityOnlyKeepFirstResultCheckBox.isSelected())' + onItemStateChanged='handler.getParameters().setSensitivityAnalysisOnlyKeepFirst(sensitivityOnlyKeepFirstResultCheckBox.isSelected())' enabled="{getRegionStorage() != null}" /> </cell> </row> @@ -273,7 +273,7 @@ <cell fill="horizontal" weightx="0.4"> <JComboBox id="comboSelLauncher" genericType="fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher" - model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulationLauncher().toArray())}' /> + model='{new DefaultComboBoxModel(handler.getSimulationLauncher().toArray())}' /> </cell> <cell fill="horizontal" weightx="0.4"> <JButton id="buttonSimulParamsSimulate" @@ -284,7 +284,7 @@ <cell fill="horizontal" weightx="0.2"> <JButton id="saveSimul" text="isisfish.simulation.menu.save" - onActionPerformed='getParentContainer(fr.ifremer.isisfish.ui.SimulationUI.class).saveSimulation()' + onActionPerformed='getParentContainer(fr.ifremer.isisfish.ui.SimulationUI.class).getHandler().saveSimulation()' enabled="{getRegionStorage() != null}" /> </cell> </row> Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -26,6 +26,8 @@ import javax.swing.table.DefaultTableModel; +import fr.ifremer.isisfish.IsisFishException; +import fr.ifremer.isisfish.IsisFishRuntimeException; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.SimulationPlanStorage; import fr.ifremer.isisfish.datastore.StorageChangeEvent; @@ -36,6 +38,7 @@ 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.widget.editor.ScriptParameterDialog; /** * Plan UI handler. @@ -75,10 +78,45 @@ } /** + * Return simulation plan names list. + * + * @return simulation plan names + */ + public List<String> getSimulationPlanNames() { + return SimulationPlanStorage.getSimulationPlanNames(); + } + + public List<SimulationPlan> getParamSimulationPlans() { + return getParameters().getSimulationPlans(); + } + + public void addSimulationPlan(PlanUI planUI, String name) { + try { + SimulationPlan sp = SimulationPlanStorage.getSimulationPlan(name).getNewInstance(); + + // add it after autoconfiguration (if enabled) + sp = (SimulationPlan)ScriptParameterDialog.displayConfigurationFrame(planUI, sp); + if (sp != null) { + getParameters().addSimulationPlan(sp); + } + } catch (IsisFishException ex) { + throw new IsisFishRuntimeException("Can't add simulation plan", ex); + } + } + + public void removeSimulationPlan(SimulationPlan sp) { + getParameters().removeSimulationPlan(sp); + } + + public void clearSimulationPlans() { + getParameters().clearPlans(); + } + + /** * Refresh simulation plan names list. */ protected GenericComboModel<String> getSimulationPlansComboModel() { - List<String> simulationPlanNames = tabUI.simulAction.getSimulationPlanNames(); + List<String> simulationPlanNames = getSimulationPlanNames(); GenericComboModel<String> model = new GenericComboModel<>(simulationPlanNames); return model; } @@ -87,33 +125,33 @@ * Refresh simulation simulation plan list. */ protected GenericListModel<SimulationPlan> getSimulationSimulationPlansListModel() { - List<SimulationPlan> simulationPlans = tabUI.simulAction.getParamSimulationPlans(); + List<SimulationPlan> simulationPlans = getParamSimulationPlans(); GenericListModel<SimulationPlan> model = new GenericListModel<>(simulationPlans); return model; } protected void addSimulationPlan() { String selectedSimulationPlanName = (String)tabUI.fieldSimulParamsSimulationPlansSelect.getSelectedItem(); - tabUI.simulAction.addSimulationPlan(tabUI, selectedSimulationPlanName); + addSimulationPlan(tabUI, selectedSimulationPlanName); tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel()); setSimulationPlanButtons(); } protected void removeSimulationPlan() { SimulationPlan selectedSimulationPlan = (SimulationPlan)tabUI.listSimulParamsSimulationPlansList.getSelectedValue(); - tabUI.simulAction.removeSimulationPlan(selectedSimulationPlan); + removeSimulationPlan(selectedSimulationPlan); tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel()); setSimulationPlanButtons(); } protected void clearSimulationPlan() { - tabUI.simulAction.clearSimulationPlans(); + clearSimulationPlans(); tabUI.listSimulParamsSimulationPlansList.setModel(getSimulationSimulationPlansListModel()); setSimulationPlanButtons(); } protected void setSimulationPlanButtons() { - if (tabUI.getContextValue(SimulAction.class).getParamSimulationPlans().isEmpty()) { + if (getParamSimulationPlans().isEmpty()) { tabUI.buttonSimulParamsSimulationPlansClear.setEnabled(false); tabUI.buttonSimulParamsSimulationPlansRemove.setEnabled(false); } else { Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PlanUI.jaxx 2015-06-08 13:47:32 UTC (rev 4246) @@ -29,8 +29,6 @@ java.awt.Dimension </import> - <SimulAction id='simulAction' javaBean='getContextValue(SimulAction.class)' /> - <script><![CDATA[ protected void $afterCompleteSetup() { handler.afterInit(); Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -41,7 +41,7 @@ } protected void save() { - tabUI.getContextValue(SimulAction.class).getSimulationParameter().setPreScript(tabUI.fieldSimulPreScript.getText()); + getParameters().setPreScript(tabUI.fieldSimulPreScript.getText()); } public void refresh() { Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -24,12 +24,20 @@ import static org.nuiton.i18n.I18n.t; +import java.lang.reflect.Field; +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 fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.ScriptStorage; import fr.ifremer.isisfish.ui.WelcomePanelUI; import fr.ifremer.isisfish.ui.models.common.GenericListModel; +import fr.ifremer.isisfish.ui.util.ErrorHelper; /** * Result choice UI handler. @@ -38,6 +46,8 @@ */ public class ResultChoiceHandler extends SimulatorTabHandler { + private static final Log log = LogFactory.getLog(ResultChoiceHandler.class); + protected ResultChoiceUI tabUI; public ResultChoiceHandler(ResultChoiceUI tabUI) { @@ -56,10 +66,39 @@ setListSimulResultChooseModel(); } + /** + * Looking for ResultName.java script and read all fields and fill + * list of field value and doc + * @return the list of result names found in ResultName script + */ + protected List<String> getResultNames() { + List<String> result = new ArrayList<String>(); + try { + ScriptStorage storage = ScriptStorage.getScript("ResultName.java"); + Class<?> resultNameClass = storage.getCodeClass(); + // TODO: if we can't find class, perhaps try to parser Java source ? + Field[] fields = resultNameClass.getFields(); + for (Field f : fields) { + String fieldName = (String) f.get(null); + result.add(fieldName); + } + } catch (Exception eee) { + if (log.isWarnEnabled()) { + log.warn("Can't find result name script", eee); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.getresultname"), eee); + } + return result; + } + + public List<String> getDefaultResultNames() { + return IsisFish.config.getDefaultResultNamesAsList(); + } + protected void setListSimulResultChooseModel() { - List<String> availableResults = getSimulAction().getResultNames(); - List<String> userResults = getSimulAction().getDefaultResultNames(); + List<String> availableResults = getResultNames(); + List<String> userResults = getDefaultResultNames(); // userResults = intersection(userResults,availableResult) userResults.retainAll(availableResults); @@ -73,14 +112,32 @@ } protected void saveParametersResultNames(ListSelectionEvent event) { - tabUI.getContextValue(SimulAction.class).saveParametersResultNames(tabUI.listResultNames.getSelectedValuesList()); + saveParametersResultNames(tabUI.listResultNames.getSelectedValuesList()); } protected void saveConfigResultNames() { - tabUI.getContextValue(SimulAction.class).saveConfigurationResultNames(tabUI.listResultNames.getSelectedValuesList()); + saveConfigurationResultNames(tabUI.listResultNames.getSelectedValuesList()); setStatusMessage(t("isisfish.resultChoice.saved")); } + + public void saveParametersResultNames(List<String> resultNames) { + List<String> resultNamesString = new ArrayList<>(resultNames); + getParameters().setResultEnabled(resultNamesString); + + if (log.isDebugEnabled()) { + log.debug("Set simulation result names : " + resultNamesString); + } + } + public void saveConfigurationResultNames(List<String> resultNames) { + List<String> resultNamesString = new ArrayList<>(resultNames); + IsisFish.config.setDefaultResultNames(resultNamesString); + + if (log.isDebugEnabled()) { + log.debug("Set configuration result names : " + resultNamesString); + } + } + protected void setStatusMessage(String txt) { // TODO remove getParentContainer use WelcomePanelUI root = tabUI.getParentContainer(WelcomePanelUI.class); Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/RuleChooserHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -23,6 +23,10 @@ package fr.ifremer.isisfish.ui.simulator; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY; +import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY; + import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; @@ -33,17 +37,25 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.swing.DropMode; import javax.swing.JList; import javax.swing.TransferHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.IsisFishRuntimeException; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.RuleStorage; import fr.ifremer.isisfish.rule.Rule; +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.models.common.ScriptParametersTableCellEditor; import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer; @@ -63,6 +75,8 @@ */ public class RuleChooserHandler { + private static final Log log = LogFactory.getLog(RuleChooserHandler.class); + protected RuleChooser ruleChooser; public RuleChooserHandler(RuleChooser ruleChooser) { @@ -185,7 +199,6 @@ * Remove selected rules for selected rules list. */ protected void removeSelectedRules() { - SimulAction simulAction = ruleChooser.getContextValue(SimulAction.class); List<Rule> selectedRuleValues = ruleChooser.getSelectedRulesList().getSelectedValuesList(); for (Rule selectedRuleValue : selectedRuleValues) { @@ -193,7 +206,7 @@ // de définition d'une simulation (hack) if (ruleChooser.isShowFactorColumn()) { int ruleIndex = ruleChooser.getRulesList().indexOf(selectedRuleValue); - simulAction.preRemoveRule(ruleIndex); + preRemoveRule(ruleIndex); ruleChooser.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree(); } @@ -211,10 +224,9 @@ // condition pour savoir si on est dans l'instance principal // de définition d'une simulation (hack) if (ruleChooser.isShowFactorColumn()) { - SimulAction simulAction = ruleChooser.getContextValue(SimulAction.class); for (Rule rule : ruleChooser.getRulesList()) { int ruleIndex = ruleChooser.getRulesList().indexOf(rule); - simulAction.preRemoveRule(ruleIndex); + preRemoveRule(ruleIndex); } ruleChooser.getContextValue(SimulationUI.class, "SimulationUI").refreshFactorTree(); } @@ -249,4 +261,63 @@ ruleChooser.getSelectedRuleParameterTableModel().setScript(null); } } + + /** + * Called by RuleChooser component before rule deletion. + * Used to remove factor associated to rule to delete. + * + * Factor path reference rule with factor path containing rule index + * in rule list : + * for example : + * <pre> + * parameters.rule.2.parameter.tacPoids + * </pre> + * + * Must also rename all next indices. + * + * @param ruleIndex rule index to to delete + */ + public void preRemoveRule(int ruleIndex) { + preRemoveRule(ruleChooser.getContextValue(FactorGroup.class), ruleIndex); + } + + /** + * Recursive rename and delete rule factor path. + * + * @param factorGroup factorGroup + * @param ruleIndex rule index to to delete + */ + protected void preRemoveRule(FactorGroup factorGroup, int ruleIndex) { + Collection<Factor> factorCopy = new ArrayList<>(factorGroup.getFactors()); + for (Factor factor : factorCopy) { + if (factor instanceof FactorGroup) { + preRemoveRule((FactorGroup)factor, ruleIndex); + } + else { + Pattern factorPathPattern = Pattern.compile( + "^(" +PARAMETERS_KEY + "\\" + DOT + RULE_KEY + "\\" + DOT + ")(\\d+)(.*)$"); + Matcher factorPathMatcher = factorPathPattern.matcher(factor.getPath()); + if (factorPathMatcher.find()) { + Integer index = Integer.parseInt(factorPathMatcher.group(2)); + if (index == ruleIndex) { + // meme index, suppression + if (log.isDebugEnabled()) { + log.debug("Removing factor for index " + ruleIndex + " : " + factor.getPath()); + } + factorGroup.remove(factor); + } + else if (index > ruleIndex) { + // index supérieur, renommage + // avec un index de moins + String factorPath = factorPathMatcher.group(1) + + String.valueOf(index - 1) + factorPathMatcher.group(3); + if (log.isDebugEnabled()) { + log.debug("Renammed factor for index " + ruleIndex + " : " + factor.getPath()); + } + factor.setPath(factorPath); + } + } + } + } + } } Deleted: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -1,1301 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2005 - 2011 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.simulator; - -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULES_KEY; -import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY; -import static org.nuiton.i18n.I18n.t; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.lang.reflect.Field; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.io.IOUtils; -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 fr.ifremer.isisfish.IsisFish; -import fr.ifremer.isisfish.IsisFishException; -import fr.ifremer.isisfish.IsisFishRuntimeException; -import fr.ifremer.isisfish.datastore.ExportStorage; -import fr.ifremer.isisfish.datastore.RegionStorage; -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.SimulationStorage; -import fr.ifremer.isisfish.datastore.SimulatorStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.Species; -import fr.ifremer.isisfish.entities.Strategy; -import fr.ifremer.isisfish.export.ExportInfo; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.mexico.MexicoHelper; -import fr.ifremer.isisfish.rule.Rule; -import fr.ifremer.isisfish.simulator.SimulationParameter; -import fr.ifremer.isisfish.simulator.SimulationParameterImpl; -import fr.ifremer.isisfish.simulator.SimulationPlan; -import fr.ifremer.isisfish.simulator.launcher.SimulationService; -import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher; -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.simulator.sensitivity.SensitivityAnalysis; -import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException; -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.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.util.ErrorHelper; -import fr.ifremer.isisfish.ui.widget.editor.ScriptParameterDialog; -import jaxx.runtime.SwingUtil; - -/** - * SimulAction. - * - * Created: 1 aout 2005 18:37:25 CEST - * - * @author Benjamin POUSSIN <poussin@codelutin.com> - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class SimulAction { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static Log log = LogFactory.getLog(SimulAction.class); - - private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd-HH-mm"); - - /** - * Les parametres de simulation (commun a tous les onglet de l'interface de simulation). - * Les parametres doivent toujours être liés avec les selections et état de l'ui. - * La mise en facteur des parametres et des regles est basé sur cet objet. - */ - protected SimulationParameter param = null; - - protected RegionStorage regionStorage = null; - protected SimulationStorage simulStorage = null; - protected String simulName = null; - - /** - * List de facteur sous forme d'arbre (factor group). - * {@code null} name for compatibility with 3.3.0.0. - */ - protected FactorGroup factorGroup = new FactorGroup(null); - - public SimulAction() { - init(); - } - - /** - * cree et initialise param avec les valeurs par defaut de l'utilisateur - */ - public void init() { - if (log.isDebugEnabled()) { - log.debug("Init "); - } - try { - param = new SimulationParameterImpl(); - List<String> resultNames = getResultNames(); - // put default value in param - param.setSimulatorName(IsisFish.config.getSimulatorClassfile()); - - Map<String, String> tv = new LinkedHashMap<String, String>(); - tv.putAll(IsisFish.config.getDefaultTagValueAsMap()); - tv.putAll(IsisFish.config.getDefaultSimulationConfig()); - param.setTagValue(tv); - - param.setExportNames(IsisFish.config.getDefaultExportNamesAsList()); - List<String> defaultResultNames = IsisFish.config - .getDefaultResultNamesAsList(); - if (defaultResultNames != null) { - param.setResultEnabled(defaultResultNames); - } else { - param.setResultEnabled(resultNames); - } - } catch (Exception eee) { - if (log.isErrorEnabled()) { - log.error("Can't init SimulationParameter", eee); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.initsimulaction"), eee); - } - } - - protected void setName(String name) { - simulName = name; - } - - /** - * Load simulation parameter file. - * - * @param f - * - * TODO public just for sensitivity - */ - public void importSimulation(File f) { - FileInputStream fos = null; - try { - fos = new FileInputStream(f); - Properties proper = new Properties(); - proper.load(fos); - param.fromProperties(proper); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't import simulation", e); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.importparameter"), e); - } finally { - IOUtils.closeQuietly(fos); - } - } - - /** - * Save current simulation to given file. - * - * @param f file to save simulation to - * - * TODO public just for sensitivity - */ - public void saveSimulation(File f) { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(f); - param.toProperties().store(fos, simulName); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't save simulation", e); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.savesimulation"), e); - } finally { - IOUtils.closeQuietly(fos); - } - } - - /** - * Looking for ResultName.java script and read all fields and fill - * list of field value and doc - * @return the list of result names found in ResultName script - */ - protected List<String> getResultNames() { - List<String> result = new ArrayList<String>(); - try { - ScriptStorage storage = ScriptStorage.getScript("ResultName.java"); - Class<?> resultNameClass = storage.getCodeClass(); - // TODO: if we can't find class, perhaps try to parser Java source ? - Field[] fields = resultNameClass.getFields(); - for (Field f : fields) { - String fieldName = (String) f.get(null); - result.add(fieldName); - } - } catch (Exception eee) { - if (log.isWarnEnabled()) { - log.warn("Can't find result name script", eee); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.getresultname"), eee); - } - return result; - } - - /** - * Change region in simulation launcher - * - * @param paramsUI paramsUI - * @param regionName region name - */ - public void regionChange(ParamsUI paramsUI, String regionName) { - regionStorage = RegionStorage.getRegion(regionName); - paramsUI.getParentContainer(SimulationUI.class).setContextValue(regionStorage); - paramsUI.getParentContainer(SimulationUI.class).setRegionStorage(regionStorage); - param.setRegionName(regionName); - } - - /** - * Load old simulation. - * - * Reset some field to empty default values: - * <ul> - * <li>params</li> - * <li>simulation plans</li> - * <li>factors list</li> - * </ul> - * - * Open old simulation: - * <ul> - * <li>params copy</li> - * <li>factors</li> - * </ul> - * - * @param simulName name of simulation to load - */ - public void loadOldSimulation(String simulName) { - if (log.isDebugEnabled()) { - log.debug("call loadOldSimulation: " + simulName); - } - try { - this.simulName = simulName; - simulStorage = SimulationStorage.getSimulation(simulName); - param = simulStorage.getParameter().copy(); - // all time reset number after load - param.setSimulationPlanNumber(-1); - regionStorage = param.getRegion(); - - // Chargement des facteurs - // clear list even if mexico file doesn't exists - factorGroup.clearFactors(); - File f = SimulationStorage.getMexicoDesignPlan(SimulationStorage.getSimulationDirectory(simulName)); - if (f != null && f.canRead()) { - if (log.isInfoEnabled()) { - log.info("Import design plan from : " + f.getAbsolutePath()); - } - TopiaContext topiaContext = regionStorage.getStorage(); - DesignPlan designPlan = MexicoHelper.getDesignPlanFromXML(f, topiaContext); - for (Factor factor : designPlan.getFactors()) { - if (log.isDebugEnabled()) { - log.debug("Find factor : " + factor.getName()); - } - //factors.put(factor.getPath() + factor.getName(), factor); - factorGroup = designPlan.getFactorGroup(); - } - } - else if (log.isInfoEnabled()) { - log.info("No xml design plan file found"); - } - } catch (Exception eee) { - throw new IsisFishRuntimeException(t("isisfish.error.simulation.loadoldsimulation"), eee); - } - } - - /** - * Called by RuleChooser component before rule deletion. - * Used to remove factor associated to rule to delete. - * - * Factor path reference rule with factor path containing rule index - * in rule list : - * for example : - * <pre> - * parameters.rule.2.parameter.tacPoids - * </pre> - * - * Must also rename all next indices. - * - * @param ruleIndex rule index to to delete - */ - public void preRemoveRule(int ruleIndex) { - preRemoveRule(factorGroup, ruleIndex); - } - - /** - * Recursive rename and delete rule factor path. - * - * @param factorGroup factorGroup - * @param ruleIndex rule index to to delete - */ - protected void preRemoveRule(FactorGroup factorGroup, int ruleIndex) { - Collection<Factor> factorCopy = new ArrayList<Factor>(factorGroup.getFactors()); - for (Factor factor : factorCopy) { - if (factor instanceof FactorGroup) { - preRemoveRule((FactorGroup)factor, ruleIndex); - } - else { - Pattern factorPathPattern = Pattern.compile( - "^(" +PARAMETERS_KEY + "\\" + DOT + RULE_KEY + "\\" + DOT + ")(\\d+)(.*)$"); - Matcher factorPathMatcher = factorPathPattern.matcher(factor.getPath()); - if (factorPathMatcher.find()) { - Integer index = Integer.parseInt(factorPathMatcher.group(2)); - if (index == ruleIndex) { - // meme index, suppression - if (log.isDebugEnabled()) { - log.debug("Removing factor for index " + ruleIndex + " : " + factor.getPath()); - } - factorGroup.remove(factor); - } - else if (index > ruleIndex) { - // index supérieur, renommage - // avec un index de moins - String factorPath = factorPathMatcher.group(1) + - String.valueOf(index - 1) + factorPathMatcher.group(3); - if (log.isDebugEnabled()) { - log.debug("Renammed factor for index " + ruleIndex + " : " + factor.getPath()); - } - factor.setPath(factorPath); - } - } - } - } - } - /** - * Get strategies list to fill Jlist in ParamUI. - * - * @return strategies list - */ - public List<Strategy> getStrategies() { - List<Strategy> result = new ArrayList<Strategy>(); - try { - TopiaContext tx = param.getRegion().getStorage().beginTransaction(); - result = RegionStorage.getFisheryRegion(tx).getStrategy(); - tx.rollbackTransaction(); - tx.closeContext(); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't get strategies", e); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.liststrategies"), e); - } - return result; - } - - /** - * Set parameters strategies. - * - * @param strategies - */ - public void setStrategies(List<Strategy> strategies) { - List<Strategy> result = new ArrayList<Strategy>(strategies); - param.setStrategies(result); - } - - /** - * Get population list to fill JList in paramUI. - * - * @return populations list - */ - public List<Population> getPopulations() { - - List<Population> result = new ArrayList<Population>(); - try { - TopiaContext tx = param.getRegion().getStorage().beginTransaction(); - List<Species> species = RegionStorage.getFisheryRegion(tx) - .getSpecies(); - for (Species s : species) { - Collection<Population> populations = s.getPopulation(); - - // FIXME initialiaze lazy hibernate collection - for (Population p : populations) { - p.getPopulationGroup().size(); - p.getPopulationZone().size(); - } - - result.addAll(populations); - } - tx.rollbackTransaction(); - tx.closeContext(); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't get population", e); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.listpopulation"), e); - } - return result; - } - - /** - * Set parameter population. - * - * @param populations populations to set - */ - public void setPopulations(List<Population> populations) { - List<Population> result = new ArrayList<Population>(populations); - param.setPopulations(result); - } - -// // Years -// public int getNumberOfYear() { -// return param.getNumberOfYear(); -// } -// -// /** -// * Change number of simulation year by parsing string value. -// * Default to 1 if value is not parsable. -// * -// * @param years number of years to set -// */ -// public void setNumberOfYear(String years) { -// try { -// param.setNumberOfYear(Integer.parseInt(years)); -// } -// catch (NumberFormatException ex) { -// // defaut to one year -// param.setNumberOfYear(1); -// } -// } - - public int getNumberOfMonths() { - return param.getNumberOfMonths(); - } - - /** - * Change number of simulation month by parsing string value. - * Default to 1 if value is not parsable. - * - * @param months number of months to set - */ - public void setNumberOfMonths(String months) { - try { - param.setNumberOfMonths(Integer.parseInt(months)); - } - catch (NumberFormatException ex) { - // defaut to one year - param.setNumberOfMonths(1); - } - } - - public List<String> getSimulatorNames() { - return SimulatorStorage.getSimulatorNames(); - } - - /* - ************ - * AdvancedParameterUI - ************ - */ - - // Gestion des TagValues - public void addTagValue(String tag, String value) { - param.getTagValue().put(tag, value); - } - - public void removeTagValue(String tag) { - if (log.isDebugEnabled()) { - log.debug("removeTagValue: " + tag); - } - param.getTagValue().remove(tag); - } - - public void saveTagValue(String simulatorName) { - Map<String, String> tagValues = param.getTagValue(); - if (log.isDebugEnabled()) { - log.debug("call saveTagValue: " + tagValues); - } - IsisFish.config.setDefaultTagValues(tagValues); - - IsisFish.config.setSimulatorClassfile(simulatorName); - } - - /* - * ExportUI - */ - - public List<String> getExportNames() { - List<String> exportNames = ExportStorage.getExportNames(); - List<String> result = new ArrayList<String>(exportNames); - return result; - } - - /** - * Save current parameters exports names in configuration. - */ - public void saveExport() { - - if (param.getExportNames() != null) { - - if (log.isDebugEnabled()) { - log.debug("Set exports in configuration : " + param.getExportNames()); - } - - IsisFish.config.setDefaultExportNames(param.getExportNames()); - } - } - - /* - * ResultUI - */ - - public void saveParametersResultNames(List<String> resultNames) { - List<String> resultNamesString = new ArrayList<>(resultNames); - param.setResultEnabled(resultNamesString); - - if (log.isDebugEnabled()) { - log.debug("Set simulation result names : " + resultNamesString); - } - } - - public void saveConfigurationResultNames(List<String> resultNames) { - List<String> resultNamesString = new ArrayList<>(resultNames); - IsisFish.config.setDefaultResultNames(resultNamesString); - - if (log.isDebugEnabled()) { - log.debug("Set configuration result names : " + resultNamesString); - } - } - - public List<String> getDefaultResultNames() { - return IsisFish.config.getDefaultResultNamesAsList(); - } - - /** - * Return simulation plan names list. - * - * @return simulation plan names - */ - public List<String> getSimulationPlanNames() { - return SimulationPlanStorage.getSimulationPlanNames(); - } - - public List<SimulationPlan> getParamSimulationPlans() { - return param.getSimulationPlans(); - } - - public void addSimulationPlan(PlanUI planUI, String name) { - try { - SimulationPlan sp = SimulationPlanStorage.getSimulationPlan(name).getNewInstance(); - - // add it after autoconfiguration (if enabled) - sp = (SimulationPlan)ScriptParameterDialog.displayConfigurationFrame(planUI, sp); - if (sp != null) { - getSimulationParameter().addSimulationPlan(sp); - } - } catch (IsisFishException ex) { - throw new IsisFishRuntimeException("Can't add simulation plan", ex); - } - } - - public void removeSimulationPlan(SimulationPlan sp) { - getSimulationParameter().removeSimulationPlan(sp); - } - - public void clearSimulationPlans() { - getSimulationParameter().clearPlans(); - } - - public Map<String, Class<?>> getSimulationPlanParameterName(SimulationPlan sp) { - Map<String, Class<?>> result = null; - if (sp != null) { - result = SimulationPlanStorage.getParameterNames(sp); - } - return result; - } - - public Object getSimulationPlanParameterValue(String paramName, SimulationPlan sp) { - Object result = null; - if (sp != null) { - try { - result = SimulationPlanStorage.getParameterValue(sp, paramName); - } catch (IsisFishException ex) { - throw new IsisFishRuntimeException("Can't get simulation plan param value", ex); - } - } - return result; - } - - public void setSimulationPlanParameterValue(String paramName, SimulationPlan sp, - Object value) { - if (log.isDebugEnabled()) { - log.debug("paramName : " + paramName + " simulationPlanName : " + sp - + " value : " + value); - } - try { - SimulationPlanStorage.setParameterValue(sp, paramName, value); - } catch (IsisFishException ex) { - throw new IsisFishRuntimeException("Can't set simulation plan param value", ex); - } - } - - /* - * Sensitivity - */ - public List<String> getSensitivityExportNames() { - List<String> result = new ArrayList<String>(); - List<String> exportNames = SensitivityExportStorage.getSensitivityExportNames(); - for (String export : exportNames) { - result.add(export); - } - return result; - } - - public List<SensitivityExport> getSensitivityExports() { - List<SensitivityExport> result = param.getSensitivityExport(); - return result; - } - - public void addSensitivityExport(SensitivityChooserUI sensitivityChooserUI, String name) { - try { - SensitivityExportStorage storage = SensitivityExportStorage.getSensitivityExport(name); - SensitivityExport sensitivityExport = storage.getNewInstance(); - - // add it after autoconfiguration (if enabled) - sensitivityExport = (SensitivityExport)ScriptParameterDialog.displayConfigurationFrame(sensitivityChooserUI, sensitivityExport); - if (sensitivityExport != null) { - param.getSensitivityExport().add(sensitivityExport); - } - } catch (IsisFishException e) { - if (log.isErrorEnabled()) { - log.error("Can't add sensitivity export", e); - } - } - } - - /** - * Remove an export. - * - * @param export export to remove - */ - public void removeSensitivityExport(SensitivityExport export) { - param.getSensitivityExport().remove(export); - } - - public void clearSensitivityExport() { - param.getSensitivityExport().clear(); - } - - public Map<String, Class<?>> getSensitivityExportParameterNames( - SensitivityExport export) { - return SensitivityExportStorage.getParameterNames(export); - } - - public void setSensitivityExportParameterValue(ExportInfo export, - String paramName, Object value) { - if (value != null) { - try { - SensitivityExportStorage.setParameterValue(export, paramName, value); - } catch (IsisFishException e) { - if (log.isErrorEnabled()) { - log.error("Can't set sensitivity export param value", e); - } - } - } - } - - public Object getSensitivityExportParameterValue(SensitivityExport sensitivityExport, String paramName) { - Object result = null; - try { - result = SensitivityExportStorage.getParameterValue(sensitivityExport, paramName); - } catch (IsisFishException e) { - if (log.isErrorEnabled()) { - log.error("Can't get sensitivity export param value", e); - } - } - return result; - } - - /** - * Return sensitivity analysis name without .java extension. - * - * @return sensitivity analysis names list - */ - public List<String> getSensitivityAnalysisNames() { - List<String> result = new ArrayList<String>(); - for (String r : SensitivityAnalysisStorage.getSensitivityAnalysisNames()) { - // there is some non java files in sensitivity directory - if (r.endsWith(".java")) { - // Remove .java extention - // for example SensitivityStorage.getRuleName(String) - result.add(r.substring(0, r.length() - 5)); - } - } - return result; - } - - /** - * Get current sensitivity calculator instance. - * @return sensitivity calculator - */ - public SensitivityAnalysis getSensitivityAnalysis() { - return param.getSensitivityAnalysis(); - } - - /** - * Build a new sensitivity calculator instance by his name. - * - * @param name calculator name - * @return instance - */ - public SensitivityAnalysis getSensitivityAnalysisInstance(String name) { - SensitivityAnalysis sensitivityAnalysis = null; - try { - SensitivityAnalysisStorage sensitivityStorage = SensitivityAnalysisStorage.getSensitivityAnalysis(name); - sensitivityAnalysis = sensitivityStorage.getNewInstance(); - } catch (IsisFishException e) { - if (log.isErrorEnabled()) { - log.error("Can't set sensitivity analysis", e); - } - } - return sensitivityAnalysis; - } - - /** - * Set calculator instance to use. - * - * @param sensitivityAnalysis new instance - */ - public void setSensitivityAnalysis(SensitivityAnalysis sensitivityAnalysis) { - param.setSensitivityAnalysis(sensitivityAnalysis); - } - - /** - * Get current simulation factor list. - * - * @return factor list - */ - public FactorGroup getFactorGroup() { - return factorGroup; - } - - /** - * Search factor in factor group tree by path. - * - * @param factorPath factor path to search - * @return found factor - */ - public Factor getFactor(String factorPath) { - return getFactor(factorGroup, factorPath); - } - - /** - * Recursive search for factor in factor group by path. - * - * @param factorGroup factor group to search to - * @param factorPath factor path to search - * @return found factor - */ - protected Factor getFactor(FactorGroup factorGroup, String factorPath) { - Factor result = null; - for (Factor factor : factorGroup.getFactors()) { - if (factor instanceof FactorGroup) { - result = getFactor((FactorGroup)factor, factorPath); - } - if (factorPath.equals(factor.getPath())) { - result = factor; - } - } - return result; - } - - /** - * Remove factor in factor group tree by path. - * - * @param factorPath factor path to remove - */ - public void removeFactor(String factorPath) { - removeFactor(factorGroup, factorPath); - } - - /** - * Recursive remove for factor in factor group by path. - * - * @param factorGroup factor group to search to - * @param factorPath factor path to remove - */ - protected void removeFactor(FactorGroup factorGroup, String factorPath) { - Collection<Factor> factorCopy = new ArrayList<Factor>(factorGroup.getFactors()); - for (Factor factor : factorCopy) { - if (factor instanceof FactorGroup) { - removeFactor((FactorGroup)factor, factorPath); - } - if (factorPath.equals(factor.getPath())) { - factorGroup.remove(factor); - } - } - } - - public void addFactor(Factor f) { - if (log.isDebugEnabled()) { - log.debug("Add factor (" + f.getName() + ") : " +f.getPath()); - } - factorGroup.addFactor(f); - } - - /** - * Ajout d'un facteur continue de type (min/max). - * - * @param name - * @param comment - * @param path - * @param domain - * @param exist - */ - public void addContinuousFactor(String name, String comment, String path, - ContinuousDomain domain, boolean exist) { - Factor f = new Factor(name); - f.setDomain(domain); - f.setComment(comment); - f.setPath(path); - if (exist) { - removeFactor(path); - } - addFactor(f); - } - - public void addDiscreteFactor(String name, String comment, String path, - List<Object> values, boolean exist) { - addDiscreteFactor(new DiscreteDomain(), name, comment, path, values, exist); - } - - public void addDiscreteRuleFactor(String name, String comment, String path, - List<Object> values, boolean exist) { - addDiscreteFactor(new RuleDiscreteDomain(), name, comment, path, values, exist); - } - - public void addDiscreteEquationFactor(String name, String comment, String path, - List<Object> values, boolean exist) { - addDiscreteFactor(new EquationDiscreteDomain(), name, comment, path, values, exist); - } - - protected void addDiscreteFactor(DiscreteDomain domain, String name, String comment, String path, - List<Object> values, boolean exist) { - Factor f = new Factor(name); - SortedMap<Object, Object> domainValues = new TreeMap<Object, Object>(); - int label = 0; - for (Object value : values) { - // FIXME test when integer - // Don't work with String ;( - domainValues.put(label, value); - // and start at 0 - label++; - } - domain.setValues(domainValues); - f.setDomain(domain); - f.setComment(comment); - f.setPath(path); - if (exist) { - removeFactor(path); - } - addFactor(f); - } - - public void addContinuousEquationFactor(Factor f, boolean exist) { - // factor name need to be composed - //Factor f = new Factor(name + "." + domain.getVariableName()); - //f.setDomain(domain); - //f.setComment(comment); - //f.setPath(path); - if (exist) { - removeFactor(f.getPath()); - } - addFactor(f); - } - - /* - ************ - * General - ************ - */ - - public SimulationParameter getSimulationParameter() { - return param; - } - - public void setSimulationParameter(SimulationParameter p) { - param = p; - } - - public SimulationStorage getSimulationStorage() { - return simulStorage; - } - - public RegionStorage getRegionStorage() { - return regionStorage; - } - - public List<SimulatorLauncher> getSimulationLauncher() { - return SimulationService.getService().getSimulationLaunchers(); - } - - protected boolean checkAndPrepare(String fullSimulationId) { - boolean result = !("".equals(fullSimulationId) - || SimulationStorage.localyExists(fullSimulationId) - || SimulationService.getService().exists(fullSimulationId)); - - if (result) { - // force all necessary config simulation in tag value - Map<String, String> m = new HashMap<String, String>( - IsisFish.config.getDefaultSimulationConfig()); - Map<String, String> tv = param.getTagValue(); - m.putAll(tv); - param.setTagValue(m); - } else { - ErrorHelper.showErrorDialog(t("isisfish.simulator.simulaction.badid", - fullSimulationId), null); - } - - return result; - } - - /** - * Launch automatically the simulation, when is possible (no other simulation) - * or wait for the last automatically simulation ended. - * - * @param simulationId id of the simulation to simulate - * @param launcher launcher to use - * - * @see SimulatorLauncher - */ - public void launchSimulation(String simulationId, SimulatorLauncher launcher) { - - String fullSimulationId = "sim_" + simulationId + "_" - + DATEFORMAT.format(new java.util.Date()); - - // log - if (log.isDebugEnabled()) { - log.debug("Launch simulation with custom launcher " - + launcher.toString()); - } - - try { - if (checkAndPrepare(fullSimulationId)) { - SimulationService.getService().submit(fullSimulationId, param, - launcher, 0); - } - } catch (Exception eee) { - if (log.isErrorEnabled()) { - log.error("Can't start simulation", eee); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.launchsimulation"), eee); - } - } - - /** - * Launch simulation with factors variations parameters. - * - * @param simulationId id of the simulation to simulate - * @param launcher launcher to use - * @param sensitivityAnalysis sensitivity analysis to use - * - * @see SimulatorLauncher - * @see SensitivityAnalysis - * @see DesignPlan - */ - public void launchSimulation(String simulationId, - SimulatorLauncher launcher, SensitivityAnalysis sensitivityAnalysis) { - - String fullSimulationId = "as_" + simulationId + "_" - + DATEFORMAT.format(new java.util.Date()); - - // log - if (log.isDebugEnabled()) { - log.debug("Launch factor simulation with custom launcher " - + launcher.toString()); - log.debug("Using sensitivityCalculator : " - + sensitivityAnalysis.getDescription()); - } - - try { - if (checkAndPrepare(fullSimulationId)) { - DesignPlan designPlan = new DesignPlan(); - designPlan.setFactorGroup(factorGroup); - SimulationService.getService().submit(fullSimulationId, param, - launcher, 0, sensitivityAnalysis, designPlan); - } - } catch (Exception eee) { - if (log.isErrorEnabled()) { - log.error("Can't start simulation", eee); - } - ErrorHelper.showErrorDialog(t("isisfish.error.simulation.launchsimulation"), eee); - } - } - - public void launchSimulationWithSensibility(String simulationId, - SimulatorLauncher launcher) { - launchSimulation(simulationId, launcher, getSensitivityAnalysis()); - } - - /** - * Lance la second passe d'une analyse de sensibilité. - * - * @param masterSensitivitySimulationName nom du prefix de toutes les simulations (without _) - */ - public void runSensitivitySecondPass(String masterSensitivitySimulationName) { - - // sensitivity analysis found - SensitivityAnalysis sensitivityAnalysis = null; - //List<SimulationStorage> simulationStorageForAnalyze = new ArrayList<SimulationStorage>(); - SortedMap<Integer, SimulationStorage> simulationStorageForAnalyze = new TreeMap<Integer, SimulationStorage>(); - File simuationDirectory = SimulationStorage.getSimulationDirectory(); - for (File simuation : simuationDirectory.listFiles()) { - if (simuation.isDirectory() - && simuation.getName().startsWith( - masterSensitivitySimulationName + "_")) { - SimulationStorage storage = SimulationStorage - .getSimulation(simuation.getName()); - String suffix = simuation.getName().substring( - simuation.getName().lastIndexOf("_") + 1); - simulationStorageForAnalyze.put(Integer.valueOf(suffix), - storage); - - if (sensitivityAnalysis == null) { - // try to find find calculator name in one storage - SimulationParameter params = storage.getParameter(); - sensitivityAnalysis = params.getSensitivityAnalysis(); - } - } - } - - if (sensitivityAnalysis != null) { - try { - // build master sensitivity export directory - File masterExportDirectory = new File(SimulationStorage.getSensitivityResultsDirectory(), - masterSensitivitySimulationName); - if (!masterExportDirectory.isDirectory()) { - masterExportDirectory.mkdirs(); - } - List<SimulationStorage> simulationStorageForAnalyzeList = new ArrayList<SimulationStorage>( - simulationStorageForAnalyze.values()); - sensitivityAnalysis.analyzeResult( - simulationStorageForAnalyzeList, masterExportDirectory); - } catch (SensitivityException e) { - if (log.isErrorEnabled()) { - log.error("Can't call analyse result", e); - } - } - } else { - if (log.isWarnEnabled()) { - log.warn("Can't run sensitivity second pass"); - } - } - } - - /** - * Renvoie les resultats de la seconde pass. - * - * @param masterSensitivitySimulationName nom du prefix de toutes les simulations (without _) - * - * @return les fichiers genere lors de la seconde passe (seulement ceux qui ne commence pas par ".") - */ - public List<File> getSensitivitySecondPassResults( - String masterSensitivitySimulationName) { - - List<File> result = new ArrayList<File>(); - - // build master sensitivity export directory - File masterExportDirectory = new File(SimulationStorage.getSensitivityResultsDirectory(), masterSensitivitySimulationName); - if (masterExportDirectory.isDirectory()) { - for (File exportFile : masterExportDirectory.listFiles()) { - if (exportFile.isFile() - && !exportFile.getName().startsWith(".")) { - result.add(exportFile); - } - } - } - - return result; - } - - /** - * Population selection changed. - * - * Fill matrix panel with population effective of selected population. - * - * @param paramsUI paramsUI - */ - public void populationSelected(final ParamsUI paramsUI) { - CardLayout layout = (CardLayout)paramsUI.getPopulationEffectivesPanel().getLayout(); - - List<Population> selectedPopulationsValues = paramsUI.getListSimulParamsPopulations().getSelectedValuesList(); - if (CollectionUtils.isNotEmpty(selectedPopulationsValues)) { - paramsUI.getPopulationEffectivesTabbedPane().removeAll(); - setPopulations(selectedPopulationsValues); - - for (Population selectedPopulation : selectedPopulationsValues) { - final MatrixPanelEditor matrixPanel = new MatrixPanelEditor(); - MatrixND populationEffectives = getSimulationParameter().getNumberOf(selectedPopulation); - matrixPanel.setMatrix(populationEffectives); - - JPanel matrixPanelComponent = new JPanel(new BorderLayout()); - matrixPanelComponent.add(matrixPanel, BorderLayout.CENTER); - - // add addFactorButton with matrixPanel (just in sensitivity cas) - if (paramsUI.isSensitivity()) { - matrixPanel.putClientProperty("sensitivityPopulation", selectedPopulation); - // TODO add another thing that action - JButton addFactorButton = new JButton(); - addFactorButton.setAction(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - addFactorWithComponent(paramsUI, matrixPanel); - } - @Override - public Object getValue(String key) { - Object result = null; - if (key.equals(Action.SMALL_ICON)) { - result = SwingUtil.createImageIcon("building_add.png"); - } - return result; - } - }); - matrixPanelComponent.add(addFactorButton, BorderLayout.EAST); - } - - paramsUI.getPopulationEffectivesTabbedPane().add(matrixPanelComponent, - t("isisfish.params.populationEffectives", selectedPopulation.getName())); - } - - layout.show(paramsUI.getPopulationEffectivesPanel(), "specific"); - } - else { - layout.show(paramsUI.getPopulationEffectivesPanel(), "default"); - } - } - - /** - * Action appelée lors du clic sur les boutons a coté des composants factorisables. - * - * Contrairement à l'interface 'input', on edite ici des facteurs existants, - * (créé à la première demande). - * - * @param paramsUI paramsUI - * @param source la source de l'event - */ - public void addFactorWithComponent(ParamsUI paramsUI, JComponent source) { - - if (log.isDebugEnabled()) { - log.debug("Event intercepted on " + source); - } - - Factor selectedFactor = null; - - // new factor with rule domain - if (source instanceof RuleChooser) { - String factorPath = PARAMETERS_KEY + DOT + RULES_KEY; - selectedFactor = getFactor(factorPath); - if (selectedFactor == null) { - selectedFactor = new Factor(t("isisfish.sensitivity.rulesfactorname")); - selectedFactor.setPath(factorPath); - //selectedFactor.setDomain(new RuleDiscreteDomain()); - } - } - - // new factor with matrix continous domain - else if (source instanceof MatrixPanelEditor) { - Population population = (Population)source.getClientProperty("sensitivityPopulation"); - String factorPath = PARAMETERS_KEY + DOT + POPULATION_KEY + DOT + population.getName() + DOT + NUMBER_KEY; - selectedFactor = getFactor(factorPath); - if (selectedFactor == null) { - selectedFactor = new Factor(t("isisfish.sensitivity.populationfactorname", population.getName())); - selectedFactor.setPath(factorPath); - //MatrixND populationEffectives = getSimulationParameter().getNumberOf(population); - /*MatrixContinuousDomain factorDomain = new MatrixContinuousDomain(); - factorDomain.setReferenceValue(populationEffectives.copy()); - factorDomain.setCoefficient(0.0); - ContinuousDomain domain = new ContinuousDomain(Distribution.QUNIFPC); - domain.addDistributionParam(Distribution.QUNIFPC.getDistibutionParams()[0].getName(), populationEffectives.copy()); - domain.addDistributionParam(Distribution.QUNIFPC.getDistibutionParams()[1].getName(), 0.0d); - selectedFactor.setDomain(domain);*/ - } - } - - if (selectedFactor != null) { - FactorWizardUI wizard = new FactorWizardUI(paramsUI); - FactorWizardHandler handler = wizard.getHandler(); - handler.initExistingFactor(wizard, selectedFactor); - wizard.pack(); - wizard.setLocationRelativeTo(paramsUI); - wizard.setVisible(true); - } - } - - /** - * Ajout d'un nouveau facteur sur un parametres de règles. - * - * Le facteur est directement crée avec un nom et un path correct. - * - * @param ruleChooser rule chooser - * @param rule rule - * @param paramName rule parameter name - */ - public void addRuleParameterFactor(RuleChooser ruleChooser, Rule rule, String paramName) { - - // get index of rule in rule list - // warning, factor path must always be cohérent - // with rule list, if a rule is deleted, factor on it must - // be deleted too, et next factor must be renamed - int index = ruleChooser.getRulesList().indexOf(rule); - String factorPath = PARAMETERS_KEY + DOT + RULE_KEY + DOT + index + DOT - + PARAMETER_KEY + DOT + paramName; - //try { - - /*// on a besoin de la valeur pour savoir s'il peut être continue - Object paramValue = RuleStorage.getParameterValue(rule, paramName); - - if (!SensitivityUtils.canBeContinue(paramValue)) { - // dans le cas ou il ne peut pas être continue, on le gere - // differement et on utilise sont type comme - // valeur - Class paramType = RuleStorage.getParameterType(rule, paramName); - factorPath += "." + paramType.getName(); - paramValue = paramType; - } - - // init new factor wizard ui - FactorWizardUI factorWizardUI = new FactorWizardUI(ruleChooser); - factorWizardUI.getFactorNameField().setText(t("isisfish.sensitivity.ruleparameterfactorname", - rule.getClass().getSimpleName(), paramName)); - factorWizardUI.setFactorPath(factorPath); - SensitivityWizardHandler handler = factorWizardUI.getHandler(); - handler.initNewFactorWithValue(factorWizardUI, paramValue); - factorWizardUI.pack(); - factorWizardUI.setLocationRelativeTo(ruleChooser); - factorWizardUI.setVisible(true);*/ - - Factor factor = new Factor(t("isisfish.sensitivity.ruleparameterfactorname", - rule.getClass().getSimpleName(), paramName)); - factor.setPath(factorPath); - FactorWizardUI factorWizardUI = new FactorWizardUI(ruleChooser); - FactorWizardHandler handler = factorWizardUI.getHandler(); - handler.initExistingFactor(factorWizardUI, factor); - factorWizardUI.pack(); - factorWizardUI.setLocationRelativeTo(ruleChooser); - factorWizardUI.setVisible(true); - - /*} catch (IsisFishException ex) { - throw new IsisFishRuntimeException("Can't add factor on rule", ex); - }*/ - } -} Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorContext.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -22,20 +22,135 @@ */ package fr.ifremer.isisfish.ui.simulator; +import static org.nuiton.i18n.I18n.t; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.RegionStorage; +import fr.ifremer.isisfish.datastore.ScriptStorage; +import fr.ifremer.isisfish.simulator.SimulationParameter; +import fr.ifremer.isisfish.simulator.SimulationParameterImpl; +import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup; +import fr.ifremer.isisfish.ui.util.ErrorHelper; import jaxx.runtime.JAXXContext; import jaxx.runtime.context.JAXXInitialContext; /** * Ce contexte regroupe les élements qui servent à une hierachie d'interfaces Simulator. * + * Ce context contient: + * <ul> + * <li>SimulationParameter.class : les parametres des la simulation</li> + * <li>FactorGroup.class : le facteur group racine</li> + * <li>RegionStorage.class : la region sélectionner pour ajouter des facteurs</li> + * <li>SimulatorContext.class : l'instance de ce context</li> + * </ul> + * * @author Eric Chatellier */ public class SimulatorContext extends JAXXInitialContext { + private static final Log log = LogFactory.getLog(SimulatorContext.class); + public SimulatorContext(JAXXContext parent) { setParentContext(parent); - // FIXME remove this - add(new SimulAction()); + initDefaultParameters(); + initFactorGroup(); + // concurrentmodification : setSimulatorContext(this); } + + public void setSimulationParameter(SimulationParameter param) { + add(param); + } + + public void setFactorGroup(FactorGroup factorGroup) { + add(factorGroup); + } + + public void setRegionStorage(RegionStorage regionStorage) { + add(regionStorage); + } + + public void setSimulatorContext(SimulatorContext simulatorContext) { + add(simulatorContext); + } + + /** + * Build simulation parameters + */ + protected void initDefaultParameters() { + + SimulationParameter param = new SimulationParameterImpl(); + + // init with default values from configuration + param.setSimulatorName(IsisFish.config.getSimulatorClassfile()); + + // export names + param.setExportNames(IsisFish.config.getDefaultExportNamesAsList()); + + // result names + List<String> defaultResultNames = IsisFish.config.getDefaultResultNamesAsList(); + if (defaultResultNames != null) { + param.setResultEnabled(defaultResultNames); + } else { + List<String> allResultNames = getResultNames(); + param.setResultEnabled(allResultNames); + } + + // tag values + Map<String, String> tv = new LinkedHashMap<String, String>(); + tv.putAll(IsisFish.config.getDefaultTagValueAsMap()); + tv.putAll(IsisFish.config.getDefaultSimulationConfig()); + param.setTagValue(tv); + + // set it in context to be used by all UIs + setSimulationParameter(param); + } + + /** + * Looking for ResultName.java script and read all fields and fill + * list of field value and doc + * @return the list of result names found in ResultName script + * + * @deprecated duplicated with another one + */ + @Deprecated + protected List<String> getResultNames() { + List<String> result = new ArrayList<String>(); + try { + ScriptStorage storage = ScriptStorage.getScript("ResultName.java"); + Class<?> resultNameClass = storage.getCodeClass(); + // TODO: if we can't find class, perhaps try to parser Java source ? + Field[] fields = resultNameClass.getFields(); + for (Field f : fields) { + String fieldName = (String) f.get(null); + result.add(fieldName); + } + } catch (Exception eee) { + if (log.isWarnEnabled()) { + log.warn("Can't find result name script", eee); + } + ErrorHelper.showErrorDialog(t("isisfish.error.simulation.getresultname"), eee); + } + return result; + } + + /** + * List de facteur sous forme d'arbre (factor group). + * {@code null} name for compatibility with 3.3.0.0. + */ + protected void initFactorGroup() { + + FactorGroup factorGroup = new FactorGroup(null); + add(factorGroup); + } } Modified: branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java 2015-06-04 14:02:08 UTC (rev 4244) +++ branches/isis-fish-4.4.0-ui-refactoring/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorTabHandler.java 2015-06-08 13:47:32 UTC (rev 4246) @@ -36,9 +36,4 @@ protected FactorGroup getFactorGroup() { return simulationUI.getContextValue(FactorGroup.class); } - - @Deprecated - protected SimulAction getSimulAction() { - return simulationUI.getContextValue(SimulAction.class); - } }