Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
October 2008
- 4 participants
- 243 discussions
Author: chatellier
Date: 2008-10-24 07:35:10 +0000 (Fri, 24 Oct 2008)
New Revision: 1572
Modified:
isis-fish/trunk/pom.xml
Log:
Remove cglib exclusion
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2008-10-24 07:32:18 UTC (rev 1571)
+++ isis-fish/trunk/pom.xml 2008-10-24 07:35:10 UTC (rev 1572)
@@ -53,13 +53,6 @@
<artifactId>topia</artifactId>
<version>${topia.version}</version>
<scope>compile</scope>
- <!-- use javassist instead of cglib -->
- <exclusions>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
1
0
Author: chatellier
Date: 2008-10-24 07:32:18 +0000 (Fri, 24 Oct 2008)
New Revision: 1571
Modified:
isis-fish/trunk/pom.xml
Log:
Update pom to release for some artifact
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2008-10-23 13:02:40 UTC (rev 1570)
+++ isis-fish/trunk/pom.xml 2008-10-24 07:32:18 UTC (rev 1571)
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
- <version>0.30</version>
+ <version>0.31</version>
<scope>compile</scope>
</dependency>
<!--
@@ -65,7 +65,7 @@
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>topia-service</artifactId>
- <version>0.9-SNAPSHOT</version>
+ <version>0.9</version>
<scope>compile</scope>
</dependency>
@@ -481,16 +481,16 @@
<current.version>3.2.0.0-SNAPSHOT</current.version>
<!-- jaxx version -->
- <jaxx.version>0.5-SNAPSHOT</jaxx.version>
+ <jaxx.version>0.5</jaxx.version>
<!-- generator version -->
<generator.version>0.60</generator.version>
<!-- topia version -->
- <topia.version>2.0.27-SNAPSHOT</topia.version>
+ <topia.version>2.0.27</topia.version>
<!-- lutinwidget version -->
- <lutinwidget.version>0.10-SNAPSHOT</lutinwidget.version>
+ <lutinwidget.version>0.10</lutinwidget.version>
<!--Main class in JAR -->
<maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class>
1
0
r1570 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: script simulator widget/editor
by sletellier@users.labs.libre-entreprise.org 23 Oct '08
by sletellier@users.labs.libre-entreprise.org 23 Oct '08
23 Oct '08
Author: sletellier
Date: 2008-10-23 13:02:40 +0000 (Thu, 23 Oct 2008)
New Revision: 1570
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/GenericCell.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java
Log:
ScriptUI completed
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2008-10-23 13:02:01 UTC (rev 1569)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2008-10-23 13:02:40 UTC (rev 1570)
@@ -9,16 +9,47 @@
*
* @author letellier
*/
+import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.JavaSourceStorage;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.ui.script.Action.ScriptMapping;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+import fr.ifremer.isisfish.ui.ScriptActionHelper;
+import fr.ifremer.isisfish.ui.script.Action.ScriptFileFilter;
+import fr.ifremer.isisfish.ui.widget.editor.GenericCell;
+import fr.ifremer.isisfish.vcs.VCSException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import static org.codelutin.i18n.I18nf._;
import java.io.File;
+import java.io.FileFilter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import javax.swing.JOptionPane;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import org.apache.commons.logging.Log;
+import org.codelutin.util.FileUtil;
+import static org.apache.commons.logging.LogFactory.getLog;
+import static fr.ifremer.isisfish.equation.Language.JAVA;
+
public class ScriptAction {
+ CodeSourceStorage code;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = getLog(ScriptAction.class);
+ File fileOpen= null;
public ScriptAction(){
}
@@ -34,8 +65,8 @@
public List<String> getScriptNames(){
return ScriptStorage.getScriptNames();
}
- public List<String> getSimulationNames(){
- return SimulationStorage.getSimulationNames();
+ public List<String> getSimulatorNames(){
+ return SimulatorStorage.getSimulatorNames();
}
public List<String> getExportNames(){
return ExportStorage.getExportNames();
@@ -55,8 +86,8 @@
public File getScriptDirectory(){
return ScriptStorage.getScriptDirectory();
}
- public File getSimulationDirectory(){
- return SimulationStorage.getSimulationDirectory();
+ public File getSimulatorDirectory(){
+ return SimulatorStorage.getSimulatorDirectory();
}
public File getExportDirectory(){
return ExportStorage.getExportDirectory();
@@ -70,4 +101,779 @@
public File getFormuleDirectory(){
return FormuleStorage.getFormuleDirectory();
}
+ /*
+ * JButton Action
+ */
+ /**
+ * Creer un nouveau script, ici un script peut-etre un Script, un Simulator,
+ * un Export.
+ *
+ * @param uiContext TODO
+ * @param frame TODO
+ * @param scriptType le type que l'on souhaite Script, Simulator,
+ * ou Export.
+ * @param jmodel TODO
+ * @param tree TODO
+ * @return TODO
+ */
+ public Object newScript(String fileName, String scriptType) {
+// log.info("newScript called [" + scriptType + "] " + uiContext);
+
+ Exception e;
+ try {
+ // Vérifie qu'il n'y pas de caractères spéciaux. Seul les caractre
+ // de a à z (majuscule ou minuscule) ainsi que les nombres sont
+ // autorisés. + pour signifier qu'il doit y avoir
+ // au moins 1 caractère.
+ String realFilename;
+ String category;
+ ScriptMapping mapping = ScriptMapping.valueOf(scriptType);
+ if (mapping == null) {
+ e = new RuntimeException("ScriptType unknown: " + scriptType);
+ return returnError(_("isisfish.error.script.create",fileName, e.getMessage()),e);
+ }
+
+ int pos = fileName.lastIndexOf('/');
+ if (pos != -1) {
+ if (mapping!= ScriptMapping.EquationModel) {
+ // interdit pour le moment ?
+ String message = _("isisfish.error.invalid.file.name", fileName);
+ e = new RuntimeException(message);
+ return returnError(_("isisfish.error.script.create",fileName, e.getMessage()),e);
+ }
+ // il y a un sous type à traiter
+ if (pos == fileName.length() - 1) {
+ String message = _("isisfish.error.invalid.file.name", fileName);
+ e = new RuntimeException(message);
+ return returnError(_("isisfish.error.script.create",fileName, e.getMessage()),e);
+ }
+ realFilename = fileName.substring(fileName.lastIndexOf('/') + 1);
+ category = fileName.substring(0, fileName.lastIndexOf('/'));
+ } else {
+ realFilename = fileName;
+ category = "";
+ }
+ if (!realFilename.matches("[A-Z0-9_][a-zA-Z0-9_]*")) {
+ String message = _("isisfish.error.invalid.file.name", fileName);
+ e = new RuntimeException(message);
+ return returnError(_("isisfish.error.script.create",fileName, e.getMessage()),e);
+ }
+ //TODO do test on category
+ CodeSourceStorage script = null;
+ String template;
+ template = mapping.getDefaultContent();
+ switch (mapping) {
+ case EquationModel:
+// if (!category.isEmpty()) {
+// // on utilise la category passée dans le nom
+// parentNode = (TreeNodeWrapper) jmodel.getNode(category);
+// if (parentNode == null) {
+// parentNode = (TreeNodeWrapper) jmodel.getNode(scriptType);
+// JTreeNode jparentNode = parentNode.getWrapped();
+// JTreeNode jnode = (JTreeNode) jparentNode.getComponent(0);
+// jnode.setName(category);
+// parentNode.addNode(jnode, category);
+// parentNode = (TreeNodeWrapper) jmodel.getNode(category);
+// UIHelper.setTreeSelection(tree, jmodel, category);
+// }
+// } else {
+// // on utilise la category dans la navigation
+// TreePath path = tree.getSelectionPath();
+// if (path.getPath().length < 2) {
+// // fatal error no category found, and was required
+// String message = _("isisfish.error.invalid.category.name", fileName);
+// e = new RuntimeException(message);
+// return returnError(_("isisfish.error.script.create", fileName, e.getMessage()), e);
+// }
+// TreeNodeWrapper categotyNode = (TreeNodeWrapper) path.getPathComponent(2);
+// parentNode = categotyNode;
+// category = String.valueOf(categotyNode.getUserObject());
+// }
+
+ script = FormuleStorage.createFormule(category, realFilename, JAVA);
+ break;
+ case AnalysePlan:
+ script = AnalysePlanStorage.getAnalysePlan(fileName);
+ break;
+ case Export:
+ script = ExportStorage.getExport(fileName);
+ break;
+ case Rule:
+ script = RuleStorage.getRule(fileName);
+ break;
+ case Script:
+ script = ScriptStorage.getScript(fileName);
+ break;
+ case Simulator:
+ script = SimulatorStorage.getSimulator(fileName);
+ break;
+ default:
+ log.fatal("ScriptType unknown: " + scriptType);
+ }
+
+ if (script.exists()) {
+ // Message d'erreur si le fichier existe en local.
+ String message = _("isisfish.error.file.already.exists", fileName);
+ e = new RuntimeException(message);
+ return returnError(_("isisfish.error.script.create",fileName, e.getMessage()),e);
+ }
+
+ // add default script content
+ String content = MessageFormat.format(template,
+ category.isEmpty() ? "" : '.' + category.replaceAll("\\/", "."),
+ realFilename,
+ new Date(),
+ IsisFish.config.getUserName(),
+ IsisFish.config.getUserMail());
+ script.setContent(content);
+ // ajout du nouveau script dans l'arbre
+// if (parentNode == null) {
+// parentNode = (TreeNodeWrapper) jmodel.getNode(scriptType);
+// }
+// if (parentNode != null) {
+// JTreeNode jparentNode = parentNode.getWrapped();
+// JTreeNode jnode = (JTreeNode) jparentNode.getComponent(0);
+// parentNode.addNode(jnode, script.getName());
+// }
+// // selection du nouveau noeud, ce qui appel la methode load
+// UIHelper.setTreeSelection(tree, jmodel, script.getName());
+
+// uiContext.setData(SCRIPT_STORAGE, script);
+ code = script;
+// uiContext.setData(SCRIPT_TYPE, scriptType);
+// frame.refreshView("scriptJedit");
+// frame.refreshView("buttonBar");
+// frame.refreshView("scriptMenuBar");
+ } catch (Exception eee) {
+ return returnError(_("isisfish.error.script.create",fileName, eee.getMessage()),eee);
+ }
+ return null;
+
+ }
+ public static Object returnError(String s, Exception eee) {
+ log.error(s,eee);
+// return new OutputView("Error.xml", "error", s);
+ return null;
+ }
+ public void loadScript(GenericCell c, String fileName, String type){
+ ScriptMapping mapping = ScriptMapping.valueOf(type);
+ CodeSourceStorage script = null;
+
+ try {
+
+ switch (mapping) {
+ case EquationModel:
+ script = FormuleStorage.getFormule((String)c.getValue(), fileName);
+ break;
+ case Rule:
+ script = RuleStorage.getRule(fileName);
+ break;
+ case AnalysePlan:
+ script = AnalysePlanStorage.getAnalysePlan(fileName);
+ break;
+ case Export:
+ script = ExportStorage.getExport(fileName);
+ break;
+ case Script:
+ script = ScriptStorage.getScript(fileName);
+ break;
+ case Simulator:
+ script = SimulatorStorage.getSimulator(fileName);
+ break;
+ default:
+ log.fatal("ScriptType unknown: " + fileName);
+ }
+
+ //frame.setInfoText(_("isisfish.message.load.finished"));
+ } finally {
+ code = script;
+ }
+ }
+ public boolean fileLoaded(){
+ return code != null;
+ }
+ public boolean isJavaScript(){
+ return JavaSourceStorage.class.isInstance(code);
+ }
+ public Object saveScript(String content) {
+ log.info("saveScript called [" + code.getName() + "] ");
+ try {
+ code.setContent(content);
+ } catch (Exception eee) {
+ return returnError(_("isisfish.error.script.save", code.getFile(), eee.getMessage()),eee);
+ }
+ return null;
+ }
+ public String commitScript(String content) {
+ String result = null;
+ try {
+ log.debug("commitScript called for ");
+ // save script before commit
+ code.setContent(content);
+ String msg = JOptionPane.showInputDialog(_("Indiquez vos modifications"));
+// String msg = VCSUIHelper.getCommitMessage(script.getFile(), true);
+ if (msg == null) {
+ result = _("isisfish.message.commit.cancelled");
+ } else {
+ code.commit(msg);
+ code.reload();
+ result = _("isisfish.message.commit.finished");
+ }
+ return null;
+ } catch (Exception ex) {
+ Logger.getLogger(ScriptAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return result;
+ }
+ /**
+ * Exporte le(s) script(s) sélectionnés dans l'arbe.
+ * <br>L'arbre doit avoir au moins un script de selectionne
+ *
+ * @param uiContext swixat context
+ * @param frame swiaxt frame
+ * @param tree tree contaings script
+ * @return <code>null</code> if everything is ok,
+ * an <code>OutputVie<</code> with an error to display otherwise
+ */
+ public static String exportScript(TreePath[] selectedPaths) {
+ String message = null;
+ // first step : acquire list of files required
+ int prefixLength = IsisFish.config.getDatabaseDirectory().getAbsolutePath().length() + 1;
+ List<String> listFiles = extractFiles(prefixLength, selectedPaths);
+
+// try {
+// boolean fired = ScriptActionHelper.exportScript(null, listFiles, false, true, frame);
+// if (!fired) {
+// message = _("isisfish.message.export.cancelled");
+// } else {
+// message = _("isisfish.message.export.done");
+// }
+// } catch (Exception eee) {
+// }
+ return message;
+ }
+ protected static List<String> extractFiles(int prefixLength,TreePath[] selectedPaths) {
+ List<String> result = new ArrayList<String>();
+ List<File> dirFound = new ArrayList<File>();
+ List<File> dirWithFileFound = new ArrayList<File>();
+
+ for (TreePath selectedPath : selectedPaths) {
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath.getPathComponent(1);
+ String moduleDisplayName = String.valueOf(node.getUserObject());
+ File file = ScriptMapping.valueOf(moduleDisplayName).getModule();
+ int nbPaths = selectedPath.getPathCount();
+ if (nbPaths > 2)
+ for (int i = 2; i < nbPaths; i++) {
+ node = (DefaultMutableTreeNode) selectedPath.getPathComponent(i);
+ String pathName = String.valueOf(node.getUserObject());
+ file = new File(file, pathName);
+ }
+ if (file.isFile()) {
+ File parentFile = file.getParentFile();
+ if (!dirFound.contains(parentFile)) dirFound.add(parentFile);
+ dirWithFileFound.add(parentFile);
+ result.add(file.getAbsolutePath().substring(prefixLength));
+ } else {
+ // mark the file
+ dirFound.add(file);
+ }
+ }
+
+ // keep only user selected directories
+ dirFound.removeAll(dirWithFileFound);
+ dirWithFileFound.clear();
+
+ if (!dirFound.isEmpty()) {
+ List<File> listF = new ArrayList<File>();
+ // there is some directories selected by user
+ for (File dir : dirFound) {
+ // take all files and directories in the dir
+ // (without VCS and data dirs)
+// SVNMigrateHelper.grabbFiles(dir, excludeFilter, listF);
+
+
+ // getFilteredElements use include file filter, we inverse excludeFilter
+ FileFilter filter = new FileFilter() {
+ FileFilter excludeFilter = getSCRIPT_FILE_FILTER();
+ public boolean accept(File pathname) {
+ return !excludeFilter.accept(pathname);
+ }
+ };
+ listF.addAll(FileUtil.getFilteredElements(dir, filter, true));
+ }
+ for (File file : listF)
+ result.add(file.getAbsolutePath().substring(prefixLength));
+ listF.clear();
+ }
+ dirFound.clear();
+ return result;
+ }
+
+ public static FileFilter SCRIPT_FILE_FILTER;
+ public static FileFilter getSCRIPT_FILE_FILTER() {
+ if (SCRIPT_FILE_FILTER == null) {
+ SCRIPT_FILE_FILTER = new ScriptFileFilter(IsisFish.vcs);
+ }
+ return SCRIPT_FILE_FILTER;
+ }
+ //public static Object updateScript()
+ public void updateScript() {
+ try {
+ log.debug("updateScript called for ");
+ //TODO Use VCS UI dialog
+ //TODO Use FileState new mecanism to obtain state
+ code.update();
+ code.reload();
+ } catch (VCSException ex) {
+ Logger.getLogger(ScriptAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ public String checkScript(String content) {
+ String resultLog = "";
+ try {
+ log.debug("checkScript called");
+ // save script before commit
+ code.setContent(content);
+ JavaSourceStorage javaCode = (JavaSourceStorage)code;
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
+ int compileResult = 0;
+ Exception e = null;
+ try {
+ compileResult = javaCode.compile(false, out);
+ } catch (Exception eee) {
+ compileResult = -1;
+ e=eee;
+ }
+ if (compileResult != 0) {
+ out.flush();
+ resultLog = result.toString();
+ if (e == null) {
+ e = new RuntimeException("there is some problem in script");
+ }
+ }
+ else{
+ resultLog = "ok";
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(ScriptAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return resultLog;
+ }
+ public String evaluateScript(String content) {
+ log.debug("evaluateScript called");
+ String msg = "";
+ try {
+ String checkResult = checkScript(content);
+ if (checkResult != null) {
+ return checkResult;
+ }
+ code.setContent(content);
+ JavaSourceStorage javaCode = (JavaSourceStorage) code;
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ PrintStream out = new PrintStream(result);
+ PrintStream err = new PrintStream(result);
+ PrintStream oldOut = System.out;
+ PrintStream oldErr = System.err;
+ System.setOut(out);
+ System.setErr(err);
+ Class clazz = javaCode.getCodeClass();
+ Method main = clazz.getMethod("main", String[].class);
+ //noinspection RedundantArrayCreation
+ main.invoke(null, new Object[]{new String[]{}});
+ System.setOut(oldOut);
+ System.setErr(oldErr);
+ msg = result.toString();
+ } catch (Exception ex) {
+ Logger.getLogger(ScriptAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return msg;
+ }
+ /** enum to encapsulate a script module */
+ enum ScriptMapping {
+
+ Script(ScriptStorage.getScriptDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email
+ */
+ "package scripts{0};\n" +
+ "\n" +
+ "import org.apache.commons.logging.Log;\n" +
+ "import org.apache.commons.logging.LogFactory;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.util.Doc;\n" +
+ "\n" +
+ "import org.codelutin.math.matrix.*;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.entities.*;\n" +
+ "\n" +
+ "/**\n" +
+ " * {0}.{1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update: $Date: 2008-10-08 16:13:44 +0200 (mer 08 oct 2008) $\n" +
+ //" * by : $Author: sletellier $\n" +
+ " */\n" +
+ "public class {1} '{'\n" +
+ "\n" +
+ " /** to use log facility, just put in your code: log.info(\"...\"); */\n" +
+ " static private Log log = LogFactory.getLog({1}.class);\n" +
+ "\n" +
+ " // add your method here\n" +
+ "'}'\n"),
+
+ Simulator(SimulatorStorage.getSimulatorDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email
+ */
+ "package simulators{0};\n" +
+ "\n" +
+ "import org.apache.commons.logging.Log;\n" +
+ "import org.apache.commons.logging.LogFactory;\n" +
+ "\n" +
+ "import org.codelutin.math.matrix.*;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.util.Doc;\n" +
+ "import fr.ifremer.isisfish.entities.*;\n" +
+ "import fr.ifremer.isisfish.simulator.Simulator;\n" +
+ "import fr.ifremer.isisfish.simulator.SimulationContext;\n" +
+ "\n" +
+ "/**\n" +
+ " * {1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update$\n" +
+ //" * by : $Author: sletellier $\n" +
+ " */\n" +
+ "public class {1} implements Simulator '{'\n" +
+ "\n" +
+ " /** to use log facility, just put in your code: log.info(\"...\"); */\n" +
+ " static private Log log = LogFactory.getLog({1}.class);\n" +
+ "\n" +
+ " public void simulate(SimulationContext context) throws Exception '{'\n" +
+ " // put your code here\n" +
+ " '}'\n" +
+ "\n" +
+ "'}'\n"),
+ Export(ExportStorage.getExportDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email
+ */
+ "package exports{0};\n" +
+ "\n" +
+ "import org.apache.commons.logging.Log;\n" +
+ "import org.apache.commons.logging.LogFactory;\n" +
+ "\n" +
+ "import java.io.Writer;\n" +
+ "\n" +
+
+ "import static org.codelutin.i18n.I18nf._;\n" +
+ "import org.codelutin.math.matrix.*;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.util.Doc;\n" +
+ "import fr.ifremer.isisfish.entities.*;\n" +
+ "import fr.ifremer.isisfish.export.Export;\n" +
+ "import fr.ifremer.isisfish.datastore.SimulationStorage;\n" +
+ "import fr.ifremer.isisfish.datastore.ResultStorage;\n" +
+ "\n" +
+ "/**\n" +
+ " * {1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update: $Date: 2008-10-08 16:13:44 +0200 (mer 08 oct 2008) $\n" +
+ //" * by : $Author: sletellier $\n" +
+ " */\n" +
+ "public class {1} implements Export '{'\n" +
+ "\n" +
+ " /** to use log facility, just put in your code: log.info(\"...\"); */\n" +
+ " static private Log log = LogFactory.getLog({1}.class);\n" +
+ "\n" +
+ " public String [] necessaryResult = '{'\n" +
+ " // put here all necessary result for this rule\n" +
+ " // example: \n" +
+ " // ResultName.MATRIX_BIOMASS,\n" +
+ " // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,\n" +
+ " '}';\n" +
+ "\n" +
+ " public String[] getNecessaryResult() '{'\n" +
+ " return this.necessaryResult;\n" +
+ " '}'\n" +
+ "\n" +
+ " public String getExportFilename() '{'\n" +
+ " // remove _(...) if you don''t want translation on filename" +
+ " return _(\"{0}\");\n" +
+ " '}'\n" +
+ "\n" +
+ " public String getExtensionFilename() '{'\n" +
+ " return \".csv\";\n" +
+ " '}'\n" +
+ "\n" +
+ " public String getDescription() '{'\n" +
+ " return _(\"TODO export description\");\n" +
+ " '}'\n" +
+ "\n" +
+ " public void export(SimulationStorage simulation, Writer out) throws Exception '{'\n" +
+ " // put your code here, and write export with: out.write(\"...\")\n" +
+ " '}'\n" +
+ "\n" +
+ "'}'\n"),
+ Rule(RuleStorage.getRuleDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email,
+ * 5 = region name
+ */
+ "package rules{0};\n" +
+ "\n" +
+ "import static org.codelutin.i18n.I18nf._;\n" +
+ "\n" +
+ "import org.apache.commons.logging.Log;\n" +
+ "import org.apache.commons.logging.LogFactory;\n" +
+ "\n" +
+ "import scripts.ResultName;\n" +
+ "\n" +
+ "import java.io.Writer;\n" +
+ "\n" +
+ "import org.codelutin.math.matrix.*;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.util.Doc;\n" +
+ "import fr.ifremer.isisfish.simulator.SimulationContext;\n" +
+ "import fr.ifremer.isisfish.types.Date;\n" +
+ "import fr.ifremer.isisfish.entities.*;\n" +
+ "import fr.ifremer.isisfish.rule.AbstractRule;\n" +
+ "import fr.ifremer.isisfish.datastore.SimulationStorage;\n" +
+ "import fr.ifremer.isisfish.datastore.ResultStorage;\n" +
+ "\n" +
+ "/**\n" +
+ " * {1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update: $Date: 2008-10-08 16:13:44 +0200 (mer 08 oct 2008) $\n" +
+ //" * by : $Author: sletellier $\n" +
+ " */\n" +
+ "public class {1} extends AbstractRule '{'\n" +
+ "\n" +
+ " /** to use log facility, just put in your code: log.info(\"...\"); */\n" +
+ " static private Log log = LogFactory.getLog({1}.class);\n" +
+ "\n" +
+ " public String [] necessaryResult = '{'\n" +
+ " // put here all necessary result for this rule\n" +
+ " // example: \n" +
+ " // ResultName.MATRIX_BIOMASS,\n" +
+ " // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,\n" +
+ " '}';\n" +
+ "\n" +
+ " public String[] getNecessaryResult() '{'\n" +
+ " return this.necessaryResult;\n" +
+ " '}'\n" +
+ "\n" +
+ " /**\n" +
+ " * Permet d''afficher a l''utilisateur une aide sur la regle.\n" +
+ " * @return L''aide ou la description de la regle\n" +
+ " */\n" +
+ " public String getDescription() throws Exception '{'\n" +
+ " // TODO\n" +
+ " return _(\"TODO description rule\");\n" +
+ " '}'\n" +
+ " \n" +
+ " /**\n" +
+ " * Appelé au démarrage de la simulation, cette méthode permet d''initialiser\n" +
+ " * des valeurs\n" +
+ " * @param simulation La simulation pour lequel on utilise cette regle\n" +
+ " */\n" +
+ " public void init(SimulationContext context) throws Exception '{'\n" +
+ " // TODO\n" +
+ " '}'\n" +
+ " /**\n" +
+ " * La condition qui doit etre vrai pour faire les actions\n" +
+ " * @param simulation La simulation pour lequel on utilise cette regle\n" +
+ " * @return vrai si on souhaite que les actions soit faites\n" +
+ " */\n" +
+ " public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception '{'\n" +
+ " // TODO\n" +
+ " return false;\n" +
+ " '}'\n" +
+ " \n" +
+ " /**\n" +
+ " * Si la condition est vrai alors cette action est executée avant le pas\n" +
+ " * de temps de la simulation.\n" +
+ " * @param simulation La simulation pour lequel on utilise cette regle\n" +
+ " */\n" +
+ " public void preAction(SimulationContext context, Date date, Metier metier) throws Exception '{'\n" +
+ " // TODO\n" +
+ " '}'\n" +
+ " \n" +
+ " /**\n" +
+ " * Si la condition est vrai alors cette action est executée apres le pas\n" +
+ " * de temps de la simulation.\n" +
+ " * @param simulation La simulation pour lequel on utilise cette regle\n" +
+ " */\n" +
+ " public void postAction(SimulationContext context, Date date, Metier metier) throws Exception '{'\n" +
+ " // TODO\n" +
+ " '}'\n" +
+ "\n" +
+ "'}'\n"),
+ AnalysePlan(AnalysePlanStorage.getAnalysePlanDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email,
+ * 5 = region name
+ */
+ "package analyseplans{0};\n" +
+ "\n" +
+ "import static org.codelutin.i18n.I18nf._;\n" +
+ "\n" +
+ "import org.apache.commons.logging.Log;\n" +
+ "import org.apache.commons.logging.LogFactory;\n" +
+ "\n" +
+ "import scripts.ResultName;\n" +
+ "\n" +
+ "import java.io.Writer;\n" +
+ "\n" +
+ "import org.codelutin.math.matrix.*;\n" +
+ "import org.codelutin.util.*;\n" +
+ "import org.codelutin.topia.*;\n" +
+ "\n" +
+ "import fr.ifremer.isisfish.util.Doc;\n" +
+ "import fr.ifremer.isisfish.*;\n" +
+ "import fr.ifremer.isisfish.simulator.SimulationContext;\n" +
+ "import fr.ifremer.isisfish.types.Date;\n" +
+ "import fr.ifremer.isisfish.entities.*;\n" +
+ "import fr.ifremer.isisfish.simulator.AnalysePlan;\n" +
+ "import fr.ifremer.isisfish.simulator.AnalysePlanContext;\n" +
+ "import fr.ifremer.isisfish.simulator.SimulationParameter;\n" +
+ "import fr.ifremer.isisfish.datastore.SimulationStorage;\n" +
+ "import fr.ifremer.isisfish.datastore.ResultStorage;\n" +
+ "\n" +
+ "/**\n" +
+ " * {1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update: $Date: 2008-10-08 16:13:44 +0200 (mer 08 oct 2008) $\n" +
+ //" * by : $Author: sletellier $\n" +
+ " */\n" +
+ "public class {1} implements AnalysePlan '{'\n" +
+ "\n" +
+ " /** to use log facility, just put in your code: log.info(\"...\"); */\n" +
+ " static private Log log = LogFactory.getLog({1}.class);\n" +
+ "\n" +
+ " public String [] necessaryResult = '{'\n" +
+ " // put here all necessary result for this rule\n" +
+ " // example: \n" +
+ " // ResultName.MATRIX_BIOMASS,\n" +
+ " // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,\n" +
+ " '}';\n" +
+ "\n" +
+ " public String[] getNecessaryResult() '{'\n" +
+ " return this.necessaryResult;\n" +
+ " '}'\n" +
+ "\n" +
+ " /**\n" +
+ " * Permet d''afficher a l''utilisateur une aide sur le plan.\n" +
+ " * @return L''aide ou la description du plan\n" +
+ " */\n" +
+ " public String getDescription() throws Exception '{'\n" +
+ " // TODO\n" +
+ " return _(\"TODO description plan\");\n" +
+ " '}'\n" +
+ " \n" +
+ " /**\n" +
+ " * Appelé au démarrage de la simulation, cette méthode permet d''initialiser\n" +
+ " * des valeurs\n" +
+ " * @param simulation La simulation pour lequel on utilise cette regle\n" +
+ " */\n" +
+ " public void init(AnalysePlanContext context) throws Exception '{'\n" +
+ " // TODO\n" +
+ " '}'\n" +
+ " \n" +
+ " /**\n" +
+ " * Call before each simulation\n" +
+ " * @param context plan context\n" +
+ " * @param nextSimulation storage used for next simulation\n" +
+ " * @return true if we must do next simulation, false to stop plan\n" +
+ " * @throws Exception\n" +
+ " */\n" +
+ " public boolean next(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception '{'\n" +
+ " return false; // TODO\n" +
+ " '}'\n" +
+ "\n" +
+ "'}'\n"),
+ EquationModel(FormuleStorage.getFormuleDirectory(),
+ /**
+ * 0 = package name,
+ * 1 = class name,
+ * 2 = current date,
+ * 3 = author name,
+ * 4 = author email
+ */
+ "/**\n" +
+ " * {1}.java\n" +
+ " *\n" +
+ " * Created: {2,date, long}\n" +
+ " *\n" +
+ " * @author {3} <{4}>\n" +
+ //" * @version $Revision: 1545 $\n" +
+ " *\n" +
+ //" * Last update: $7 $\n" +
+ //" * by : $Author: sletellier $\n" +
+ //" */\n" +
+ "\n" +
+ "// put your code here\n" +
+ "\n");
+
+ private File module;
+ private String defaultContent;
+
+ ScriptMapping(File module, String defaultContent) {
+ this.module = module;
+ this.defaultContent = defaultContent;
+ }
+
+ File getModule() {
+ return module;
+ }
+
+ String getDefaultContent() {
+ return defaultContent;
+ }
+ }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2008-10-23 13:02:01 UTC (rev 1569)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2008-10-23 13:02:40 UTC (rev 1570)
@@ -37,193 +37,254 @@
import javax.swing.event.TreeSelectionListener;
import jaxx.runtime.swing.JAXXTree;
import javax.swing.tree.TreePath;
-
- protected Map<String, Item> items;
-
+ import fr.ifremer.isisfish.ui.widget.editor.GenericCell;
+ import javax.swing.tree.DefaultTreeModel;
+ import javax.swing.tree.DefaultMutableTreeNode;
+ import javax.swing.tree.TreeNode;
+ import static org.codelutin.i18n.I18nf._;
+ import fr.ifremer.isisfish.ui.WelcomePanelUI;
+
setContextValue(new ScriptAction());
- setItems();
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
- JAXXTree tree = (JAXXTree)e.getSource();
- String selectedValue = (String)tree.getSelectionValue();
- Item i = items.get(selectedValue);
- File f = null;
- if (i != null){
- Item parent = i.getParent();
- if (parent.equals(scriptItem)){
- f = new File(getContextValue(ScriptAction.class).getScriptDirectory().getPath() + File.separator + selectedValue);
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+ if (node != null){
+ GenericCell selectedValue = (GenericCell) node.getUserObject();
+ if (selectedValue.getValue() != null){
+ String parent = selectedValue.getValue().toString();
+ File f = null;
+ if (!parent.equals("EquationModel")) {
+ if (parent.equals("Script")) {
+ f = new File(getContextValue(ScriptAction.class).getScriptDirectory().getPath() + File.separator + selectedValue);
+ } else if (parent.equals("Simulator")) {
+ f = new File(getContextValue(ScriptAction.class).getSimulatorDirectory().getPath() + File.separator + selectedValue);
+ } else if (parent.equals("Export")) {
+ f = new File(getContextValue(ScriptAction.class).getExportDirectory().getPath() + File.separator + selectedValue);
+ } else if (parent.equals("Rule")) {
+ f = new File(getContextValue(ScriptAction.class).getRuleDirectory().getPath() + File.separator + selectedValue);
+ } else if (parent.equals("AnalysePlan")) {
+ f = new File(getContextValue(ScriptAction.class).getAnalysePlanDirectory().getPath() + File.separator + selectedValue);
+ } else {
+ f = new File(getContextValue(ScriptAction.class).getFormuleDirectory().getPath() + File.separator + parent + File.separator + selectedValue);
+ parent = "EquationModel";
+ }
+ }
+ if (f != null) {
+ getContextValue(ScriptAction.class).loadScript(selectedValue, selectedValue.getName(), parent);
+ setEditor(f);
+ }
+ setButton();
}
- else if (parent.equals(simulationItem)){
- f = new File(getContextValue(ScriptAction.class).getSimulationDirectory().getPath() + File.separator + selectedValue);
+ else {
+ editor.close();
+ editor.repaint();
}
- else if (parent.equals(exportItem)){
- f = new File(getContextValue(ScriptAction.class).getExportDirectory().getPath() + File.separator + selectedValue);
- }
- else if (parent.equals(ruleItem)){
- f = new File(getContextValue(ScriptAction.class).getRuleDirectory().getPath() + File.separator + selectedValue);
- }
- else if (parent.equals(analysePlanItem)){
- f = new File(getContextValue(ScriptAction.class).getAnalysePlanDirectory().getPath() + File.separator + selectedValue);
- }
- else if (parent.equals(equationModelItem)){
- f = new File(getContextValue(ScriptAction.class).getFormuleDirectory().getPath() + File.separator + selectedValue);
- }
- if (f!=null){
- setEditor(f);
- }
+ actionLogArea.setText("");
+ setButton();
}
}
});
- protected void setItems(){
- items = new HashMap<String, Item>();
- setScriptItems();
- setSimulationItems();
- setExportItems();
- setRuleItems();
- setAnalysePlanItem();
- setEquationModelItem();
+ protected void setTreeModel(){
+ tree.setModel(getTreeModel());
}
- protected void setScriptItems(){
- for (String value : getContextValue(ScriptAction.class).getScriptNames()){
- Item i = new Item(value, null, value, false);
- items.put(value, i);
- scriptItem.addChild(i);
+ protected DefaultTreeModel getTreeModel(){
+ DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
+ DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
+ DefaultMutableTreeNode scriptNode = new DefaultMutableTreeNode(new GenericCell("Script", null));
+ DefaultMutableTreeNode simulatorNode = new DefaultMutableTreeNode(new GenericCell("Simulator", null));
+ DefaultMutableTreeNode exportNode = new DefaultMutableTreeNode(new GenericCell("Export", null));
+ DefaultMutableTreeNode ruleNode = new DefaultMutableTreeNode(new GenericCell("Rule", null));
+ DefaultMutableTreeNode analysePlanNode = new DefaultMutableTreeNode(new GenericCell("AnalysePlan", null));
+ DefaultMutableTreeNode equationModelNode = new DefaultMutableTreeNode(new GenericCell("EquationModel", null));
+ setNode(scriptNode, getContextValue(ScriptAction.class).getScriptNames(), "Script");
+ setNode(simulatorNode, getContextValue(ScriptAction.class).getSimulatorNames(), "Simulator");
+ setNode(exportNode, getContextValue(ScriptAction.class).getExportNames(), "Export");
+ setNode(ruleNode, getContextValue(ScriptAction.class).getRuleNames(), "Rule");
+ setNode(analysePlanNode, getContextValue(ScriptAction.class).getAnalysePlanNames(), "AnalysePlan");
+ setNode(equationModelNode, getContextValue(ScriptAction.class).getCategories(), "EquationModel");
+ for (Enumeration e = equationModelNode.children(); e.hasMoreElements();){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)e.nextElement();
+ GenericCell g = (GenericCell)node.getUserObject();
+ setNode(node, getContextValue(ScriptAction.class).getFormuleNames(g.toString()), g.toString());
}
+ treeModel.insertNodeInto(scriptNode, rootNode, 0);
+ treeModel.insertNodeInto(simulatorNode, rootNode, 1);
+ treeModel.insertNodeInto(exportNode, rootNode, 2);
+ treeModel.insertNodeInto(ruleNode, rootNode, 3);
+ treeModel.insertNodeInto(analysePlanNode, rootNode, 4);
+ treeModel.insertNodeInto(equationModelNode, rootNode, 5);
+ return treeModel;
}
- protected void setSimulationItems(){
- for (String value : getContextValue(ScriptAction.class).getSimulationNames()){
- Item i = new Item(value, null, value, false);
- items.put(value, i);
- simulationItem.addChild(i);
+ protected void setNode(DefaultMutableTreeNode node, java.util.List<String> values, String type) {
+ for (String value : values){
+ DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new GenericCell(value, type));
+ node.add(childNode);
}
}
- protected void setExportItems(){
- for (String value : getContextValue(ScriptAction.class).getExportNames()){
- Item i = new Item(value, null, value, false);
- items.put(value, i);
- exportItem.addChild(i);
- }
+ protected void setEditor(File f){
+ editor.open(f);
+ editor.repaint();
}
- protected void setRuleItems(){
- for (String value : getContextValue(ScriptAction.class).getRuleNames()){
- Item i = new Item(value, null, value, false);
- items.put(value, i);
- ruleItem.addChild(i);
+ protected DefaultMutableTreeNode findNode(DefaultMutableTreeNode root, String value){
+ DefaultMutableTreeNode result= null;
+ for (Enumeration e = root.children(); e.hasMoreElements();){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)e.nextElement();
+ GenericCell g = (GenericCell)node.getUserObject();
+ if (value.equals(g.getName())){
+ result = node;
+ }
}
+ return result;
}
- protected void setAnalysePlanItem(){
- for (String value : getContextValue(ScriptAction.class).getAnalysePlanNames()){
- Item i = new Item(value, null, value, false);
- items.put(value, i);
- analysePlanItem.addChild(i);
+
+ protected void setButton(){
+ boolean fileLoaded = getContextValue(ScriptAction.class).fileLoaded();
+ boolean isJavaScript = getContextValue(ScriptAction.class).isJavaScript();
+ buttonScriptExport.setEnabled(tree.getSelectionValue() != null);
+// buttonScriptCommit
+// buttonScriptUpdate
+ buttonScriptSave.setEnabled(fileLoaded);
+ buttonScriptCut.setEnabled(fileLoaded);
+ buttonScriptCopy.setEnabled(fileLoaded);
+ buttonScriptPaste.setEnabled(fileLoaded);
+ buttonScriptCheck.setEnabled(isJavaScript);
+ buttonScriptEval.setEnabled(isJavaScript);
+ }
+ protected void setInfoText(String msg){
+ WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
+ root.setInfoText("msg");
+ }
+/*
+ * JButton Action
+ */
+
+ protected void newScript(){
+ java.util.List<String> values = getContextValue(ScriptAction.class).getCategories();
+ String scriptType = (String)ScriptTypeChoice.getSelectedItem();
+ String equationModelType = "";
+ String equationModelTypePath = "";
+ if (scriptType.equals("EquationModel")){
+ equationModelType = (String)JOptionPane.showInputDialog(
+ this,
+ "Select the equation model's category",
+ "Equation model",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ values.toArray(),
+ values.get(0));
+ equationModelTypePath = equationModelType + File.separator;
}
- }
- protected void setEquationModelItem(){
- for (String categorie : getContextValue(ScriptAction.class).getCategories()){
- Item item = new Item(categorie, null, categorie, false);
- equationModelItem.addChild(item);
- for (String formule : getContextValue(ScriptAction.class).getFormuleNames(categorie)){
- Item i = new Item(formule, null, formule, false);
- items.put(formule, i);
- i.addChild(i);
+ if (equationModelType != null){
+ String fileName = JOptionPane.showInputDialog(_("isisfish.message.new.filename"));
+ if (fileName != null){
+ getContextValue(ScriptAction.class).newScript(equationModelTypePath + fileName, scriptType);
+ setTreeModel();
+ setInfoText(_("isisfish.message.creation.done", script.getName()));
+ DefaultMutableTreeNode element = null;
+ element = findNode((DefaultMutableTreeNode) tree.getModel().getRoot(), scriptType);
+ if (!equationModelTypePath.equals("")){
+ element = findNode(element, equationModelType);
+ }
+ element = findNode(element, fileName + ".java");
+ TreeNode[] path = element.getPath();
+ if (log.isDebugEnabled()) {
+ log.debug("chemin du prochain noeud selectionnée: " + Arrays.toString(path));
+ }
+ TreePath newSelectionPath = new TreePath(path);
+ tree.setSelectionPath(newSelectionPath);
}
}
}
- protected void setEditor(File f){
- editor.open(f);
+ protected void saveScript(){
+ getContextValue(ScriptAction.class).saveScript(editor.getText());
+ setInfoText(_("isisfish.message.save.finished"));
}
+ protected void exportScript(){
+ getContextValue(ScriptAction.class).exportScript(tree.getSelectionPaths());
+ }
+ protected void commitScript(){
+ setInfoText(_(getContextValue(ScriptAction.class).commitScript(editor.getText())));
+ }
+ protected void updateScript(){
+ getContextValue(ScriptAction.class).updateScript();
+ setInfoText(_("isisfish.message.update.finished"));
+ }
+ protected void cut(){
+ }
+ protected void copy(){
+ }
+ protected void paste(){
+ }
+ protected void checkScript(){
+ actionLogArea.setText(getContextValue(ScriptAction.class).checkScript(editor.getText()));
+ setInfoText(_("isisfish.message.check.finished"));
+ }
+ protected void evaluateScript(){
+ actionLogArea.setText(getContextValue(ScriptAction.class).evaluateScript(editor.getText()));
+ setInfoText(_("isisfish.message.evaluation.finished"));
+ }
]]>
</script>
-<!--
-title="isisfish.script.title"
-visible="true" size='{new Dimension(620,400)}'
--->
-
-<!-- Fixme : WindowsEvents
-<WindowEvents id="events" onOpened="script.Action.opened()" />
-Maximizable="true" Closable="true"
-bundle="org.codelutin.i18n.I18nBundleBridge"
--->
-
-<!-- Fixme : ContextDataSource
- <ContextDataSource id="ScriptStorage" context="current" source="ScriptStorage"/>
- <ContextDataSource id="ActionLog" context="current" source="ActionLog"/>
- <ContextDataSource id="ScriptType" context="current" source="ScriptType"/>
- <ContextDataSource id="canCommit" context="current" source="canCommit"/>
- <ContextDataSource id="canUpdate" context="current" source="canUpdate"/>
- <ContextDataSource id="canDiff" context="current" source="canDiff"/>
- <ContextDataSource id="canDelete" context="current" source="canDelete"/>
--->
-
<!--
| Toolbar
+-->
<JPanel id="buttonBar" layout='{new GridLayout()}' constraints='BorderLayout.NORTH'>
<JComboBox id="ScriptTypeChoice" model='{new DefaultComboBoxModel(getContextValue(ScriptAction.class).getScriptTypesNames())}'/>
+ <JButton id="buttonScriptNew" text="isisfish.script.new" onActionPerformed='newScript()'/>
<!--
-origin="ScriptType"
-renderer="org.codelutin.i18n.I18n._(.)"
--->
-
- <!-- no change name in combo box, or change for menu and in Action.newScript too -->
-<!-- Fixme : comboboxmodel
- <comboboxmodel origin="fr.ifremer.isisfish.ui.script.Action.getScriptTypesNames()"/>
--->
- <JButton id="buttonScriptNew" text="isisfish.script.new"/>
-<!--
ToolTipText="Create a new script"
actionCommand="script.Action.newScript($tree, $treeModel, $ScriptTypeChoice/selectedItem)"
-->
- <JButton id="buttonScriptSave" text="isisfish.script.save"/>
+ <JButton id="buttonScriptSave" text="isisfish.script.save" enabled='false' onActionPerformed='saveScript()'/>
<!--
ToolTipText="Save current script"
origin="util:isValid($ScriptStorage)"
actionCommand="script.Action.saveScript($ScriptStorage, $scriptJedit/text)"
-->
- <JButton id="buttonScriptExport" text="isisfish.script.txtExport"/>
+ <JButton id="buttonScriptExport" text="isisfish.script.txtExport" enabled='false' onActionPerformed='exportScript()'/>
<!--
ToolTipText="Export selected script(s) to zip archive"
origin="$tree/selectionPaths"
actionCommand="script.Action.exportScript($tree)"
-->
- <JButton id="buttonScriptCommit" text="isisfish.script.commit"/>
+ <JButton id="buttonScriptCommit" text="isisfish.script.commit" enabled='false' onActionPerformed='commitScript()'/>
<!--
ToolTipText="Commit script to CVS server"
origin="$canCommit"
actionCommand="script.Action.commitScript($tree, $ScriptStorage, $scriptJedit/text)"
-->
- <JButton id="buttonScriptUpdate" text="isisfish.script.update"/>
+ <JButton id="buttonScriptUpdate" text="isisfish.script.update" enabled='false' onActionPerformed='updateScript()'/>
<!--
ToolTipText="Update current script from server"
origin="$canUpdate"
actionCommand="script.Action.updateScript($tree,$ScriptStorage)"
-->
- <JButton id="buttonScriptCut" text="isisfish.script.cut"/>
+ <JButton id="buttonScriptCut" text="isisfish.script.cut" enabled='false' onActionPerformed='cut()'/>
<!--
ToolTipText="Cut current selection (Ctrl-x)"
origin="util:isValid($ScriptStorage)"
actionCommand="xpath:cut($scriptJedit)"
-->
- <JButton id="buttonScriptCopy" text="isisfish.script.copy"/>
+ <JButton id="buttonScriptCopy" text="isisfish.script.copy" enabled='false' onActionPerformed='copy()'/>
<!--
ToolTipText="Copy current selection (Ctrl-c)"
origin="util:isValid($ScriptStorage)"
actionCommand="xpath:copy($scriptJedit)"
-->
- <JButton id="buttonScriptPaste" text="isisfish.script.paste"/>
+ <JButton id="buttonScriptPaste" text="isisfish.script.paste" enabled='false' onActionPerformed='paste()'/>
<!--
ToolTipText="Paste current selection (Ctrl-v)"
origin="util:isValid($ScriptStorage)"
actionCommand="xpath:paste($scriptJedit)"
-->
- <JButton id="buttonScriptCheck" text="isisfish.script.check"/>
+ <JButton id="buttonScriptCheck" text="isisfish.script.check" enabled='false' onActionPerformed='checkScript()'/>
<!--
ToolTipText="Check syntax of the current script"
origin="util:isInstance('fr.ifremer.isisfish.datastore.JavaSourceStorage', $ScriptStorage)"
actionCommand="script.Action.checkScript($ScriptStorage, $scriptJedit/text)"
-->
- <JButton id="buttonScriptEval" text="isisfish.script.evaluate"/>
+ <JButton id="buttonScriptEval" text="isisfish.script.evaluate" enabled='false' onActionPerformed='evaluateScript()'/>
<!--
ToolTipText="Try to eval current script (must be have main method)"
origin="util:isInstance('fr.ifremer.isisfish.datastore.JavaSourceStorage', $ScriptStorage)"
@@ -246,13 +307,7 @@
<!-- Fixme : non plus : JScrollPane does not accept constraints
constraints='"tree"'
-->
- <JTree id="tree" name="tree" rootVisible="false">
- <item id='scriptItem' selected='true' value="Script"/>
- <item id='simulationItem' value="Simulator"/>
- <item id='exportItem' value="Export"/>
- <item id='ruleItem' value="Rule"/>
- <item id='analysePlanItem' value="AnalysePlan"/>
- <item id='equationModelItem' value="EquationModel"/>
+ <javax.swing.JTree id="tree" name="tree" rootVisible="false" model='{getTreeModel()}'/>
<!-- Fixme : NestedTreeModel, TreeRenderer and TreeSelectionEvents
<NestedTreeModel id="treeModel">
@@ -288,7 +343,6 @@
<TreeSelectionEvents id="treeSelectionListener"
onValueChanged="thread:script.Action.loadScript($tree, $tree/selectionPath/path[2]/userObject, $tree/selectionPath/lastPathComponent)"/>
-->
- </JTree>
</JScrollPane>
<JSplitPane oneTouchExpandable="true" dividerLocation="250" orientation="VERTICAL">
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-23 13:02:01 UTC (rev 1569)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-23 13:02:40 UTC (rev 1570)
@@ -45,9 +45,9 @@
import org.codelutin.math.matrix.gui.MatrixPanelEditor;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
+ import fr.ifremer.isisfish.ui.widget.editor.GenericCell;
+ import javax.swing.table.TableColumn;
import fr.ifremer.isisfish.ui.widget.editor.ParameterColumnEditor;
- import javax.swing.table.TableColumn;
-import fr.ifremer.isisfish.ui.widget.editor.ParameterCellEditor;
setContextValue(new MatrixPanelEditor());
simulParamsNumbers.add(getContextValue(MatrixPanelEditor.class), BorderLayout.CENTER);
@@ -208,7 +208,7 @@
for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) {
String name = it.next();
Object properties = getContextValue(SimulAction.class).getRuleParameterValue(name, listSimulParamsMesuresList.getSelectedValue().toString());
- ParameterCellEditor value = new ParameterCellEditor(name, values.get(name));
+ GenericCell value = new GenericCell(name, values.get(name));
model.setValueAt(value, row, 0);
model.setValueAt(properties, row, 1);
row++;
@@ -223,7 +223,7 @@
public void tableChanged(TableModelEvent e) {
int row = e.getFirstRow();
TableModel model = (TableModel)e.getSource();
- ParameterCellEditor data = (ParameterCellEditor) model.getValueAt(row, 0);
+ GenericCell data = (GenericCell) model.getValueAt(row, 0);
getContextValue(SimulAction.class).setRuleParameterValue(data.getName(), listSimulParamsMesuresList.getSelectedValue().toString(), model.getValueAt(row, 1));
}
});
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2008-10-23 13:02:01 UTC (rev 1569)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2008-10-23 13:02:40 UTC (rev 1570)
@@ -38,7 +38,7 @@
import javax.swing.table.TableModel;
import fr.ifremer.isisfish.ui.widget.editor.ParameterColumnEditor;
import javax.swing.table.TableColumn;
- import fr.ifremer.isisfish.ui.widget.editor.ParameterCellEditor;
+ import fr.ifremer.isisfish.ui.widget.editor.GenericCell;
public SensUI (SimulAction action){
setContextValue(action);
@@ -89,7 +89,7 @@
for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) {
String name = it.next();
Object properties = getContextValue(SimulAction.class).getAnalysePlanParameterValue(name, listSimulParamsAnalysePlansList.getSelectedValue().toString());
- ParameterCellEditor value = new ParameterCellEditor(name, values.get(name));
+ GenericCell value = new GenericCell(name, values.get(name));
model.setValueAt(value, row, 0);
model.setValueAt(properties, row, 1);
row++;
@@ -103,7 +103,7 @@
public void tableChanged(TableModelEvent e) {
int row = e.getFirstRow();
TableModel model = (TableModel)e.getSource();
- ParameterCellEditor data = (ParameterCellEditor) model.getValueAt(row, 0);
+ GenericCell data = (GenericCell) model.getValueAt(row, 0);
getContextValue(SimulAction.class).setAnalysePlanParameterValue(data.getName(), listSimulParamsAnalysePlansList.getSelectedValue().toString(), model.getValueAt(row, 1));
}
});
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/GenericCell.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/GenericCell.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/GenericCell.java 2008-10-23 13:02:40 UTC (rev 1570)
@@ -0,0 +1,29 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package fr.ifremer.isisfish.ui.widget.editor;
+
+/**
+ *
+ * @author letellier
+ */
+public class GenericCell{
+ private String name;
+ private Object value;
+ public GenericCell(String n, Object c){
+ name = n;
+ value = c;
+ }
+ @Override
+ public String toString(){
+ return name;
+ }
+ public Object getValue(){
+ return value;
+ }
+ public String getName(){
+ return name;
+ }
+}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java 2008-10-23 13:02:01 UTC (rev 1569)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java 2008-10-23 13:02:40 UTC (rev 1570)
@@ -152,8 +152,8 @@
// Map.Entry<String, Class> p = (Map.Entry<String, Class>) table.getValueAt(row, 0);
// type = p.getValue();
// log.debug(p.getKey() + " P.type:" + type);
- ParameterCellEditor p = (ParameterCellEditor) table.getValueAt(row, 0);
- type = p.getType();
+ GenericCell p = (GenericCell) table.getValueAt(row, 0);
+ type = (Class)p.getValue();
JComboBox c;
//if (!table.hasFocus()) return null;
1
0
r1569 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/equation
by sletellier@users.labs.libre-entreprise.org 23 Oct '08
by sletellier@users.labs.libre-entreprise.org 23 Oct '08
23 Oct '08
Author: sletellier
Date: 2008-10-23 13:02:01 +0000 (Thu, 23 Oct 2008)
New Revision: 1569
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/equation/Language.java
Log:
Correction bug
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/equation/Language.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/equation/Language.java 2008-10-21 08:48:52 UTC (rev 1568)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/equation/Language.java 2008-10-23 13:02:01 UTC (rev 1569)
@@ -38,7 +38,7 @@
*/
public class Language {
- final static public String JAVA = "Java";
+ final static public String JAVA = "java";
final static public String BSH = "BSH";
final static public String ECMASCRIPT = "ECMAScript";
final static public String GROOVY = "Groovy";
1
0
r1568 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator
by sletellier@users.labs.libre-entreprise.org 21 Oct '08
by sletellier@users.labs.libre-entreprise.org 21 Oct '08
21 Oct '08
Author: sletellier
Date: 2008-10-21 08:48:52 +0000 (Tue, 21 Oct 2008)
New Revision: 1568
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
Log:
Correction bug loadOldSimulation
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-20 16:43:49 UTC (rev 1567)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-21 08:48:52 UTC (rev 1568)
@@ -87,10 +87,11 @@
WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
root.setInfoText(_("isisfish.message.loading.old.simulation"));
- Exception eee = getContextValue(SimulAction.class).loadOldSimulation(fieldSimulParamsSelect.getSelectedItem().toString());
- if (eee != null){
+ getContextValue(SimulAction.class).loadOldSimulation(fieldSimulParamsSelect.getSelectedItem().toString());
+ //Exception eee =
+ //if (eee != null){
// new OutputView("Error.xml", "error", eee.getMessage());
- }
+ //}
refresh();
root.setInfoText(_("isisfish.message.old.simulation.loaded"));
}
1
0
r1567 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script
by sletellier@users.labs.libre-entreprise.org 20 Oct '08
by sletellier@users.labs.libre-entreprise.org 20 Oct '08
20 Oct '08
Author: sletellier
Date: 2008-10-20 16:43:49 +0000 (Mon, 20 Oct 2008)
New Revision: 1567
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
Log:
Script JAXX
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2008-10-20 16:43:49 UTC (rev 1567)
@@ -0,0 +1,73 @@
+package fr.ifremer.isisfish.ui.script;
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author letellier
+ */
+import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.ui.script.Action.ScriptMapping;
+import java.io.File;
+import java.util.List;
+public class ScriptAction {
+ public ScriptAction(){
+
+ }
+ /** @return an array of all script's modules names managed by this screen */
+ public static String[] getScriptTypesNames() {
+ ScriptMapping[] values = ScriptMapping.values();
+ String[] result = new String[values.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = values[i].name();
+ }
+ return result;
+ }
+ public List<String> getScriptNames(){
+ return ScriptStorage.getScriptNames();
+ }
+ public List<String> getSimulationNames(){
+ return SimulationStorage.getSimulationNames();
+ }
+ public List<String> getExportNames(){
+ return ExportStorage.getExportNames();
+ }
+ public List<String> getRuleNames(){
+ return RuleStorage.getRuleNames();
+ }
+ public List<String> getAnalysePlanNames(){
+ return AnalysePlanStorage.getAnalysePlanNames();
+ }
+ public List<String> getCategories(){
+ return FormuleStorage.getCategories();
+ }
+ public List<String> getFormuleNames(String Categories){
+ return FormuleStorage.getFormuleNames(Categories);
+ }
+ public File getScriptDirectory(){
+ return ScriptStorage.getScriptDirectory();
+ }
+ public File getSimulationDirectory(){
+ return SimulationStorage.getSimulationDirectory();
+ }
+ public File getExportDirectory(){
+ return ExportStorage.getExportDirectory();
+ }
+ public File getRuleDirectory(){
+ return RuleStorage.getRuleDirectory();
+ }
+ public File getAnalysePlanDirectory(){
+ return AnalysePlanStorage.getAnalysePlanDirectory();
+ }
+ public File getFormuleDirectory(){
+ return FormuleStorage.getFormuleDirectory();
+ }
+}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2008-10-17 14:58:29 UTC (rev 1566)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2008-10-20 16:43:49 UTC (rev 1567)
@@ -32,6 +32,109 @@
-->
<JPanel id="script" layout='{new BorderLayout()}'>
+ <script><![CDATA[
+ import jaxx.runtime.swing.Item;
+ import javax.swing.event.TreeSelectionListener;
+ import jaxx.runtime.swing.JAXXTree;
+ import javax.swing.tree.TreePath;
+
+ protected Map<String, Item> items;
+
+ setContextValue(new ScriptAction());
+ setItems();
+ tree.addTreeSelectionListener(new TreeSelectionListener() {
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ JAXXTree tree = (JAXXTree)e.getSource();
+ String selectedValue = (String)tree.getSelectionValue();
+ Item i = items.get(selectedValue);
+ File f = null;
+ if (i != null){
+ Item parent = i.getParent();
+ if (parent.equals(scriptItem)){
+ f = new File(getContextValue(ScriptAction.class).getScriptDirectory().getPath() + File.separator + selectedValue);
+ }
+ else if (parent.equals(simulationItem)){
+ f = new File(getContextValue(ScriptAction.class).getSimulationDirectory().getPath() + File.separator + selectedValue);
+ }
+ else if (parent.equals(exportItem)){
+ f = new File(getContextValue(ScriptAction.class).getExportDirectory().getPath() + File.separator + selectedValue);
+ }
+ else if (parent.equals(ruleItem)){
+ f = new File(getContextValue(ScriptAction.class).getRuleDirectory().getPath() + File.separator + selectedValue);
+ }
+ else if (parent.equals(analysePlanItem)){
+ f = new File(getContextValue(ScriptAction.class).getAnalysePlanDirectory().getPath() + File.separator + selectedValue);
+ }
+ else if (parent.equals(equationModelItem)){
+ f = new File(getContextValue(ScriptAction.class).getFormuleDirectory().getPath() + File.separator + selectedValue);
+ }
+ if (f!=null){
+ setEditor(f);
+ }
+ }
+ }
+ });
+ protected void setItems(){
+ items = new HashMap<String, Item>();
+ setScriptItems();
+ setSimulationItems();
+ setExportItems();
+ setRuleItems();
+ setAnalysePlanItem();
+ setEquationModelItem();
+ }
+ protected void setScriptItems(){
+ for (String value : getContextValue(ScriptAction.class).getScriptNames()){
+ Item i = new Item(value, null, value, false);
+ items.put(value, i);
+ scriptItem.addChild(i);
+ }
+ }
+ protected void setSimulationItems(){
+ for (String value : getContextValue(ScriptAction.class).getSimulationNames()){
+ Item i = new Item(value, null, value, false);
+ items.put(value, i);
+ simulationItem.addChild(i);
+ }
+ }
+ protected void setExportItems(){
+ for (String value : getContextValue(ScriptAction.class).getExportNames()){
+ Item i = new Item(value, null, value, false);
+ items.put(value, i);
+ exportItem.addChild(i);
+ }
+ }
+ protected void setRuleItems(){
+ for (String value : getContextValue(ScriptAction.class).getRuleNames()){
+ Item i = new Item(value, null, value, false);
+ items.put(value, i);
+ ruleItem.addChild(i);
+ }
+ }
+ protected void setAnalysePlanItem(){
+ for (String value : getContextValue(ScriptAction.class).getAnalysePlanNames()){
+ Item i = new Item(value, null, value, false);
+ items.put(value, i);
+ analysePlanItem.addChild(i);
+ }
+ }
+ protected void setEquationModelItem(){
+ for (String categorie : getContextValue(ScriptAction.class).getCategories()){
+ Item item = new Item(categorie, null, categorie, false);
+ equationModelItem.addChild(item);
+ for (String formule : getContextValue(ScriptAction.class).getFormuleNames(categorie)){
+ Item i = new Item(formule, null, formule, false);
+ items.put(formule, i);
+ i.addChild(i);
+ }
+ }
+ }
+ protected void setEditor(File f){
+ editor.open(f);
+ }
+ ]]>
+ </script>
<!--
title="isisfish.script.title"
visible="true" size='{new Dimension(620,400)}'
@@ -57,7 +160,7 @@
| Toolbar
+-->
<JPanel id="buttonBar" layout='{new GridLayout()}' constraints='BorderLayout.NORTH'>
- <JComboBox id="ScriptTypeChoice">
+ <JComboBox id="ScriptTypeChoice" model='{new DefaultComboBoxModel(getContextValue(ScriptAction.class).getScriptTypesNames())}'/>
<!--
origin="ScriptType"
renderer="org.codelutin.i18n.I18n._(.)"
@@ -67,7 +170,6 @@
<!-- Fixme : comboboxmodel
<comboboxmodel origin="fr.ifremer.isisfish.ui.script.Action.getScriptTypesNames()"/>
-->
- </JComboBox>
<JButton id="buttonScriptNew" text="isisfish.script.new"/>
<!--
ToolTipText="Create a new script"
@@ -145,6 +247,13 @@
constraints='"tree"'
-->
<JTree id="tree" name="tree" rootVisible="false">
+ <item id='scriptItem' selected='true' value="Script"/>
+ <item id='simulationItem' value="Simulator"/>
+ <item id='exportItem' value="Export"/>
+ <item id='ruleItem' value="Rule"/>
+ <item id='analysePlanItem' value="AnalysePlan"/>
+ <item id='equationModelItem' value="EquationModel"/>
+
<!-- Fixme : NestedTreeModel, TreeRenderer and TreeSelectionEvents
<NestedTreeModel id="treeModel">
<TreeNode name="Root">
@@ -186,9 +295,8 @@
<!--
| Editor script
+-->
+ <org.codelutin.widget.editor.Editor id='editor'/>
<!-- Fixme : editor
- <editor id="scriptJedit" constraints='"fieldScriptEdit"'/>
-
origin="$ScriptStorage/file"
-->
<!--
1
0
r1566 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator
by sletellier@users.labs.libre-entreprise.org 17 Oct '08
by sletellier@users.labs.libre-entreprise.org 17 Oct '08
17 Oct '08
Author: sletellier
Date: 2008-10-17 14:58:29 +0000 (Fri, 17 Oct 2008)
New Revision: 1566
Removed:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Queue.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorAction.java
Log:
Simulation completed
Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsAction.java 2008-10-17 14:57:40 UTC (rev 1565)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsAction.java 2008-10-17 14:58:29 UTC (rev 1566)
@@ -1,49 +0,0 @@
-/* *##%
- * Copyright (C) 2005
- * Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * IsisFish.java
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin at codelutin.com>
- * @version $Revision: 1312 $
- *
- * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $
- * by : $Author: sletellier $
- */
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-/**
- *
- * @author letellier
- */
-package fr.ifremer.isisfish.ui.simulator;
-
-public class AdvancedParamsAction{
- public AdvancedParamsAction(){
-
- }
- public void getSimulatorNames(){
-
- }
-}
Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Queue.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Queue.java 2008-10-17 14:57:40 UTC (rev 1565)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Queue.java 2008-10-17 14:58:29 UTC (rev 1566)
@@ -1,212 +0,0 @@
-/*
- * Queue.java
- *
- * Created on 22 août 2008, 23:01
- */
-
-package fr.ifremer.isisfish.ui.simulator;
-
-import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
-import static org.codelutin.i18n.I18nf._;
-
-import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
-import fr.ifremer.isisfish.simulator.launcher.SimulationService;
-import fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel;
-import java.awt.Component;
-import javax.swing.GroupLayout;
-import javax.swing.JProgressBar;
-import javax.swing.JTable;
-import javax.swing.LayoutStyle;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.TableCellRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.log.UserLog;
-import org.jdesktop.beansbinding.AutoBinding;
-import org.jdesktop.beansbinding.BeanProperty;
-import org.jdesktop.beansbinding.Binding;
-import org.jdesktop.beansbinding.BindingGroup;
-import org.jdesktop.beansbinding.Bindings;
-import org.jdesktop.beansbinding.ELProperty;
-
-/**
- * Widget permettant d'afficher l'etat des simulations
- *
- * @author poussin
- */
-public class Queue extends javax.swing.JPanel {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SimulationServiceTableModel.class);
-
- public class JProgressBarTableCellRenderer implements TableCellRenderer {
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
- int row, int column) {
- return (JProgressBar) value;
- }
- }// JProgressBarTableCellRenderer
-
- /** Creates new form Queue */
- public Queue() {
- initComponents();
- SimulationService ss = SimulationService.getService();
-
- modelJobs = new SimulationServiceTableModel(ss, true);
- modelJobDones = new SimulationServiceTableModel(ss, false);
-
- tableJobs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- tableJobs.setDefaultRenderer(JProgressBar.class,
- new JProgressBarTableCellRenderer());
- tableJobDones.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- tableJobDones.setDefaultRenderer(JProgressBar.class,
- new JProgressBarTableCellRenderer());
-
- tableJobs.setModel(modelJobs);
- tableJobDones.setModel(modelJobDones);
- }
-
- protected void stopSimulation(java.awt.event.ActionEvent evt) {
- int i = tableJobs.getSelectedRow();
- if (i >= 0) {
- SimulationJob job = modelJobs.getJob(i);
- job.stop();
- log.info(_("User stop simulation %s", job.getItem().getControl().getId()));
- }
- }
-
- protected void viewLog(java.awt.event.ActionEvent evt) {
- int i = tableJobs.getSelectedRow();
- if (i >= 0) {
- SimulationJob job = modelJobs.getJob(i);
- String id = job.getItem().getControl().getId();
- try {
- SimulationLoggerUtil.showSimulationLogConsole(id);
- } catch (Exception eee) {
- UserLog.error(_("Can't open log for %s", id), eee);
- }
- }
- }
-
- protected void clearDoneJobs(java.awt.event.ActionEvent evt) {
- SimulationService ss = SimulationService.getService();
- ss.clearJobDone();
- }
-
- protected void initComponents() {
- bindingGroup = new BindingGroup();
-
- tableJobsScroll = new javax.swing.JScrollPane();
- tableJobs = new javax.swing.JTable();
- tableJobDonesScroll = new javax.swing.JScrollPane();
- tableJobDones = new javax.swing.JTable();
- autoLaunchButton = new javax.swing.JToggleButton();
- stopSimuButton = new javax.swing.JButton();
- showLogButton = new javax.swing.JButton();
- clearDoneJobsButton = new javax.swing.JButton();
-
- tableJobsScroll.setViewportView(tableJobs);
-
- tableJobDonesScroll.setViewportView(tableJobDones);
-
- autoLaunchButton.setText(_("Auto Launch"));
-
- Binding binding = Bindings.createAutoBinding(
- AutoBinding.UpdateStrategy.READ_WRITE,
- SimulationService.getService(), ELProperty.create("${autoLaunch}"),
- autoLaunchButton, BeanProperty.create("selected"));
- bindingGroup.addBinding(binding);
-
- stopSimuButton.setText(_("Stop simulation"));
-
- binding = Bindings.createAutoBinding(
- AutoBinding.UpdateStrategy.READ,
- tableJobs, ELProperty.create("${selectedElement != null}"),
- stopSimuButton, BeanProperty.create("enabled"));
- binding.setSourceNullValue(false);
- binding.setSourceUnreadableValue(false);
- bindingGroup.addBinding(binding);
-
- stopSimuButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- stopSimulation(evt);
- }
- });
-
- showLogButton.setText(_("View log"));
-
- binding = Bindings.createAutoBinding(
- AutoBinding.UpdateStrategy.READ,
- tableJobDones, ELProperty.create("${selectedElement != null}"),
- showLogButton, BeanProperty.create("enabled"));
- binding.setSourceNullValue(false);
- binding.setSourceUnreadableValue(false);
- bindingGroup.addBinding(binding);
-
- showLogButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- viewLog(evt);
- }
- });
-
- clearDoneJobsButton.setText(_("Clear done jobs"));
-
- clearDoneJobsButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- clearDoneJobs(evt);
- }
- });
-
- GroupLayout layout = new GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(12, 12, 12)
- .addComponent(autoLaunchButton)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(stopSimuButton)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(showLogButton)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(clearDoneJobsButton))
- .addComponent(tableJobDonesScroll, GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
- .addComponent(tableJobsScroll, GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(tableJobsScroll, GroupLayout.PREFERRED_SIZE, 140, Short.MAX_VALUE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(tableJobDonesScroll, GroupLayout.PREFERRED_SIZE, 140, Short.MAX_VALUE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(autoLaunchButton)
- .addComponent(stopSimuButton)
- .addComponent(showLogButton)
- .addComponent(clearDoneJobsButton))
- .addContainerGap())
- );
-
- bindingGroup.bind();
- }
-
- protected SimulationServiceTableModel modelJobs;
- protected SimulationServiceTableModel modelJobDones;
- protected javax.swing.JToggleButton autoLaunchButton;
- protected javax.swing.JButton stopSimuButton;
- protected javax.swing.JButton showLogButton;
- protected javax.swing.JButton clearDoneJobsButton;
- protected javax.swing.JTable tableJobDones;
- protected javax.swing.JScrollPane tableJobDonesScroll;
- protected javax.swing.JTable tableJobs;
- protected javax.swing.JScrollPane tableJobsScroll;
- private org.jdesktop.beansbinding.BindingGroup bindingGroup;
-
-}
Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorAction.java 2008-10-17 14:57:40 UTC (rev 1565)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulatorAction.java 2008-10-17 14:58:29 UTC (rev 1566)
@@ -1,372 +0,0 @@
-/* *##%
- * Copyright (C) 2006
- * Ifremer, Code Lutin, C?dric Pineau, Benjamin Poussin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * SimulatorAction.java
- *
- * Created: 7 juil. 2006 12:19:06
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package fr.ifremer.isisfish.ui.simulator;
-
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
-import fr.ifremer.isisfish.datastore.ExportStorage;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.RuleStorage;
-import fr.ifremer.isisfish.datastore.ScriptStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import static fr.ifremer.isisfish.datastore.SimulationStorage.getSimulation;
-import static fr.ifremer.isisfish.datastore.SimulationStorage.getSimulationNames;
-import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
-import fr.ifremer.isisfish.simulator.SimulationException;
-import fr.ifremer.isisfish.simulator.SimulationParameter;
-import fr.ifremer.isisfish.simulator.SimulationProperties;
-import fr.ifremer.isisfish.simulator.launcher.SimulationService;
-import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher;
-import fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil;
-import fr.ifremer.isisfish.ui.widget.filter.FilterModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.codelutin.i18n.I18nf._;
-import org.codelutin.topia.TopiaContext;
-import org.swixat.framework.AbstractFrame;
-import org.swixat.framework.OutputView;
-import org.swixat.model.Context;
-
-import javax.swing.*;
-import javax.swing.table.TableModel;
-import java.lang.reflect.Field;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.codelutin.log.UserLog;
-
-
-/**
- * @author poussin
- */
-
-public class SimulatorAction {
- static private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SimulatorAction.class);
-
- static public Object opened(Context uiContext, AbstractFrame frame,
- TopiaContext isisContext, JTabbedPane tabs,
-// JButton start, JButton remove,JButton showLog,
-// JTable table,JTable tableDone,
- JButton removeAnalysePlan,
- JList listAnalysePlan,
- JButton removeRule,
- JList listRule) {
- log.debug("call opened " + isisContext);
- try {
- SimulationParameter param = new SimulationParameter();
-
- // TODO refresh data context on all this when datas coming from script module
- // when a modification is done in script dialog
- // => then refresh whoses data
- // and the associated ui
- // compute result names available
- List<String> resultNames = getResultNames();
- uiContext.setData("ResultNames", resultNames);
- uiContext.setData("ExportNames", ExportStorage.getExportNames());
- uiContext.setData("AnalysePlanNames", AnalysePlanStorage.getAnalysePlanNames());
- uiContext.setData("RuleNames", RuleStorage.getRuleNames());
-
- // put default value in param
- param.setSimulatorName(IsisFish.config.getSimulatorClassfile());
- param.setTagValue(IsisFish.config.getDefaultTagValueAsMap());
- param.setExportDirectory(IsisFish.config.getDefaultExportDirectory().toString());
- param.setExportNames(IsisFish.config.getDefaultExportNamesAsList());
- List<String> defaultResultNames = IsisFish.config.getDefaultResultNamesAsList();
- if (defaultResultNames != null)
- param.setResultEnabled(defaultResultNames);
- else
- param.setResultEnabled(resultNames);
-
- uiContext.setData("OldSimulationName", "");
- uiContext.setData("SimulationParameter", param);
-
- // keep in context list of old simulation names (for filter process)
- List<String> value = getSimulationNames();
- // create filter model
- FilterModel<SimulationProperties, String> model =
- SimulationFilterUtil.createFilterModel(value);
- // to used directly model.getFilteredResult() in xml
- // we must fill filterModel result with original items
- model.selectAll();
- uiContext.setData("SimulationFilterModel", model);
-
- tabs.setEnabledAt(1, false); // disable prescript tab
- tabs.setEnabledAt(2, false); // disable analyse plan tab
-
-// // add simulation queue button listeners
-// SimulatorListeners.initSimulQueueButtonsListener(
-// start,
-// remove,
-// showLog,
-// table,
-// tableDone
-// );
- // add rule around button listeners
- SimulatorListeners.initButtonRemoveIfItemSelected(removeRule, listRule);
-
- // add analyse plan around button listeners
- SimulatorListeners.initButtonRemoveIfItemSelected(removeAnalysePlan, listAnalysePlan);
-
- frame.refreshView();
- } catch (Exception eee) {
- log.error("Can't init SimulationParameter", eee);
- return new OutputView("Error.xml", "error", eee.getMessage());
- }
- return null;
- }
-
- /**
- * 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
- */
- static private 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);
- }
- }
- return result;
- }
-
- /**
- * Change region in simulation launcher
- *
- * @param uiContext swixat context
- * @param frame swixat frame
- * @param simulationName name of simulation to load
- * @return <code>null</code> if ok, an OutputView otherwise with error
- */
- static public Object loadOldSimulation(Context uiContext, AbstractFrame frame,
- String simulationName) {
- log.debug("call loadOldSimulation: " + simulationName);
- try {
- frame.setInfoText(_("isisfish.message.loading.old.simulation"));
-
- SimulationStorage storage = getSimulation(simulationName);
- uiContext.setData("OldSimulationName", storage.getName());
-
- SimulationParameter param = storage.getParameter().copy();
- // all time reset number after load
- param.setAnalysePlanNumber(-1);
- uiContext.setData("SimulationParameter", param);
-
- RegionStorage region = param.getRegion();
- uiContext.setData("RegionStorage", region);
-
- frame.refreshView();
-
- JTabbedPane tab = (JTabbedPane) uiContext.getWidget("simulTabs");
- tab.setEnabledAt(1, param.getUsePreScript());
- tab.setEnabledAt(2, param.getUseAnalysePlan());
-
- frame.setInfoText(_("isisfish.message.old.simulation.loaded"));
- } catch (Exception eee) {
- log.error("Can't load old Simulation: " + simulationName, eee);
- return new OutputView("Error.xml", "error", eee.getMessage());
- }
- return null;
- }
-
- /**
- * Change region in simulation launcher
- *
- * @param uiContext swixat context
- * @param frame swixat frame
- * @param param simulation parameter to use
- * @param regionName SimulationParameter/description * @return
- * @return <code>null</code> if ok, an OutputView otherwise with error
- */
- static public Object loadRegion(Context uiContext, AbstractFrame frame,
- SimulationParameter param, String regionName) {
- log.debug("call loadRegion: " + regionName);
- try {
- frame.setInfoText(_("isisfish.message.loading.region"));
-
- RegionStorage storage = RegionStorage.getRegion(regionName);
- uiContext.setData("RegionStorage", storage);
- param.setRegionName(regionName);
-
- // change Region, we must init some list
- param.setPopulations(null);
- param.setRules(null);
- param.setStrategies(null);
-
- frame.refreshView();
- frame.setInfoText(_("isisfish.message.region.loaded"));
- } catch (Exception eee) {
- log.error("Can't load region: " + regionName, eee);
- return new OutputView("Error.xml", "error", eee.getMessage());
- }
- return null;
- }
-
- /**
- * Launch automaticaly the simulation, when is possible (no other simulation)
- * or wait for the last automaticaly simulation ended.
- *
- * @param uiContext swixat context
- * @param frame swixat frame
- * @param simulId id of the simulation to simulate
- * @param param paramters of the simulation
- * @param tabs the tabs
- * @param inQueue flag to say put in queue
- * @return <code>null</code> if ok, an OutputView otherwise with error
- */
- static public Object simulate(Context uiContext, AbstractFrame frame,
- String simulId, SimulationParameter param,
- boolean inQueue, JTabbedPane tabs,
- SimulatorLauncher launcher) {
- log.debug("call simulate");
- try {
- uiContext.setData("SimulationLaunched", false);
-
- simulId += " " + dateFormat.format(new java.util.Date());
-
- if (simulId == null || "".equals(simulId) ||
- SimulationStorage.localyExists(simulId) ||
- SimulationService.getService().exists(simulId)) {
- UserLog.error(_("Can't start simulation, bad id: %s", simulId));
- } else {
- SimulationParameter p = param.copy();
-
- SimulationService.getService().submit(simulId, p, launcher, 0);
-
- selectTab(tabs, true, 6);
- }
- } catch (Exception eee) {
- log.error("Can't start simulation", eee);
- return new OutputView("Error.xml", "error", eee.getMessage());
- }
- return null;
- }
-
- /**
- * Save simulator name and local/remote choice in user preference
- *
- * @param simulatorName name of simulator
- * @param local <code>true</code> to use local simulator
- */
- static public void saveSimulatorChoice(String simulatorName, boolean local) {
- IsisFish.config.setSimulatorClassfile(simulatorName);
- IsisFish.config.setSimulatorLauncher(local?"local":"isis-server");
- }
-
- static public void saveExport(String exportDirectory, List<String> exportNames) {
- IsisFish.config.setDefaultExportDirectory(exportDirectory);
- IsisFish.config.setDefaultExportNames(exportNames);
- }
-
- static public void saveResultNames(List<String> resultNames) {
- IsisFish.config.setDefaultResultNames(resultNames);
- }
-
- static public void saveTagValue(Map<String, String> tagValues) {
- log.debug("call saveTagValue: " + tagValues);
- IsisFish.config.setDefaultTagValues(tagValues);
- }
-
- static public void addTagValue(SimulationParameter param, String tag, String value) {
- param.getTagValue().put(tag, value);
- }
-
- static public void removeTagValue(SimulationParameter param, String tag) {
- log.debug("removeTagValue: " + tag);
- param.getTagValue().remove(tag);
- }
-
- static public void selectTab(JTabbedPane tabs, boolean mustGo, int tabIndex) {
- log.debug("selectTab: " + mustGo + " index: " + tabIndex);
- if (mustGo) {
- tabs.setSelectedIndex(tabIndex);
- }
- }
-
- @SuppressWarnings({"UnusedDeclaration"})
- static public void refreshRule(Context uiContext, AbstractFrame frame,
- JTable table) {
- // we must first loose focus from table
- //TODO No! we must fix bug on columnEditor : when focus lost, should
- //TODO stop editing
- frame.refreshView("simulParamsRules");
- }
-
- /**
- *
- * @param uiContext swiwat context
- * @param frame swixat frame
- * @param table the done simulation table
- * @param model the done simulation table model
- * @param selected state of the button clicked
- * @return <code>null</code> if ok, an OutputView otherwise with error
- */
- @SuppressWarnings({"UnusedDeclaration"})
- static public Object showLog(Context uiContext, AbstractFrame frame,
- JTable table, TableModel model,int selected) {
- try {
- if (selected<0 || model==null) return null;
-
- // obtain the name of selected simulation
- String id = (String) model.getValueAt(selected,0);
-
- // check if not a simulation with anaylse plans
- Object analyzePlan = model.getValueAt(selected,1);
-
- if (analyzePlan instanceof Integer) {
- // we have a simulation with anaylse
- //TODO Make a ui to ask user which anaylyse to see
- id = id+"_0";
- }
- // launch log console
- SimulationLoggerUtil.showSimulationLogConsole(id);
- } catch (Exception e) {
- // ignore ?
- return new OutputView("Error.xml", "error", e.getMessage());
- }
- return null;
- }
-
-} //SimulatorAction
1
0
r1565 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: simulator widget/editor
by sletellier@users.labs.libre-entreprise.org 17 Oct '08
by sletellier@users.labs.libre-entreprise.org 17 Oct '08
17 Oct '08
Author: sletellier
Date: 2008-10-17 14:57:40 +0000 (Fri, 17 Oct 2008)
New Revision: 1565
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterCellEditor.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ToolTipListModelFactory.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java
Log:
Simulation completed
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -33,6 +33,9 @@
<Table>
<script>
<![CDATA[
+ import javax.swing.table.DefaultTableModel;
+ import java.util.Map.Entry;
+
fieldSimulationStatistique.setSelected(getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic());
fieldSimulationCache.setSelected(getContextValue(SimulAction.class).getSimulationParameter().getUseOptimization());
fieldSimulAdvParamsSimulLoggerError.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isSimulErrorLevel());
@@ -47,15 +50,18 @@
fieldSimulAdvParamsLibLoggerWarn.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibWarnLevel());
fieldSimulAdvParamsLibLoggerInfo.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibErrorLevel());
fieldSimulAdvParamsLibLoggerDebug.setSelected(getContextValue(SimulAction.class).getSimulationParameter().isLibDebugLevel());
+ setTableTagValue();
public AdvancedParamsUI (SimulAction action){
setContextValue(action);
}
protected void addTagValue(){
getContextValue(SimulAction.class).addTagValue(fieldTag.getText(), fieldValue.getText());
+ setTableTagValue();
}
protected void removeTagValue(){
getContextValue(SimulAction.class).removeTagValue(tableTagValue.getValueAt(tableTagValue.getSelectedRow(),0).toString());
+ setTableTagValue();
}
protected void saveTagValue(){
if (fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1){
@@ -67,6 +73,32 @@
getContextValue(SimulAction.class).getSimulationParameter().setSimulatorName(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
}
}
+ protected void setTableTagValue(){
+ Map<String, String> tagValue = getContextValue(SimulAction.class).getSimulationParameter().getTagValue();
+ if (tagValue!=null){
+ String columnName[] = {"Tag", "Value"};
+ DefaultTableModel model = new DefaultTableModel(columnName, tagValue.size()){
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ boolean result = false;
+ return result;
+ }
+ };
+ Set<Entry<String, String>> set = tagValue.entrySet();
+ int row = 0;
+ for (Iterator<String> it = tagValue.keySet().iterator(); it.hasNext();) {
+ String name = it.next();
+ model.setValueAt(name, row, 0);
+ model.setValueAt(tagValue.get(name), row, 1);
+ row++;
+ }
+ tableTagValue.setModel(model);
+ }
+ else {
+ String columnName[] = {"Tag", "Value"};
+ DefaultTableModel model = new DefaultTableModel(columnName, 0);
+ }
+ }
]]>
</script>
<row>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -33,24 +33,27 @@
<Table>
<script><![CDATA[
- fieldSimulExportFolder.setText(getContextValue(SimulAction.class).getSimulationParameter().getExportDirectory());
+ update();
public ExportUI (SimulAction action){
setContextValue(action);
}
+ protected void update(){
+ if (listSimulExportChoose.getSelectedIndex() > -1){
+ Object[] values = listSimulExportChoose.getSelectedValues();
+ java.util.List<String> exportNames = new LinkedList<String>();
+ for (Object o : values){
+ exportNames.add((String) o);
+ }
+ getContextValue(SimulAction.class).getSimulationParameter().setExportNames(exportNames);
+ }
+ fieldSimulExportFolder.setText(getContextValue(SimulAction.class).getSimulationParameter().getExportDirectory());
+ }
]]>
</script>
<row>
<cell columns="4" fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
- <JList id="listSimulExportChoose" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getExportNames().toArray())}'>
-<!-- Fixme : ListModel
- <ListModel origin="$ExportNames"/>
- <ListSelectionEvents onValueChanged="Update($listSimulExportChoose/selectedValues, $SimulationParameter/exportNames)"/>
- <ListRenderer>
- <SimpleToolTipListRenderer origin='fr.ifremer.isisfish.ui.simulator.ToolTipListModelFactory.createExportClassDocsModel($ExportNames)'/>
- </ListRenderer>
--->
- </JList>
+ <JList id="listSimulExportChoose" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getExportNames().toArray())}' onValueChanged='update()'/>
</JScrollPane>
</cell>
</row>
@@ -59,21 +62,14 @@
<JLabel text="isisfish.export.directory"/>
</cell>
<cell fill="horizontal" weightx="1.0">
- <JTextField id="fieldSimulExportFolder"/>
+ <JTextField id="fieldSimulExportFolder" onFocusLost='update()'/>
</cell>
<cell>
<JButton text="isisfish.common.ellipsis" onActionPerformed='getContextValue(SimulAction.class).updateDirectory()'/>
-<!--
-actionCommand="update(org.codelutin.util.FileUtil.getDirectory(), $SimulationParameter/exportDirectory);refreshView($fieldSimulExportFolder)"
--->
</cell>
<cell>
<JButton text="isisfish.common.saveNextSimulation" onActionPerformed='getContextValue(SimulAction.class).saveExport()'/>
</cell>
</row>
-
-<!--
-actionCommand="simulator.SimulatorAction.saveExport($SimulationParameter/exportDirectory, $SimulationParameter/exportNames)"
--->
</Table>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -41,18 +41,44 @@
import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher;
import fr.ifremer.isisfish.entities.Strategy;
import fr.ifremer.isisfish.entities.Population;
+ import fr.ifremer.isisfish.rule.Rule;
+ import org.codelutin.math.matrix.gui.MatrixPanelEditor;
+ import javax.swing.table.DefaultTableModel;
+ import javax.swing.table.TableModel;
+ import fr.ifremer.isisfish.ui.widget.editor.ParameterColumnEditor;
+ import javax.swing.table.TableColumn;
+import fr.ifremer.isisfish.ui.widget.editor.ParameterCellEditor;
+
+ setContextValue(new MatrixPanelEditor());
+ simulParamsNumbers.add(getContextValue(MatrixPanelEditor.class), BorderLayout.CENTER);
public ParamsUI(SimulAction action){
setContextValue(action);
}
+ protected void refresh(){
+ if (getContextValue(SimulAction.class).getSimulationStorage() != null){
+ fieldSimulParamsName.setText(getContextValue(SimulAction.class).getSimulationStorage().getName());
+ }
+ fieldSimulParamsDesc.setText(getContextValue(SimulAction.class).getSimulationParameter().getDescription());
+ setListSimulParamsStrategiesItems();
+ setListSimulParamsPopulationsItems();
+ setRulesItems();
+ fieldSimulParamsRegion.setSelectedItem(getContextValue(SimulAction.class).getSimulationParameter().getRegionName());
+ if (getContextValue(SimulAction.class).getSimulationParameter().getUsePreScript()){
+ SimulUI simul = getParentContainer(SimulUI.class);
+ simul.enablePreSimul();
+ }
+ if (getContextValue(SimulAction.class).getSimulationParameter().getUseAnalysePlan()){
+ SimulUI simul = getParentContainer(SimulUI.class);
+ simul.enableAnalysePlan();
+ }
+ }
protected void regionChange(){
WelcomePanelUI root = getParentContainer(WelcomePanelUI.class);
root.setInfoText(_("isisfish.message.loading.region"));
getContextValue(SimulAction.class).regionChange(fieldSimulParamsRegion.getSelectedItem().toString());
- setListSimulParamsStrategiesItems();
- setListSimulParamsPopulationsItems();
+ refresh();
root.setInfoText(_("isisfish.message.region.loaded"));
}
-
public void setSimulationParameter(SimulAction simulAction){
getContextValue(SimulAction.class).setSimulationParameter(simulAction.getSimulationParameter());
}
@@ -65,31 +91,20 @@
if (eee != null){
// new OutputView("Error.xml", "error", eee.getMessage());
}
- fieldSimulParamsName.setText(getContextValue(SimulAction.class).getSimulationStorage().getName());
- fieldSimulParamsDesc.setText(getContextValue(SimulAction.class).getSimulationParameter().getDescription());
- setListSimulParamsStrategiesItems();
- setListSimulParamsPopulationsItems();
- if (getContextValue(SimulAction.class).getSimulationParameter().getUsePreScript()){
- SimulUI simul = getParentContainer(SimulUI.class);
- simul.enablePreSimul();
- }
- if (getContextValue(SimulAction.class).getSimulationParameter().getUseAnalysePlan()){
- SimulUI simul = getParentContainer(SimulUI.class);
- simul.enableAnalysePlan();
- }
+ refresh();
root.setInfoText(_("isisfish.message.old.simulation.loaded"));
}
protected void addRules(){
getContextValue(SimulAction.class).addRules(fieldSimulParamsMesuresSelect.getSelectedItem().toString());
- listSimulParamsMesuresList.setListData(getContextValue(SimulAction.class).getRules().toArray());
+ setRulesItems();
}
protected void removeRules(){
getContextValue(SimulAction.class).removeRules(listSimulParamsMesuresList.getSelectedValue().toString());
- listSimulParamsMesuresList.setListData(getContextValue(SimulAction.class).getRules().toArray());
+ setRulesItems();
}
protected void clearRules(){
getContextValue(SimulAction.class).getSimulationParameter().clearRules();
- listSimulParamsMesuresList.setListData(getContextValue(SimulAction.class).getRules().toArray());
+ setRulesItems();
}
protected void simul(){
getContextValue(SimulAction.class).simul(fieldSimulParamsName.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem());
@@ -118,6 +133,14 @@
listSimulParamsStrategiesModel.addElement(s);
}
listSimulParamsStrategies.setModel(listSimulParamsStrategiesModel);
+ java.util.List<Strategy> strategiesSelected = getContextValue(SimulAction.class).getSimulationParameter().getStrategies();
+ int[] indexs = new int[listSimulParamsStrategiesModel.size()];
+ int i = 0;
+ for (Strategy s : strategiesSelected){
+ indexs[i] = listSimulParamsStrategiesModel.indexOf(s);
+ i++;
+ }
+ listSimulParamsStrategies.setSelectedIndices(indexs);
}
protected void setListSimulParamsPopulationsItems(){
DefaultListModel listSimulParamsPopulationsModel = new DefaultListModel();
@@ -126,8 +149,84 @@
listSimulParamsPopulationsModel.addElement(p);
}
listSimulParamsPopulations.setModel(listSimulParamsPopulationsModel);
- //listSimulParamsPopulations.setListData(getContextValue(SimulAction.class).getPopulations().toArray());
+ java.util.List<Population> populationsSelected = getContextValue(SimulAction.class).getSimulationParameter().getPopulations();
+ int[] indexs = new int[listSimulParamsPopulationsModel.size()];
+ int i = 0;
+ for (Population p : populationsSelected){
+ indexs[i] = listSimulParamsPopulationsModel.indexOf(p);
+ i++;
+ }
+ listSimulParamsPopulations.setSelectedIndices(indexs);
+ populationSelected();
}
+ protected void setRulesItems(){
+ listSimulParamsMesuresList.setListData(getContextValue(SimulAction.class).getRules().toArray());
+ setRulesButton();
+ }
+ protected void populationSelected(){
+ if (listSimulParamsPopulations.getSelectedIndex() != -1){
+ getContextValue(SimulAction.class).setPopulations(listSimulParamsPopulations.getSelectedValues());
+ getContextValue(MatrixPanelEditor.class).setMatrix(getContextValue(SimulAction.class).getSimulationParameter().getNumberOf((Population) listSimulParamsPopulations.getSelectedValue()));
+ }
+ }
+ protected void strategySelected(){
+ getContextValue(SimulAction.class).setStrategies(listSimulParamsStrategies.getSelectedValues());
+ }
+ protected void saveDescription(){
+ getContextValue(SimulAction.class).getSimulationParameter().setDescription(fieldSimulParamsDesc.getText());
+ }
+ protected void setRulesButton(){
+ if (getContextValue(SimulAction.class).getRules().toArray().length == 0){
+ buttonSimulParamsMesuresClear.setEnabled(false);
+ buttonSimulParamsMesuresRemove.setEnabled(false);
+ }
+ else{
+ if (listSimulParamsMesuresList.getSelectedIndex() != -1){
+ buttonSimulParamsMesuresRemove.setEnabled(true);
+ setSimulParamsRulesModel();
+ }
+ buttonSimulParamsMesuresClear.setEnabled(true);
+ }
+ }
+ protected void setSimulParamsRulesModel(){
+ DefaultTableModel model = new DefaultTableModel();
+ Map<String, Class> values;
+ if (listSimulParamsMesuresList.getSelectedIndex() != -1){
+ values = getContextValue(SimulAction.class).getRuleParameterName(listSimulParamsMesuresList.getSelectedValue().toString());
+ int row = 0;
+ model = new DefaultTableModel(values.size(), 2){
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ boolean result = false;
+ if (column > 0){
+ result =true;
+ }
+ return result;
+ }
+ };
+ for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) {
+ String name = it.next();
+ Object properties = getContextValue(SimulAction.class).getRuleParameterValue(name, listSimulParamsMesuresList.getSelectedValue().toString());
+ ParameterCellEditor value = new ParameterCellEditor(name, values.get(name));
+ model.setValueAt(value, row, 0);
+ model.setValueAt(properties, row, 1);
+ row++;
+ }
+ }
+ simulParamsRules.setModel(model);
+ ParameterColumnEditor cellEditor = new ParameterColumnEditor();
+ cellEditor.setRegion(getContextValue(SimulAction.class).getRegionStorage());
+ simulParamsRules.getColumnModel().getColumn(1).setCellEditor(cellEditor);
+ simulParamsRules.getModel().addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ int row = e.getFirstRow();
+ TableModel model = (TableModel)e.getSource();
+ ParameterCellEditor data = (ParameterCellEditor) model.getValueAt(row, 0);
+ getContextValue(SimulAction.class).setRuleParameterValue(data.getName(), listSimulParamsMesuresList.getSelectedValue().toString(), model.getValueAt(row, 1));
+ }
+ });
+ }
]]>
</script>
<row>
@@ -198,7 +297,7 @@
<row>
<cell columns="4" fill="both" weightx="1.0" weighty="0.3">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JTextArea id="fieldSimulParamsDesc" text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}'/>
+ <JTextArea id="fieldSimulParamsDesc" text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' onFocusLost='saveDescription()'/>
</JScrollPane>
</cell>
</row>
@@ -230,10 +329,7 @@
<row>
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="listSimulParamsStrategies" selectionMode="2"/>
-<!--
- model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getStrategies().toArray())}'
- -->
+ <JList id="listSimulParamsStrategies" selectionMode="2" onFocusLost='strategySelected()'/>
</JScrollPane>
</cell>
</row>
@@ -249,10 +345,7 @@
<row>
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="listSimulParamsPopulations" selectionMode="2"/>
-<!--
- model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getPopulations().toArray())}'
- -->
+ <JList id="listSimulParamsPopulations" selectionMode="2" onMouseClicked='populationSelected()'/>
</JScrollPane>
</cell>
</row>
@@ -268,25 +361,13 @@
<row>
<cell fill="horizontal">
<!-- TODO : Render -->
- <JComboBox id="fieldSimulParamsMesuresSelect" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getRuleNames().toArray())}'
- onActionPerformed='buttonSimulParamsMesuresRemove.setEnabled(true)'/>
-<!--
- setToolTipRenderContext();
- private void setToolTipRenderContext(){
- ToolTipComboBoxRenderer2 render = new ToolTipComboBoxRenderer2();
- render.setModel(ToolTipListModelFactory.createRuleDescriptionsModel(RuleStorage.getRuleNames()));
- setContextValue(render);
- }
-
- renderer='{getContextValue(ToolTipComboBoxRenderer2.class)}'
-<SimpleToolTipComboBoxRenderer origin='fr.ifremer.isisfish.ui.simulator.ToolTipListModelFactory.createRuleDescriptionsModel($RuleNames)'/>
--->
+ <JComboBox id="fieldSimulParamsMesuresSelect" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getRuleNames().toArray())}'/>
</cell>
</row>
<row>
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="listSimulParamsMesuresList" selectionMode="0" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulationParameter().getRules().toArray())}' onValueChanged='buttonSimulParamsMesuresClear.setEnabled(true)'/>
+ <JList id="listSimulParamsMesuresList" selectionMode="0" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getRules().toArray())}' onValueChanged='setRulesButton()'/>
</JScrollPane>
</cell>
</row>
@@ -326,7 +407,7 @@
<cell columns="4" fill="both" weightx="1.0" weighty="0.6">
<JTabbedPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<tab title='{_("isisfish.params.populationNumbers")}'>
- <!--JMatrixPanel id="simulParamsNumbers" name="isisfish.params.populationNumbers"/-->
+ <JPanel id="simulParamsNumbers" name="isisfish.params.populationNumbers" layout='{new BorderLayout()}'/>
</tab>
<tab title='{_("isisfish.params.ruleParameters")}'>
<JTable id="simulParamsRules" name="isisfish.params.ruleParameters">
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/PreScriptsUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -31,25 +31,21 @@
*/
-->
<JPanel id="simulPreScripts" layout='{new BorderLayout()}'>
-<script><![CDATA[
- public PreScriptsUI (SimulAction action){
- setContextValue(action);
- }
- ]]>
- </script>
-
+ <script><![CDATA[
+ public PreScriptsUI (SimulAction action){
+ setContextValue(action);
+ }
+ protected void save(){
+ getContextValue(SimulAction.class).getSimulationParameter().setPreScript(fieldSimulPreScript.getText());
+ }
+ protected void backParameter(){
+ SimulUI simul = getParentContainer(SimulUI.class);
+ simul.selTab(0);
+ }
+ ]]>
+ </script>
<JScrollPane constraints='BorderLayout.CENTER'>
- <JTextArea id="fieldSimulPreScript">
-<!-- Fixme : DocmumentEvents
-origin="$SimulationParameter/preScript"
- <DocumentEvents onModified="Update($fieldSimulPreScript/text, $SimulationParameter/preScript)"/>
--->
- </JTextArea>
+ <JTextArea id="fieldSimulPreScript" onFocusLost='save()'/>
</JScrollPane>
-
- <JButton constraints='BorderLayout.SOUTH' text="isisfish.preScript.backParameter"/>
-<!--
-actionCommand="simulator.SimulatorAction.selectTab($simulTabs, 'true', '0')"
--->
-
+ <JButton constraints='BorderLayout.SOUTH' text="isisfish.preScript.backParameter" onActionPerformed='backParameter()'/>
</JPanel>
\ No newline at end of file
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -51,8 +51,8 @@
SimulationService ss = SimulationService.getService();
BindingGroup bindingGroup = new BindingGroup();
- setContextValue(new SimulationServiceTableModel(ss, true), "done");
- setContextValue(new SimulationServiceTableModel(ss, false), "new");
+ setContextValue(new SimulationServiceTableModel(ss, true), "new");
+ setContextValue(new SimulationServiceTableModel(ss, false), "done");
queueTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
queueTableDone.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
queueTable.setDefaultRenderer(JProgressBar.class, new JProgressBarTableCellRenderer());
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -31,7 +31,7 @@
*/
-->
<JPanel id="ResultChoice" name="isisfish.resultChoice.title" layout='{new BorderLayout()}'>
-<script><![CDATA[
+ <script><![CDATA[
public ResultChoiceUI (SimulAction action){
setContextValue(action);
}
@@ -42,34 +42,11 @@
}
]]>
</script>
-
-<!-- Fixme : ContextDataSource
- <ContextDataSource id="ResultNames" context="current" source="ResultNames"/>
--->
- <!--
- |
- | Result enabled
- |
- +-->
-
- <JLabel text="isisfish.resultChoice.save" horizontalAlignment="0" constraints='BorderLayout.NORTH'/>
- <JScrollPane constraints='BorderLayout.CENTER'>
- <!--list id="listResultNames" SelectionMode="2" renderer="org.codelutin.i18n.I18n._(.)"-->
- <JList id="listResultNames" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getResultNames().toArray())}'>
-<!-- Fixme : ListModel, ListSelectionEvents and listRender
- origin="$SimulationParameter/resultEnabled"
- <ListModel origin="$ResultNames"/>
- <ListSelectionEvents onValueChanged="Update($listResultNames/selectedValues, $SimulationParameter/resultEnabled)"/>
- <ListRenderer>
- <SimpleToolTipListRenderer origin='fr.ifremer.isisfish.ui.simulator.ToolTipListModelFactory.createResultFieldsModel($ResultNames)'/>
- </ListRenderer>
--->
- </JList>
- </JScrollPane>
-
- <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation" onActionPerformed='saveResultNames()'/>
-<!--
- actionCommand="simulator.SimulatorAction.saveResultNames($listResultNames/selectedValues)"
--->
+ <JLabel text="isisfish.resultChoice.save" horizontalAlignment="0" constraints='BorderLayout.NORTH'/>
+ <JScrollPane constraints='BorderLayout.CENTER'>
+ <JList id="listResultNames" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getResultNames().toArray())}'>
+ </JList>
+ </JScrollPane>
+ <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation" onActionPerformed='saveResultNames()'/>
</JPanel>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2008-10-17 14:57:40 UTC (rev 1565)
@@ -33,47 +33,115 @@
<Table>
<script><![CDATA[
+ import javax.swing.DefaultComboBoxModel;
+ import javax.swing.table.DefaultTableModel;
+ import javax.swing.table.TableModel;
+ import fr.ifremer.isisfish.ui.widget.editor.ParameterColumnEditor;
+ import javax.swing.table.TableColumn;
+ import fr.ifremer.isisfish.ui.widget.editor.ParameterCellEditor;
+
public SensUI (SimulAction action){
setContextValue(action);
}
+ public void refresh(){
+ listSimulParamsAnalysePlansList.setModel(new DefaultComboBoxModel(getContextValue(SimulAction.class).getParamAnalysePlans().toArray()));
+ }
+ public void addAnalysePlan(){
+ getContextValue(SimulAction.class).addAnalysePlan(fieldSimulParamsAnalysePlansSelect.getSelectedItem().toString());
+ refresh();
+ }
+ public void removeAnalysePlan(){
+ getContextValue(SimulAction.class).removeAnalysePlan(fieldSimulParamsAnalysePlansSelect.getSelectedItem().toString());
+ refresh();
+ }
+ public void clearAnalysePlan(){
+ getContextValue(SimulAction.class).clearAnalysePlan();
+ refresh();
+ }
+ protected void setAnalysePlanButton(){
+ if (getContextValue(SimulAction.class).getParamAnalysePlans().toArray().length == 0){
+ buttonSimulParamsAnalysePlansClear.setEnabled(false);
+ buttonSimulParamsAnalysePlansRemove.setEnabled(false);
+ }
+ else{
+ if (listSimulParamsAnalysePlansList.getSelectedIndex() != -1){
+ buttonSimulParamsAnalysePlansRemove.setEnabled(true);
+ setSimulParamsAnalysePlans();
+ }
+ buttonSimulParamsAnalysePlansClear.setEnabled(true);
+ }
+ }
+ protected void setSimulParamsAnalysePlans(){
+ if (listSimulParamsAnalysePlansList.getSelectedIndex() != -1){
+ Map<String, Class> values = getContextValue(SimulAction.class).getAnalysePlanParameterName(listSimulParamsAnalysePlansList.getSelectedValue().toString());
+ int row = 0;
+ if (values != null){
+ DefaultTableModel model = new DefaultTableModel(values.size(), 2){
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ boolean result = false;
+ if (column > 0){
+ result =true;
+ }
+ return result;
+ }
+ };
+ for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) {
+ String name = it.next();
+ Object properties = getContextValue(SimulAction.class).getAnalysePlanParameterValue(name, listSimulParamsAnalysePlansList.getSelectedValue().toString());
+ ParameterCellEditor value = new ParameterCellEditor(name, values.get(name));
+ model.setValueAt(value, row, 0);
+ model.setValueAt(properties, row, 1);
+ row++;
+ }
+ simulParamsAnalysePlans.setModel(model);
+ ParameterColumnEditor cellEditor = new ParameterColumnEditor();
+ cellEditor.setRegion(getContextValue(SimulAction.class).getRegionStorage());
+ simulParamsAnalysePlans.getColumnModel().getColumn(1).setCellEditor(cellEditor);
+ simulParamsAnalysePlans.getModel().addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ int row = e.getFirstRow();
+ TableModel model = (TableModel)e.getSource();
+ ParameterCellEditor data = (ParameterCellEditor) model.getValueAt(row, 0);
+ getContextValue(SimulAction.class).setAnalysePlanParameterValue(data.getName(), listSimulParamsAnalysePlansList.getSelectedValue().toString(), model.getValueAt(row, 1));
+ }
+ });
+ }
+ }
+ }
+ protected void backParameter(){
+ SimulUI simul = getParentContainer(SimulUI.class);
+ simul.selTab(0);
+ }
]]>
</script>
<row>
<cell columns="2" fill="horizontal" weightx="1.0">
- <JComboBox id="fieldSimulParamsAnalysePlansSelect"/>
+ <JComboBox id="fieldSimulParamsAnalysePlansSelect" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getAnalysePlanNames().toArray())}'/>
</cell>
</row>
<row>
<cell fill="both" weightx="0.5">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="listSimulParamsAnalysePlansList" selectionMode="0"/>
+ <JList id="listSimulParamsAnalysePlansList" selectionMode="0" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getParamAnalysePlans().toArray())}' onValueChanged='setAnalysePlanButton()'/>
</JScrollPane>
</cell>
<cell fill="both" weightx="0.5">
<Table id="simulSens" name="isisfish.sens.title">
<row>
<cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsAnalysePlansAdd" text="isisfish.common.add"/>
-<!--
-actionCommand="xpath:addAnalysePlan($SimulationParameter, getNewAnalysePlanInstance(fr.ifremer.isisfish.datastore.AnalysePlanStorage.getAnalysePlan($fieldSimulParamsAnalysePlansSelect/selectedItem)));refreshView($listSimulParamsAnalysePlansList)"
--->
+ <JButton id="buttonSimulParamsAnalysePlansAdd" text="isisfish.common.add" onActionPerformed='addAnalysePlan()'/>
</cell>
</row>
<row>
<cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsAnalysePlansRemove" text="isisfish.common.remove"/>
-<!--
- actionCommand="xpath:removeAnalysePlan($SimulationParameter, $listSimulParamsAnalysePlansList/selectedValue);refreshView($listSimulParamsAnalysePlansList)"
--->
+ <JButton id="buttonSimulParamsAnalysePlansRemove" text="isisfish.common.remove" onActionPerformed='removeAnalysePlan()' enabled='false'/>
</cell>
</row>
<row>
<cell fill="both" weightx="1.0">
- <JButton id="buttonSimulParamsAnalysePlansClear" text="isisfish.common.clear"/>
-<!--
-actionCommand="xpath:clearPlans($SimulationParameter);refreshView($listSimulParamsAnalysePlansList,$simulParamsAnalysePlans)"
--->
- <!--TODO Doest not work! when calling use an AbstractCollection with no clear implementation text="Clear" actionCommand="xpath:clear($SimulationParameter/analysePlans);refreshView($listSimulParamsAnalysePlansList)"/>-->
+ <JButton id="buttonSimulParamsAnalysePlansClear" text="isisfish.common.clear" onActionPerformed='clearAnalysePlan()' enabled='false'/>
</cell>
</row>
</Table>
@@ -82,35 +150,14 @@
<row>
<cell columns="2" fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
- <JTable id="simulParamsAnalysePlans" name="isisfish.sens.planParameters">
-<!-- Fixme : JTableModel
- <tableModel origin="fr.ifremer.isisfish.datastore.AnalysePlanStorage.getParameterNames($listSimulParamsAnalysePlansList/selectedValue)">
- <column title="Name" property="/" renderer="key">
- <tableColumnRenderer>
- <SimpleToolTipTableColumnRenderer origin='fr.ifremer.isisfish.ui.simulator.ToolTipListModelFactory.createAnalysePlanParamsModel($listSimulParamsAnalysePlansList/selectedValue)'/>
- </tableColumnRenderer>
- </column>
- <column title="Value" editable="true"
- property="fr.ifremer.isisfish.datastore.AnalysePlanStorage.getParameterValue($listSimulParamsAnalysePlansList/selectedValue, /key)"
- actionEdit="fr.ifremer.isisfish.datastore.AnalysePlanStorage.setParameterValue($listSimulParamsAnalysePlansList/selectedValue, $e/object/key, $e/value)">
- <tableColumnEditor><ParameterColumnEditor origin="$RegionStorage"/></tableColumnEditor>
- <tableColumnRenderer>
- <SimpleToolTipTableColumnRenderer origin=''/>
- </tableColumnRenderer>
- </column>
- </tableModel>
--->
- </JTable>
+ <JTable id="simulParamsAnalysePlans" name="isisfish.sens.planParameters"/>
</JScrollPane>
</cell>
</row>
<row>
<cell columns="2" fill="horizontal" weightx="1.0">
- <JButton text="isisfish.sens.backParameter"/>
+ <JButton text="isisfish.sens.backParameter" onActionPerformed='backParameter()'/>
</cell>
</row>
-<!--
-actionCommand="simulator.SimulatorAction.selectTab($simulTabs, 'true', '0')"
--->
</Table>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2008-10-17 14:57:40 UTC (rev 1565)
@@ -29,24 +29,22 @@
* by : $Author: sletellier $
*/
- /*
+/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-
/**
*
* @author letellier
*/
package fr.ifremer.isisfish.ui.simulator;
-import fr.ifremer.isisfish.datastore.StorageException;
import static org.codelutin.i18n.I18nf._;
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
@@ -56,6 +54,7 @@
import fr.ifremer.isisfish.entities.Strategy;
import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.simulator.AnalysePlan;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
@@ -64,6 +63,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -71,76 +71,47 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.log.UserLog;
-import org.codelutin.topia.TopiaContext;
public class SimulAction {
-
+
/** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SimulatorAction.class);
-
+ static private Log log = LogFactory.getLog(SimulAction.class);
protected SimulationParameter param = null;
protected RegionStorage regionStorage = null;
protected SimulationStorage simulStorage = null;
protected RuleStorage ruleStorage = null;
+ protected List<String> analysePlan = null;
protected Map<Rule, String> rules = new HashMap<Rule, String>();
+ protected Map<AnalysePlan, String> analysePlans = new HashMap<AnalysePlan, String>();
static private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
- public SimulAction(){
- param = new SimulationParameter();
-
- // TODO refresh data context on all this when datas coming from script module
- // when a modification is done in script dialog
- // => then refresh whoses data
- // and the associated ui
- // compute result names available
+
+/*
+ ************
+ * Init
+ ************
+ */
+
+ public SimulAction() {
+ log.debug("Init ");
+ try {
+ param = new SimulationParameter();
List<String> resultNames = getResultNames();
-// uiContext.setData("ResultNames", resultNames);
-// uiContext.setData("ExportNames", ExportStorage.getExportNames());
-// uiContext.setData("AnalysePlanNames", AnalysePlanStorage.getAnalysePlanNames());
-// uiContext.setData("RuleNames", RuleStorage.getRuleNames());
-
// put default value in param
param.setSimulatorName(IsisFish.config.getSimulatorClassfile());
param.setTagValue(IsisFish.config.getDefaultTagValueAsMap());
param.setExportDirectory(IsisFish.config.getDefaultExportDirectory().toString());
param.setExportNames(IsisFish.config.getDefaultExportNamesAsList());
+ analysePlan = AnalysePlanStorage.getAnalysePlanNames();
List<String> defaultResultNames = IsisFish.config.getDefaultResultNamesAsList();
- if (defaultResultNames != null)
+ if (defaultResultNames != null) {
param.setResultEnabled(defaultResultNames);
- else
+ } else {
param.setResultEnabled(resultNames);
-//
-// uiContext.setData("OldSimulationName", "");
-// uiContext.setData("SimulationParameter", param);
-//
-// // keep in context list of old simulation names (for filter process)
-// List<String> value = getSimulationNames();
-// // create filter model
-// FilterModel<SimulationProperties, String> model =
-// SimulationFilterUtil.createFilterModel(value);
-// // to used directly model.getFilteredResult() in xml
-// // we must fill filterModel result with original items
-// model.selectAll();
-// uiContext.setData("SimulationFilterModel", model);
-//
-// tabs.setEnabledAt(1, false); // disable prescript tab
-// tabs.setEnabledAt(2, false); // disable analyse plan tab
-//
-//// // add simulation queue button listeners
-//// SimulatorListeners.initSimulQueueButtonsListener(
-//// start,
-//// remove,
-//// showLog,
-//// table,
-//// tableDone
-//// );
-// // add rule around button listeners
-// SimulatorListeners.initButtonRemoveIfItemSelected(removeRule, listRule);
-//
-// // add analyse plan around button listeners
-// SimulatorListeners.initButtonRemoveIfItemSelected(removeAnalysePlan, listAnalysePlan);
-//
-// frame.refreshView();
-
+ }
+ }
+ catch (Exception eee) {
+ log.error("Can't init SimulationParameter", eee);
+ }
}
/**
@@ -166,7 +137,7 @@
}
return result;
}
-
+
protected void stopSimulation(SimulationJob job) {
job.stop();
log.info(_("User stop simulation %s", job.getItem().getControl().getId()));
@@ -180,26 +151,32 @@
UserLog.error(_("Can't open log for %s", id), eee);
}
}
-
+
protected void clearDoneJobs() {
SimulationService ss = SimulationService.getService();
- ss.clearJobDone();
+ ss.clearJobDone();
}
+
+ /**
+ * Change region in simulation launcher
+ *
+ * @param regionName SimulationParameter/description
+ */
public void regionChange(String regionName) {
regionStorage = RegionStorage.getRegion(regionName);
param.setRegionName(regionName);
- // change Region, we must init some list
- //param.setPopulations(null);
- //param.setRules(null);
- //param.setStrategies(null);
+ for (Rule r : param.getRules()) {
+ rules.put(r, RuleStorage.getName(r));
+ }
}
+
/**
* Change region in simulation launcher
*
* @param simulationName name of simulation to load
* @return <code>null</code> if ok, an OutputView otherwise with error
*/
- public Exception loadOldSimulation(String simulName) {
+ public void loadOldSimulation(String simulName) {
log.debug("call loadOldSimulation: " + simulName);
try {
simulStorage = SimulationStorage.getSimulation(simulName);
@@ -207,25 +184,20 @@
// all time reset number after load
param.setAnalysePlanNumber(-1);
regionStorage = param.getRegion();
- } catch (Exception eee) {
+ } catch (Exception eee) {
log.error("Can't load old Simulation: " + simulName, eee);
- return eee;
}
- return null;
}
- public SimulationParameter getSimulationParameter(){
- return param;
- }
- public void setSimulationParameter(SimulationParameter p){
- param = p;
- }
- public SimulationStorage getSimulationStorage(){
- return simulStorage;
- }
- public RegionStorage getRegionStorage(){
- return regionStorage;
- }
- public void addRules(String name){
+
+/*
+ ************
+ * ParamsUI
+ ************
+ */
+
+// Gestion des rules
+
+ public void addRules(String name) {
ruleStorage = RuleStorage.getRule(name);
try {
Rule ruleTmp = ruleStorage.getNewRuleInstance();
@@ -246,7 +218,7 @@
List<String> result = new ArrayList<String>();
for (Rule r : param.getRules()) {
try {
- result.add(rules.get(r));
+ result.add(RuleStorage.getName(r));
} catch (Exception ex) {
Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -258,27 +230,54 @@
for (Map.Entry<Rule, String> entry : rules.entrySet()) {
if (entry.getValue().equals(name)) {
param.removeRule(entry.getKey());
+ rules.remove(entry.getKey());
}
}
}
}
- public void simul(String simulId, SimulatorLauncher launcher) {
- simulId += " " + dateFormat.format(new java.util.Date());
-
- if (simulId == null || "".equals(simulId) ||
- SimulationStorage.localyExists(simulId) ||
- SimulationService.getService().exists(simulId)) {
- UserLog.error(_("Can't start simulation, bad id: %s", simulId));
- } else {
- SimulationParameter p = param.copy();
-
- SimulationService.getService().submit(simulId, p, launcher, 0);
+ public Rule getRule(String ruleName){
+ Rule r = null;
+ for (Map.Entry<Rule, String> entry : rules.entrySet()) {
+ if (entry.getValue().equals(ruleName)) {
+ r = entry.getKey();
}
+ }
+ return r;
}
- public List<SimulatorLauncher> getSimulationLauncher(){
- return SimulationService.getService().getSimulationLaunchers();
+ public Map<String, Class> getRuleParameterName(String ruleName) {
+ Map<String, Class> result = null;
+ if (ruleName != null) {
+ Rule r = getRule(ruleName);
+ if (r != null){
+ result = RuleStorage.getParameterNames(r);
+ }
+ }
+ return result;
}
- public List<Strategy> getStrategies(){
+ public Object getRuleParameterValue(String paramName, String ruleName){
+ Object result = null;
+ if (ruleName != null) {
+ try {
+ result = RuleStorage.getParameterValue(getRule(ruleName), paramName);
+ } catch (IsisFishException ex) {
+ Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return result;
+ }
+ public void setRuleParameterValue(String paramName, String ruleName, Object o){
+ if (ruleName != null) {
+ try {
+ RuleStorage.setParameterValue(getRule(ruleName), paramName, o);
+ } catch (IsisFishException ex) {
+ Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+// Strategies
+
+ public List<Strategy> getStrategies() {
List<Strategy> result = new ArrayList<Strategy>();
try {
result = RegionStorage.getFisheryRegion(param.getRegion().getStorage().beginTransaction()).getStrategy();
@@ -287,12 +286,23 @@
}
return result;
}
- public List<Population> getPopulations(){
+
+ public void setStrategies(Object[] strategies) {
+ List<Strategy> result = new ArrayList<Strategy>();
+ for (Object o : strategies) {
+ result.add((Strategy) o);
+ }
+ param.setStrategies(result);
+ }
+
+// Population
+
+ public List<Population> getPopulations() {
List<Species> species;
List<Population> result = new ArrayList<Population>();
try {
species = RegionStorage.getFisheryRegion(param.getRegion().getStorage().beginTransaction()).getSpecies();
- for (Species s : species){
+ for (Species s : species) {
result.addAll(s.getPopulation());
}
} catch (Exception ex) {
@@ -300,42 +310,201 @@
}
return result;
}
- public void setNbAnnees(String years){
+ public void setPopulations(Object[] populations) {
+ List<Population> result = new ArrayList<Population>();
+ for (Object o : populations) {
+ result.add((Population) o);
+ }
+ param.setPopulations(result);
+ }
+
+// Years
+
+ public void setNbAnnees(String years) {
param.setNumberOfYear(Integer.parseInt(years));
}
- public List<String> getSimulatorNames(){
+
+ public List<String> getSimulatorNames() {
return SimulatorStorage.getSimulatorNames();
}
- public void addTagValue(String tag, String value){
+
+/*
+ ************
+ * AdvancedParameterUI
+ ************
+ */
+
+ // Gestion des TagValues
+
+ public void addTagValue(String tag, String value) {
param.getTagValue().put(tag, value);
}
- public void removeTagValue(String tag){
+
+ public void removeTagValue(String tag) {
log.debug("removeTagValue: " + tag);
param.getTagValue().remove(tag);
}
- public void saveTagValue(String simulatorName){
+
+ public void saveTagValue(String simulatorName) {
Map<String, String> tagValues = param.getTagValue();
log.debug("call saveTagValue: " + tagValues);
IsisFish.config.setDefaultTagValues(tagValues);
-
+
IsisFish.config.setSimulatorClassfile(simulatorName);
- //IsisFish.config.setSimulatorLauncher(local?"local":"isis-server");
}
- public List<String> getExportNames(){
+/*
+ * ExportUI
+ */
+
+ public List<String> getExportNames() {
return ExportStorage.getExportNames();
}
- public void updateDirectory(){
- param.setExportDirectory(org.codelutin.util.FileUtil.getDirectory());
+
+ public void updateDirectory() {
+ param.setExportDirectory(org.codelutin.util.FileUtil.getDirectory());
}
- public void saveExport(){
+
+ public void saveExport() {
IsisFish.config.setDefaultExportDirectory(param.getExportDirectory());
- IsisFish.config.setDefaultExportNames(param.getExportNames());
+ if (param.getExportNames() != null){
+ IsisFish.config.setDefaultExportNames(param.getExportNames());
+ }
}
+
+/*
+ * ResultUI
+ */
+
public void saveResultNames(Object[] resultNames) {
List<String> resultNamesString = new ArrayList<String>();
- for (Object o : resultNames){
+ for (Object o : resultNames) {
resultNamesString.add(o.toString());
}
IsisFish.config.setDefaultResultNames(resultNamesString);
+ }
+
+/**
+ ************
+ * SensUI
+ ************
+ */
+
+// Gestion des analysePlans
+
+ public List<String> getAnalysePlanNames(){
+ return analysePlan;
}
+ public List<String> getParamAnalysePlans(){
+ List<String> result = new LinkedList<String>();
+ for (AnalysePlan a : param.getAnalysePlans()){
+ result.add(analysePlans.get(a));
+ }
+ return result;
+ }
+ public void addAnalysePlan(String name){
+ try {
+ AnalysePlan ap = AnalysePlanStorage.getAnalysePlan(name).getNewAnalysePlanInstance();
+ analysePlans.put(ap, name);
+ getSimulationParameter().addAnalysePlan(ap);
+ } catch (IsisFishException ex) {
+ Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ public void removeAnalysePlan(String name){
+ AnalysePlan ap = getAnalysePlan(name);
+ analysePlans.remove(ap);
+ getSimulationParameter().removeAnalysePlan(ap);
+ }
+ public void clearAnalysePlan(){
+ getSimulationParameter().clearPlans();
+ }
+ public AnalysePlan getAnalysePlan(String name){
+ AnalysePlan r = null;
+ for (Map.Entry<AnalysePlan, String> entry : analysePlans.entrySet()) {
+ if (entry.getValue().equals(name)) {
+ r = entry.getKey();
+ }
+ }
+ return r;
+ }
+ public Map<String, Class> getAnalysePlanParameterName(String analysePlanName) {
+ Map<String, Class> result = null;
+ if (analysePlanName != null) {
+ AnalysePlan a = getAnalysePlan(analysePlanName);
+ if (a != null){
+ result = AnalysePlanStorage.getParameterNames(a);
+ }
+ }
+ return result;
+ }
+ public Object getAnalysePlanParameterValue(String paramName, String analysePlanName){
+ Object result = null;
+ if (analysePlanName != null) {
+ try {
+ result = AnalysePlanStorage.getParameterValue(getAnalysePlan(analysePlanName), paramName);
+ } catch (IsisFishException ex) {
+ Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ return result;
+ }
+ public void setAnalysePlanParameterValue(String paramName, String analysePlanName, Object o){
+ if (analysePlanName != null) {
+ try {
+ AnalysePlanStorage.setParameterValue(getAnalysePlan(analysePlanName), paramName, o);
+ } catch (IsisFishException ex) {
+ Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+/*
+ ************
+ * 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();
+ }
+ /**
+ * Launch automaticaly the simulation, when is possible (no other simulation)
+ * or wait for the last automaticaly simulation ended.
+ *
+ * @param simulId id of the simulation to simulate
+ * @param inQueue flag to say put in queue
+ */
+ public void simul(String simulId, SimulatorLauncher launcher) {
+ simulId += " " + dateFormat.format(new java.util.Date());
+ log.debug("call simulate");
+ try {
+ if (simulId == null || "".equals(simulId) ||
+ SimulationStorage.localyExists(simulId) ||
+ SimulationService.getService().exists(simulId)) {
+ UserLog.error(_("Can't start simulation, bad id: %s", simulId));
+ } else {
+ SimulationParameter p = param.copy();
+
+ SimulationService.getService().submit(simulId, p, launcher, 0);
+ }
+ } catch (Exception eee) {
+ log.error("Can't start simulation", eee);
+ }
+ }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ToolTipListModelFactory.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ToolTipListModelFactory.java 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ToolTipListModelFactory.java 2008-10-17 14:57:40 UTC (rev 1565)
@@ -31,7 +31,7 @@
public class ToolTipListModelFactory {
/** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SimulatorAction.class);
+ static private Log log = LogFactory.getLog(SimulAction.class);
/**
* Build a new {@link ToolTipListModel} for for @Doc'field of all given
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterCellEditor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterCellEditor.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterCellEditor.java 2008-10-17 14:57:40 UTC (rev 1565)
@@ -0,0 +1,29 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package fr.ifremer.isisfish.ui.widget.editor;
+
+/**
+ *
+ * @author letellier
+ */
+public class ParameterCellEditor{
+ private String name;
+ private Class type;
+ public ParameterCellEditor(String n, Class c){
+ name = n;
+ type = c;
+ }
+ @Override
+ public String toString(){
+ return name;
+ }
+ public Class getType(){
+ return type;
+ }
+ public String getName(){
+ return name;
+ }
+}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java 2008-10-14 09:01:24 UTC (rev 1564)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterColumnEditor.java 2008-10-17 14:57:40 UTC (rev 1565)
@@ -86,6 +86,10 @@
* for a simple date
*/
Date(Date.class),
+ /**
+ * for a simple boolean
+ */
+ Double(double.class),
/**
* for a simple boolean
*/
@@ -145,11 +149,11 @@
@SuppressWarnings( { "unchecked" })
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
-
- Map.Entry<String, Class> p = (Map.Entry<String, Class>) table
- .getValueAt(row, 0);
- type = p.getValue();
- log.debug(p.getKey() + " P.type:" + type);
+// Map.Entry<String, Class> p = (Map.Entry<String, Class>) table.getValueAt(row, 0);
+// type = p.getValue();
+// log.debug(p.getKey() + " P.type:" + type);
+ ParameterCellEditor p = (ParameterCellEditor) table.getValueAt(row, 0);
+ type = p.getType();
JComboBox c;
//if (!table.hasFocus()) return null;
1
0
r1564 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . simulator
by sletellier@users.labs.libre-entreprise.org 14 Oct '08
by sletellier@users.labs.libre-entreprise.org 14 Oct '08
14 Oct '08
Author: sletellier
Date: 2008-10-14 09:01:24 +0000 (Tue, 14 Oct 2008)
New Revision: 1564
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
Log:
Migration des fichiers JAXX
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
@@ -0,0 +1,118 @@
+<!--
+/* *##%
+ * Copyright (C) 2005
+ * Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/* *
+ * IsisFish.java
+ *
+ * Created: 1 aout 2005 18:37:25 CEST
+ *
+ * @author Benjamin POUSSIN <poussin at codelutin.com>
+ * @version $Revision: 1312 $
+ *
+ * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $
+ * by : $Author: sletellier $
+ */
+ -->
+<JFrame id='isisfishFrame' title="isisfish.welcome.title" size='{new Dimension(800,600)}' resizable="true" location='{new Point(0,23)}' layout='{new BorderLayout()}'>
+ <script><![CDATA[
+ import static org.codelutin.i18n.I18nf._;
+ import fr.ifremer.isisfish.ui.simulator.SimulAction;
+ import fr.ifremer.isisfish.ui.input.InputUI;
+ import fr.ifremer.isisfish.ui.input.InputAction;
+ import fr.ifremer.isisfish.ui.result.ResultUI;
+ import fr.ifremer.isisfish.ui.script.ScriptUI;
+ import fr.ifremer.isisfish.ui.simulator.SimulQueueUI;
+ import fr.ifremer.isisfish.ui.simulator.SimulUI;
+ import javax.swing.JFrame;
+ welcomePanelUI.setContent(new WelcomeTabUI());
+ protected void openFrame(Container c, String title){
+ JFrame f = new JFrame();
+ f.setLayout(new BorderLayout());
+ WelcomePanelUI welcome = new WelcomePanelUI();
+ welcome.setContent(c);
+ f.add(welcome, BorderLayout.CENTER);
+ f.setTitle(title);
+ f.setVisible(true);
+ f.pack();
+ }
+ ]]>
+ </script>
+ <JMenuBar>
+ <JMenu text='isisfish.welcome.menu.file'>
+ <JMenuItem text="isisfish.welcome.menu.synchro" />
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).updateVCS()"
+-->
+ <JSeparator/>
+ <JMenuItem text="isisfish.welcome.menu.close"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).close(getContextValue(this.getClass()))"
+-->
+ </JMenu>
+ <JMenu text="isisfish.welcome.menu.frame">
+ <JMenuItem text="isisfish.welcome.menu.simulation" onActionPerformed='openFrame(new SimulUI(new SimulAction()), _("isisfish.simulation.title"))'/>
+ <JMenuItem text="isisfish.welcome.menu.result" onActionPerformed='openFrame(new ResultUI(), _("isisfish.result.title"))'/>
+ <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(), _("isisfish.input.title"))'/>
+ <JMenuItem text="isisfish.welcome.menu.script" onActionPerformed='openFrame(new ScriptUI(), _("isisfish.script.title"))'/>
+ <JSeparator/>
+ <JMenuItem text="isisfish.welcome.menu.queue" onActionPerformed='openFrame(new SimulQueueUI(), _("isisfish.queue.title"))'/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).openSimulQueueUIFrame()"
+-->
+ <JSeparator/>
+ <JMenu text="isisfish.welcome.menu.configuration">
+ <JMenuItem text="isisfish.welcome.menu.configuration"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).showConfig()"
+-->
+ <JMenuItem text="isisfish.welcome.menu.vcs.configuration"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).showConfigVCS()"
+-->
+ </JMenu>
+ </JMenu>
+ <JMenu text="isisfish.welcome.menu.help">
+ <JMenuItem text="isisfish.welcome.menu.help"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).help()"
+-->
+ <JSeparator/>
+ <JMenuItem text="isisfish.welcome.menu.monitor"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).monitorUI()"
+-->
+ <JSeparator/>
+ <JMenuItem text="isisfish.welcome.menu.about"/>
+<!--
+ onActionPerformed="getContextValue(WelcomeAction.class).aboutUI()"
+-->
+ </JMenu>
+ </JMenuBar>
+ <WelcomePanelUI id="welcomePanelUI"/>
+<!-- <JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}'>
+ <tab title='' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'><fr.ifremer.isisfish.ui.simulator.SimulUI/></tab>
+ <tab title='' icon='{new ImageIcon(getClass().getResource("/images/calc.gif"))}'><fr.ifremer.isisfish.ui.result.ResultUI/></tab>
+ <tab title='' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'><fr.ifremer.isisfish.ui.input.InputUI/></tab>
+ <tab title='' icon='{new ImageIcon(getClass().getResource("/images/bookPage.gif"))}'><fr.ifremer.isisfish.ui.script.ScriptUI/></tab>
+ </JTabbedPane>
+ <JPanel constraints="BorderLayout.SOUTH">
+ <StatusBarUI id='statusBar'/>
+ </JPanel> -->
+</JFrame>
\ No newline at end of file
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2008-10-14 08:54:25 UTC (rev 1563)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
@@ -55,13 +55,17 @@
getContextValue(SimulAction.class).addTagValue(fieldTag.getText(), fieldValue.getText());
}
protected void removeTagValue(){
- // getContextValue(SimulAction.class).removeTagValue(tableTagValue.getValueAt(getSelectedRow(),0));
+ getContextValue(SimulAction.class).removeTagValue(tableTagValue.getValueAt(tableTagValue.getSelectedRow(),0).toString());
}
protected void saveTagValue(){
- // getContextValue(SimulAction.class).saveTagValue();
+ if (fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1){
+ getContextValue(SimulAction.class).saveTagValue(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
+ }
}
protected void setSimulName(){
- getContextValue(SimulAction.class).getSimulationParameter().setSimulatorName(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
+ if (fieldSimulAdvParamsSimulatorSelect.getSelectedIndex() != -1){
+ getContextValue(SimulAction.class).getSimulationParameter().setSimulatorName(fieldSimulAdvParamsSimulatorSelect.getSelectedItem().toString());
+ }
}
]]>
</script>
@@ -102,27 +106,15 @@
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsSimulLoggerError" text="isisfish.common.error" buttonGroup="fieldSimulAdvParamsSimulLoggerGroup"/>
-<!--
-origin='$SimulationParameter/simulErrorLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsSimulLoggerWarn" text="isisfish.common.warn" buttonGroup="fieldSimulAdvParamsSimulLoggerGroup"/>
-<!--
-origin='$SimulationParameter/simulWarnLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsSimulLoggerInfo" text="isisfish.common.info" buttonGroup="fieldSimulAdvParamsSimulLoggerGroup"/>
-<!--
-origin='$SimulationParameter/simulInfoLevel'origin='$SimulationParameter/simulInfoLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsSimulLoggerDebug" text="isisfish.common.debug" buttonGroup="fieldSimulAdvParamsSimulLoggerGroup"/>
-<!--
-origin='$SimulationParameter/simulDebugLevel'
--->
</cell>
</row>
<row>
@@ -131,27 +123,15 @@
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsScriptLoggerError" text="isisfish.common.error" buttonGroup="fieldSimulAdvParamsScriptLoggerGroup"/>
-<!--
-origin='$SimulationParameter/scriptErrorLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsScriptLoggerWarn" text="isisfish.common.warn" buttonGroup="fieldSimulAdvParamsScriptLoggerGroup"/>
-<!--
-origin='$SimulationParameter/scriptWarnLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsScriptLoggerInfo" text="isisfish.common.info" buttonGroup="fieldSimulAdvParamsScriptLoggerGroup"/>
-<!--
-origin='$SimulationParameter/scriptInfoLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsScriptLoggerDebug" text="isisfish.common.debug" buttonGroup="fieldSimulAdvParamsScriptLoggerGroup"/>
-<!--
-origin='$SimulationParameter/scriptDebugLevel'
--->
</cell>
</row>
<row>
@@ -160,24 +140,15 @@
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsLibLoggerError" text="isisfish.common.error" buttonGroup="fieldSimulAdvParamsLibLoggerGroup"/>
-<!--
-origin='$SimulationParameter/libErrorLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsLibLoggerWarn" text="isisfish.common.warn" buttonGroup="fieldSimulAdvParamsLibLoggerGroup"/>
-<!--
-origin='$SimulationParameter/libWarnLevel'
--->
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsLibLoggerInfo" text="isisfish.common.info" buttonGroup="fieldSimulAdvParamsLibLoggerGroup"/>
</cell>
<cell fill="horizontal" weightx="0.2">
<JRadioButton id="fieldSimulAdvParamsLibLoggerDebug" text="isisfish.common.debug" buttonGroup="fieldSimulAdvParamsLibLoggerGroup"/>
-<!--
-origin='$SimulationParameter/libInfoLevel'
--->
</cell>
</row>
<row>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2008-10-14 08:54:25 UTC (rev 1563)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
@@ -33,6 +33,7 @@
<Table>
<script><![CDATA[
+ fieldSimulExportFolder.setText(getContextValue(SimulAction.class).getSimulationParameter().getExportDirectory());
public ExportUI (SimulAction action){
setContextValue(action);
}
@@ -41,7 +42,7 @@
<row>
<cell columns="4" fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
- <JList id="listSimulExportChoose" selectionMode="2">
+ <JList id="listSimulExportChoose" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getExportNames().toArray())}'>
<!-- Fixme : ListModel
<ListModel origin="$ExportNames"/>
<ListSelectionEvents onValueChanged="Update($listSimulExportChoose/selectedValues, $SimulationParameter/exportNames)"/>
@@ -61,13 +62,13 @@
<JTextField id="fieldSimulExportFolder"/>
</cell>
<cell>
- <JButton text="isisfish.common.ellipsis"/>
+ <JButton text="isisfish.common.ellipsis" onActionPerformed='getContextValue(SimulAction.class).updateDirectory()'/>
<!--
actionCommand="update(org.codelutin.util.FileUtil.getDirectory(), $SimulationParameter/exportDirectory);refreshView($fieldSimulExportFolder)"
-->
</cell>
<cell>
- <JButton text="isisfish.common.saveNextSimulation"/>
+ <JButton text="isisfish.common.saveNextSimulation" onActionPerformed='getContextValue(SimulAction.class).saveExport()'/>
</cell>
</row>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2008-10-14 08:54:25 UTC (rev 1563)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2008-10-14 09:01:24 UTC (rev 1564)
@@ -35,6 +35,11 @@
public ResultChoiceUI (SimulAction action){
setContextValue(action);
}
+ protected void saveResultNames(){
+ if (listResultNames.getSelectedIndex() != -1){
+ getContextValue(SimulAction.class).saveResultNames(listResultNames.getSelectedValues());
+ }
+ }
]]>
</script>
@@ -50,7 +55,7 @@
<JLabel text="isisfish.resultChoice.save" horizontalAlignment="0" constraints='BorderLayout.NORTH'/>
<JScrollPane constraints='BorderLayout.CENTER'>
<!--list id="listResultNames" SelectionMode="2" renderer="org.codelutin.i18n.I18n._(.)"-->
- <JList id="listResultNames" selectionMode="2">
+ <JList id="listResultNames" selectionMode="2" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getResultNames().toArray())}'>
<!-- Fixme : ListModel, ListSelectionEvents and listRender
origin="$SimulationParameter/resultEnabled"
<ListModel origin="$ResultNames"/>
@@ -62,7 +67,7 @@
</JList>
</JScrollPane>
- <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation"/>
+ <JButton constraints='BorderLayout.SOUTH' text="isisfish.common.saveNextSimulation" onActionPerformed='saveResultNames()'/>
<!--
actionCommand="simulator.SimulatorAction.saveResultNames($listResultNames/selectedValues)"
-->
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2008-10-14 08:54:25 UTC (rev 1563)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2008-10-14 09:01:24 UTC (rev 1564)
@@ -44,7 +44,9 @@
import static org.codelutin.i18n.I18nf._;
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
@@ -273,49 +275,67 @@
SimulationService.getService().submit(simulId, p, launcher, 0);
}
}
- public void addTagValue(String tag, String value){
- param.getTagValue().put(tag, value);
- }
- public void removeTagValue(String tag){
- log.debug("removeTagValue: " + tag);
- param.getTagValue().remove(tag);
- }
- public void saveTagValue(Map<String, String> tagValues){
- log.debug("call saveTagValue: " + tagValues);
- IsisFish.config.setDefaultTagValues(tagValues);
- }
public List<SimulatorLauncher> getSimulationLauncher(){
return SimulationService.getService().getSimulationLaunchers();
}
public List<Strategy> getStrategies(){
List<Strategy> result = new ArrayList<Strategy>();
try {
- result = regionStorage.getFisheryRegion(param.getRegion().getStorage()).getStrategy();
- } catch (StorageException ex) {
+ result = RegionStorage.getFisheryRegion(param.getRegion().getStorage().beginTransaction()).getStrategy();
+ } catch (Exception ex) {
Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
}
-// result = param.getStrategies();
return result;
}
public List<Population> getPopulations(){
List<Species> species;
List<Population> result = new ArrayList<Population>();
try {
- species = regionStorage.getFisheryRegion(param.getRegion().getStorage()).getSpecies();
+ species = RegionStorage.getFisheryRegion(param.getRegion().getStorage().beginTransaction()).getSpecies();
for (Species s : species){
result.addAll(s.getPopulation());
}
} catch (Exception ex) {
Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex);
}
-// result = param.getPopulations();
return result;
}
public void setNbAnnees(String years){
param.setNumberOfYear(Integer.parseInt(years));
}
-
- static public List<String> getSimulatorNames(){
+ public List<String> getSimulatorNames(){
return SimulatorStorage.getSimulatorNames();
}
+ public void addTagValue(String tag, String value){
+ param.getTagValue().put(tag, value);
+ }
+ public void removeTagValue(String tag){
+ log.debug("removeTagValue: " + tag);
+ param.getTagValue().remove(tag);
+ }
+ public void saveTagValue(String simulatorName){
+ Map<String, String> tagValues = param.getTagValue();
+ log.debug("call saveTagValue: " + tagValues);
+ IsisFish.config.setDefaultTagValues(tagValues);
+
+ IsisFish.config.setSimulatorClassfile(simulatorName);
+ //IsisFish.config.setSimulatorLauncher(local?"local":"isis-server");
+ }
+ public List<String> getExportNames(){
+ return ExportStorage.getExportNames();
+ }
+ public void updateDirectory(){
+ param.setExportDirectory(org.codelutin.util.FileUtil.getDirectory());
+ }
+ public void saveExport(){
+ IsisFish.config.setDefaultExportDirectory(param.getExportDirectory());
+ IsisFish.config.setDefaultExportNames(param.getExportNames());
+ }
+ public void saveResultNames(Object[] resultNames) {
+ List<String> resultNamesString = new ArrayList<String>();
+ for (Object o : resultNames){
+ resultNamesString.add(o.toString());
+ }
+ IsisFish.config.setDefaultResultNames(resultNamesString);
+ }
}
1
0
r1563 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui
by sletellier@users.labs.libre-entreprise.org 14 Oct '08
by sletellier@users.labs.libre-entreprise.org 14 Oct '08
14 Oct '08
Author: sletellier
Date: 2008-10-14 08:54:25 +0000 (Tue, 14 Oct 2008)
New Revision: 1563
Removed:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
Log:
Migration des fichiers JAXX
Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2008-10-13 18:52:04 UTC (rev 1562)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2008-10-14 08:54:25 UTC (rev 1563)
@@ -1,118 +0,0 @@
-<!--
-/* *##%
- * Copyright (C) 2005
- * Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * IsisFish.java
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin at codelutin.com>
- * @version $Revision: 1312 $
- *
- * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $
- * by : $Author: sletellier $
- */
- -->
-<JFrame id='isisfishFrame' title="isisfish.welcome.title" size='{new Dimension(800,600)}' resizable="true" location='{new Point(0,23)}' layout='{new BorderLayout()}'>
- <script><![CDATA[
- import static org.codelutin.i18n.I18nf._;
- import fr.ifremer.isisfish.ui.simulator.SimulAction;
- import fr.ifremer.isisfish.ui.input.InputUI;
- import fr.ifremer.isisfish.ui.input.InputAction;
- import fr.ifremer.isisfish.ui.result.ResultUI;
- import fr.ifremer.isisfish.ui.script.ScriptUI;
- import fr.ifremer.isisfish.ui.simulator.SimulQueueUI;
- import fr.ifremer.isisfish.ui.simulator.SimulUI;
- import javax.swing.JFrame;
- welcomePanelUI.setContent(new WelcomeTabUI());
- protected void openFrame(Container c, String title){
- JFrame f = new JFrame();
- f.setLayout(new BorderLayout());
- WelcomePanelUI welcome = new WelcomePanelUI();
- welcome.setContent(c);
- f.add(welcome, BorderLayout.CENTER);
- f.setTitle(title);
- f.setVisible(true);
- f.pack();
- }
- ]]>
- </script>
- <JMenuBar>
- <JMenu text='isisfish.welcome.menu.file'>
- <JMenuItem text="isisfish.welcome.menu.synchro" />
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).updateVCS()"
--->
- <JSeparator/>
- <JMenuItem text="isisfish.welcome.menu.close"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).close(getContextValue(this.getClass()))"
--->
- </JMenu>
- <JMenu text="isisfish.welcome.menu.frame">
- <JMenuItem text="isisfish.welcome.menu.simulation" onActionPerformed='openFrame(new SimulUI(), _("isisfish.simulation.title"))'/>
- <JMenuItem text="isisfish.welcome.menu.result" onActionPerformed='openFrame(new ResultUI(), _("isisfish.result.title"))'/>
- <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(), _("isisfish.input.title"))'/>
- <JMenuItem text="isisfish.welcome.menu.script" onActionPerformed='openFrame(new ScriptUI(), _("isisfish.script.title"))'/>
- <JSeparator/>
- <JMenuItem text="isisfish.welcome.menu.queue" onActionPerformed='openFrame(new SimulQueueUI(), _("isisfish.queue.title"))'/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).openSimulQueueUIFrame()"
--->
- <JSeparator/>
- <JMenu text="isisfish.welcome.menu.configuration">
- <JMenuItem text="isisfish.welcome.menu.configuration"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).showConfig()"
--->
- <JMenuItem text="isisfish.welcome.menu.vcs.configuration"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).showConfigVCS()"
--->
- </JMenu>
- </JMenu>
- <JMenu text="isisfish.welcome.menu.help">
- <JMenuItem text="isisfish.welcome.menu.help"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).help()"
--->
- <JSeparator/>
- <JMenuItem text="isisfish.welcome.menu.monitor"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).monitorUI()"
--->
- <JSeparator/>
- <JMenuItem text="isisfish.welcome.menu.about"/>
-<!--
- onActionPerformed="getContextValue(WelcomeAction.class).aboutUI()"
--->
- </JMenu>
- </JMenuBar>
- <WelcomePanelUI id="welcomePanelUI"/>
-<!-- <JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}'>
- <tab title='' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'><fr.ifremer.isisfish.ui.simulator.SimulUI/></tab>
- <tab title='' icon='{new ImageIcon(getClass().getResource("/images/calc.gif"))}'><fr.ifremer.isisfish.ui.result.ResultUI/></tab>
- <tab title='' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'><fr.ifremer.isisfish.ui.input.InputUI/></tab>
- <tab title='' icon='{new ImageIcon(getClass().getResource("/images/bookPage.gif"))}'><fr.ifremer.isisfish.ui.script.ScriptUI/></tab>
- </JTabbedPane>
- <JPanel constraints="BorderLayout.SOUTH">
- <StatusBarUI id='statusBar'/>
- </JPanel> -->
-</JFrame>
1
0