r2366 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . queue simulator
Author: chatellier Date: 2009-06-10 15:24:47 +0000 (Wed, 10 Jun 2009) New Revision: 2366 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/ComponentTableCellRenderer.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java Log: Move and refactor queue UI. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-06-10 15:24:16 UTC (rev 2365) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-06-10 15:24:47 UTC (rev 2366) @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *##%*/ --> -<JPanel id='welcomePanelUI' layout='{new BorderLayout()}'> +<JPanel layout='{new BorderLayout()}'> <script><![CDATA[ import fr.ifremer.isisfish.ui.simulator.SimulAction; import fr.ifremer.isisfish.ui.result.ResultAction; @@ -30,11 +30,11 @@ // chatellier already done in SimulAction constructor //simulUI.getContextValue(SimulAction.class).init(); - queueUI.setContextValue(simulUI.getContextValue(SimulAction.class)); + //queueUI.setContextValue(simulUI.getContextValue(SimulAction.class)); public void selTab(int i){ simulTabs.setSelectedIndex(i); } - public void refresh(){ + public void refresh() { simulUI.refresh(); sensitivityUI.refresh(); } @@ -57,7 +57,7 @@ <fr.ifremer.isisfish.ui.script.ScriptUI/> </tab> <tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/Queue.gif"))}'> - <fr.ifremer.isisfish.ui.simulator.QueueUI id="queueUI"/> + <fr.ifremer.isisfish.ui.queue.QueueUI /> </tab> </JTabbedPane> </JPanel> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-06-10 15:24:16 UTC (rev 2365) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-06-10 15:24:47 UTC (rev 2366) @@ -33,7 +33,7 @@ import fr.ifremer.isisfish.ui.result.ResultView; import fr.ifremer.isisfish.ui.script.ScriptUI; import fr.ifremer.isisfish.ui.simulator.SimulUI; - import fr.ifremer.isisfish.ui.simulator.QueueUI; + import fr.ifremer.isisfish.ui.queue.QueueUI; import fr.ifremer.isisfish.ui.simulator.launcher.SSHLauncherConfigUI; import fr.ifremer.isisfish.ui.vcs.VCSConfigUI; import org.codelutin.widget.AboutFrame; @@ -132,11 +132,11 @@ <JMenuItem text="isisfish.welcome.menu.close" onActionPerformed='close()'/> </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.simulation" onActionPerformed='openFrame(new SimulUI(new JAXXInitialContext().add(new SimulAction()).add(regionMonitor).add(this)), _("isisfish.simulation.title"))'/> <JMenuItem text="isisfish.welcome.menu.result" onActionPerformed='openFrame(new ResultView(), _("isisfish.result.title"))'/> - <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(new JAXXInitialContext().add(verifier).add(new InputAction()).add(new InputSaveVerifier()).add(this)), _("isisfish.input.title"))'/> + <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(new JAXXInitialContext().add(verifier).add(regionMonitor).add(new InputAction()).add(new InputSaveVerifier()).add(this)), _("isisfish.input.title"))'/> <JMenuItem text="isisfish.welcome.menu.script" onActionPerformed='openFrame(new ScriptUI(), _("isisfish.script.title"))'/> - <JMenuItem text="isisfish.sensitivity.title" onActionPerformed='openFrame(new SensitivityUI(new JAXXInitialContext().add(new InputAction()).add(new InputSaveVerifier()).add(new SimulAction()).add(this)), _("isisfish.sensitivity.title"))'/> + <JMenuItem text="isisfish.sensitivity.title" onActionPerformed='openFrame(new SensitivityUI(new JAXXInitialContext().add(regionMonitor).add(new InputAction()).add(new InputSaveVerifier()).add(new SimulAction()).add(this)), _("isisfish.sensitivity.title"))'/> <JSeparator/> <JMenuItem text="isisfish.welcome.menu.queue" onActionPerformed='openFrame(new QueueUI(), _("isisfish.queue.title"))'/> </JMenu> Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/ComponentTableCellRenderer.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/ComponentTableCellRenderer.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/ComponentTableCellRenderer.java 2009-06-10 15:24:47 UTC (rev 2366) @@ -0,0 +1,47 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 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. + *##%*/ + +package fr.ifremer.isisfish.ui.queue; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; + +/** + * Renderer to display component in table. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 10 juin 2009 $ + * By : $Author: chatellier $ + */ +public class ComponentTableCellRenderer implements TableCellRenderer { + + /** + * Value is already a component, resend it without modification. + */ + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + + return (Component)value; + } +} Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java 2009-06-10 15:24:47 UTC (rev 2366) @@ -0,0 +1,139 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 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. + *##%*/ + +package fr.ifremer.isisfish.ui.queue; + +import static org.codelutin.i18n.I18n._; +import jaxx.runtime.swing.ErrorDialogUI; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.log.UserLog; + +import fr.ifremer.isisfish.logging.SimulationLoggerUtil; +import fr.ifremer.isisfish.simulator.launcher.SimulationJob; +import fr.ifremer.isisfish.simulator.launcher.SimulationService; + +/** + * Common action for all queue ui. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 10 juin 2009 $ + * By : $Author: chatellier $ + */ +public class QueueAction { + + /** Log. */ + private static Log log = LogFactory.getLog(QueueAction.class); + + /** queue ui to manage. */ + protected QueueUI queueUI; + + /** + * Queue action. + * + * @param queueUI queue ui to manage + */ + public QueueAction(QueueUI queueUI) { + this.queueUI = queueUI; + } + + /** + * Update ui buttons. + */ + public void updateActions() { + queueUI.setCanStop(!queueUI.getSelectionModelQueueTable().isSelectionEmpty()); + queueUI.setCanShowLog(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty()); + // TODO value have to change on non valueChanged event + queueUI.setCanClear(queueUI.getQueueTableDone().getModel().getRowCount()>0); + queueUI.setCanRestart(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty()); + } + + /** + * Stop simulation associated with table selected rows. + */ + protected void stopSimulation() { + int[] selectedRows = queueUI.getQueueTable().getSelectedRows(); + SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length]; + int index = 0; + + // to do in two pass, because each stopped simulation + // change selected rows + for (int selectedRow : selectedRows) { + jobsToStop[index++] = queueUI.getNewSimulationModel().getJob(selectedRow); + } + for (SimulationJob jobToStop : jobsToStop) { + jobToStop.stop(); + if (log.isInfoEnabled()) { + log.info(_("User stop simulation %s", jobToStop.getItem().getControl() + .getId())); + } + } + } + + /** + * Restart simulation. + */ + protected void restartSimulation() { + int[] selectedRows = queueUI.getQueueTableDone().getSelectedRows(); + SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length]; + int index = 0; + + // to do in two pass, because each simulation + // change selected rows + for (int selectedRow : selectedRows) { + jobsToRestart[index++] = queueUI.getDoneSimulationModel().getJob(selectedRow); + } + for (SimulationJob jobToRestart : jobsToRestart) { + + jobToRestart.restart(); + jobToRestart.getItem().getControl().setText(_("isisfish.simulation.restarting")); + if (log.isInfoEnabled()) { + log.info(_("User restart simulation %s", jobToRestart.getItem().getControl() + .getId())); + } + } + } + + /** + * View log of selected done jobs. + */ + protected void viewLog() { + if (queueUI.getQueueTableDone().getSelectedRow() >= 0) { + SimulationJob selectedJob = queueUI.getDoneSimulationModel().getJob(queueUI.getQueueTableDone().getSelectedRow()); + + String id = selectedJob.getItem().getControl().getId(); + try { + SimulationLoggerUtil.showSimulationLogConsole(id); + } catch (Exception eee) { + UserLog.error(_("Can't open log for %s", id), eee); + ErrorDialogUI.showError(eee); + } + } + } + + /** + * Remove all done jobs. + */ + protected void clearDoneJobs() { + SimulationService ss = SimulationService.getService(); + ss.clearJobDone(); + } +} Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx (from rev 2296, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx) =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx 2009-06-10 15:24:47 UTC (rev 2366) @@ -0,0 +1,80 @@ +<!-- +/* *##% + * Copyright (C) 2005 - 2009 + * 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. + *##%*/ + --> +<Table> +<script><![CDATA[ + import fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel; + import fr.ifremer.isisfish.simulator.launcher.SimulationService; + import javax.swing.JProgressBar; + import javax.swing.ListSelectionModel; + + queueTable.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer()); + queueTableDone.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer()); + ]]> + </script> + + <Boolean id='canStop' javaBean='false'/> + <Boolean id='canShowLog' javaBean='false'/> + <Boolean id='canClear' javaBean='false'/> + <Boolean id='canRestart' javaBean='false'/> + + <QueueAction id="queueAction" javaBean='new QueueAction(this)'/> + <SimulationServiceTableModel id="newSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), true)'/> + <SimulationServiceTableModel id="doneSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), false)'/> + + <DefaultListSelectionModel id="selectionModelQueueTable" onValueChanged='queueAction.updateActions()'/> + <DefaultListSelectionModel id="selectionModelQueueTableDone" onValueChanged='queueAction.updateActions()'/> + + <row> + <cell columns="5" fill="both" weightx="1.0" weighty="0.5"> + <JScrollPane> + <JTable id="queueTable" model='{newSimulationModel}' + selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" + selectionModel="{selectionModelQueueTable}" /> + </JScrollPane> + </cell> + </row> + <row> + <cell columns="5" fill="both" weightx="1.0" weighty="0.5"> + <JScrollPane> + <JTable id="queueTableDone" model='{doneSimulationModel}' + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" + selectionModel="{selectionModelQueueTableDone}" /> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" weightx="0.3"> + <JToggleButton id="autoLaunchButton" text="isisfish.queue.simulationLaunch"/> + </cell> + <cell fill="horizontal" weightx="0.3"> + <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='queueAction.stopSimulation()' enabled='{isCanStop()}' /> + </cell> + <cell fill="horizontal" weightx="0.3"> + <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='queueAction.restartSimulation()' enabled='{isCanRestart()}' /> + </cell> + <cell fill="horizontal" weightx="0.3"> + <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='queueAction.viewLog()' enabled='{isCanShowLog()}' /> + </cell> + <cell fill="horizontal" weightx="0.3"> + <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='queueAction.clearDoneJobs()' enabled='{isCanClear()}' /> + </cell> + </row> +</Table> \ No newline at end of file Deleted: 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 2009-06-10 15:24:16 UTC (rev 2365) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/QueueUI.jaxx 2009-06-10 15:24:47 UTC (rev 2366) @@ -1,153 +0,0 @@ -<!-- -/* *##% - * Copyright (C) 2005 - 2009 - * 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. - *##%*/ - --> - -<Table> -<script><![CDATA[ - import fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel; - import fr.ifremer.isisfish.simulator.launcher.SimulationService; - import fr.ifremer.isisfish.simulator.launcher.SimulationJob; - import javax.swing.JProgressBar; - import javax.swing.ListSelectionModel; - import javax.swing.table.TableCellRenderer; - - // TODO this code is magic - // lucky executed BEFORE ui - initContext(); - - public void initContext() { - SimulationService ss = SimulationService.getService(); - setContextValue(new SimulationServiceTableModel(ss, true), "new"); - setContextValue(new SimulationServiceTableModel(ss, false), "done"); - queueTable.setDefaultRenderer(JProgressBar.class, new JProgressBarTableCellRenderer()); - queueTableDone.setDefaultRenderer(JProgressBar.class, new JProgressBarTableCellRenderer()); - } - - public QueueUI(SimulAction action) { - setContextValue(action); - } - - public class JProgressBarTableCellRenderer implements TableCellRenderer { - public Component getTableCellRendererComponent(JTable table, - Object value, boolean isSelected, boolean hasFocus, - int row, int column) { - return (JProgressBar) value; - } - } - - /** - * Stop simulation associated with table selected rows. - */ - protected void stopSimulation() { - SimulAction simulAction = getContextValue(SimulAction.class); - - int[] selectedRows = queueTable.getSelectedRows(); - SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length]; - int index = 0; - - // to do in two pass, because each stopped simulation - // change selected rows - for (int selectedRow : selectedRows) { - jobsToStop[index++] = getContextValue(SimulationServiceTableModel.class, "new").getJob(selectedRow); - } - for (SimulationJob jobToStop : jobsToStop) { - simulAction.stopSimulation(jobToStop); - } - } - - protected void restartSimulation() { - SimulAction simulAction = getContextValue(SimulAction.class); - - int[] selectedRows = queueTableDone.getSelectedRows(); - SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length]; - int index = 0; - - // to do in two pass, because each simulation - // change selected rows - for (int selectedRow : selectedRows) { - jobsToRestart[index++] = getContextValue(SimulationServiceTableModel.class, "done").getJob(selectedRow); - } - for (SimulationJob jobToRestart : jobsToRestart) { - simulAction.restartSimulation(jobToRestart); - } - } - - protected void viewLog() { - if (queueTableDone.getSelectedRow() >= 0) { - getContextValue(SimulAction.class).viewLog(getContextValue(SimulationServiceTableModel.class, "done").getJob(queueTableDone.getSelectedRow())); - } - } - - protected void clearDoneJobs() { - getContextValue(SimulAction.class).clearDoneJobs(); - } - - protected void updateActions() { - setCanStop(!selectionModelQueueTab.isSelectionEmpty()); - setCanShowLog(!selectionModelQueueTabDone.isSelectionEmpty()); - // TODO value have to change on non valueChanged event - setCanClear(queueTableDone.getModel().getRowCount()>0); - setCanRestart(!selectionModelQueueTabDone.isSelectionEmpty()); - } - ]]> - </script> - - <Boolean id='canStop' javaBean='false'/> - <Boolean id='canShowLog' javaBean='false'/> - <Boolean id='canClear' javaBean='false'/> - <Boolean id='canRestart' javaBean='false'/> - - <DefaultListSelectionModel id="selectionModelQueueTab" onValueChanged='updateActions()'/> - <DefaultListSelectionModel id="selectionModelQueueTabDone" onValueChanged='updateActions()'/> - - <row> - <cell columns="5" fill="both" weightx="1.0" weighty="0.5"> - <JScrollPane> - <JTable id="queueTable" model='{getContextValue(SimulationServiceTableModel.class, "new")}' selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" - selectionModel="{selectionModelQueueTab}"/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns="5" fill="both" weightx="1.0" weighty="0.5"> - <JScrollPane> - <JTable id="queueTableDone" model='{getContextValue(SimulationServiceTableModel.class, "done")}' selectionMode="{ListSelectionModel.SINGLE_SELECTION}" - selectionModel="{selectionModelQueueTabDone}" /> - </JScrollPane> - </cell> - </row> - <row> - <cell fill="horizontal" weightx="0.3"> - <JToggleButton id="autoLaunchButton" text="isisfish.queue.simulationLaunch"/> - </cell> - <cell fill="horizontal" weightx="0.3"> - <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='stopSimulation()' enabled='{isCanStop()}' /> - </cell> - <cell fill="horizontal" weightx="0.3"> - <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='restartSimulation()' enabled='{isCanRestart()}' /> - </cell> - <cell fill="horizontal" weightx="0.3"> - <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='viewLog()' enabled='{isCanShowLog()}' /> - </cell> - <cell fill="horizontal" weightx="0.3"> - <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='clearDoneJobs()' enabled='{isCanClear()}' /> - </cell> - </row> -</Table> \ No newline at end of file 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 2009-06-10 15:24:16 UTC (rev 2365) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-06-10 15:24:47 UTC (rev 2366) @@ -32,16 +32,16 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; -import java.util.Map.Entry; import javax.swing.JComponent; +import jaxx.runtime.swing.ErrorDialogUI; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.log.UserLog; @@ -63,13 +63,11 @@ import fr.ifremer.isisfish.entities.Strategy; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.logging.SimulationLoggerUtil; import fr.ifremer.isisfish.mexico.MexicoHelper; import fr.ifremer.isisfish.rule.Rule; import fr.ifremer.isisfish.simulator.AnalysePlan; import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.simulator.SimulationProperties; -import fr.ifremer.isisfish.simulator.launcher.SimulationJob; import fr.ifremer.isisfish.simulator.launcher.SimulationService; import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher; import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan; @@ -82,7 +80,6 @@ import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain; import fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil; import fr.ifremer.isisfish.ui.widget.filter.FilterModel; -import jaxx.runtime.swing.ErrorDialogUI; /** * SimulAction. @@ -105,9 +102,7 @@ protected SimulationParameter param = null; protected RegionStorage regionStorage = null; protected SimulationStorage simulStorage = null; - protected RuleStorage ruleStorage = null; protected List<String> analysePlan = null; - protected List<Rule> rules = new ArrayList<Rule>(); protected Map<SensitivityExport, String> sensitivityExports = new HashMap<SensitivityExport, String>(); protected List<String> oldSimulNames = null; @@ -259,58 +254,24 @@ return result; } - public void stopSimulation(SimulationJob job) { - job.stop(); - if (log.isInfoEnabled()) { - log.info(_("User stop simulation %s", job.getItem().getControl() - .getId())); - } - } - /** - * Restart job. - * - * @param job job to restart - */ - public void restartSimulation(SimulationJob job) { - job.restart(); - job.getItem().getControl().setText(_("isisfish.simulation.restarting")); - if (log.isInfoEnabled()) { - log.info(_("User restart simulation %s", job.getItem().getControl() - .getId())); - } - } - - protected void viewLog(SimulationJob job) { - String id = job.getItem().getControl().getId(); - try { - SimulationLoggerUtil.showSimulationLogConsole(id); - } catch (Exception eee) { - UserLog.error(_("Can't open log for %s", id), eee); - showMsgBox(eee); - } - } - - protected void clearDoneJobs() { - SimulationService ss = SimulationService.getService(); - ss.clearJobDone(); - } - - /** * Change region in simulation launcher * - * @param regionName SimulationParameter/description + * @param regionName region name */ public void regionChange(String regionName) { try { regionStorage = RegionStorage.getRegion(regionName); - init(); // reinitialise param pour le vider + + // chatellier, on ne peut pas le reinitialiser, on + // perd toutes les info apres un rechergement d'une anciennes simulation + //init(); // reinitialise param pour le vider param.setRegionName(regionName); -// poussin 20090519 quel est l'interet de faire ca ? et encore plus maintenant qu'on reinitialise -// for (Rule r : param.getRules()) { -// rules.put(r, RuleStorage.getName(r)); -// } + // poussin 20090519 quel est l'interet de faire ca ? et encore plus maintenant qu'on reinitialise + // for (Rule r : param.getRules()) { + // rules.put(r, RuleStorage.getName(r)); + // } } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Can't change region", e); @@ -390,13 +351,16 @@ } /** - * Add new rule by name. + * Add new rule. * - * @param name rule name + * Get a new instance of ruleItem, and add it to rule list. + * + * @param ruleItem rule to get copy */ - public void addRules(String name) { - ruleStorage = RuleStorage.getRule(name); + public void addNewRule(Rule ruleItem) { + String ruleName = RuleStorage.getName(ruleItem); try { + RuleStorage ruleStorage = RuleStorage.getRule(ruleName); Rule ruleTmp = ruleStorage.getNewRuleInstance(); param.addRule(ruleTmp); } catch (IsisFishException e) { @@ -418,20 +382,29 @@ } /** - * Return rules name without .java extention. + * Retourne une liste d'instance de toutes les regles disponible. * - * @return rule names list + * Instancié (utile pour les modeles). + * + * @return instance rule list */ - public List<String> getAvailableRuleNames() { - List<String> result = new ArrayList<String>(); - for (String r : RuleStorage.getRuleNames()) { - // Remove .java extention - // TODO find a better way to to that - // for example RuleStorage.getRuleName(String) - result.add(r.substring(0, r.length() - 5)); + public List<Rule> getAvailableRules() { + List<Rule> result = new ArrayList<Rule>(); + for (String ruleName : RuleStorage.getRuleNames()) { + try { + // remove last .java + String shortRuleName = ruleName.substring(0, ruleName.length() - 5); + Rule rule = RuleStorage.getRule(shortRuleName).getNewRuleInstance(); + result.add(rule); + } catch (IsisFishException e) { + if (log.isErrorEnabled()) { + log.error("Can't get rule instance", e); + } + } } return result; } + // Strategies public List<Strategy> getStrategies() {
participants (1)
-
chatellier@users.labs.libre-entreprise.org