Author: sletellier Date: 2008-12-15 17:46:56 +0000 (Mon, 15 Dec 2008) New Revision: 1674 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.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/SimulAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx Log: Debug vol4 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 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2008-12-15 17:46:56 UTC (rev 1674) @@ -33,15 +33,10 @@ <JPanel id='welcomePanelUI' layout='{new BorderLayout()}'> <script><![CDATA[ import fr.ifremer.isisfish.ui.simulator.SimulAction; - import static javax.swing.JOptionPane.showMessageDialog; import fr.ifremer.isisfish.ui.input.InputAction; import fr.ifremer.isisfish.ui.result.ResultAction; - showMsgBox(simulUI.getContextValue(SimulAction.class).init()); - protected void showMsgBox(String txt){ - if (txt != null){ - showMessageDialog(this, txt); - } - } + + simulUI.getContextValue(SimulAction.class).init(); ]]> </script> <JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}' constraints="BorderLayout.CENTER"> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2008-12-15 17:46:56 UTC (rev 1674) @@ -30,7 +30,7 @@ * by : $Author: sletellier $ */ --> -<JPanel id="input" visible="true" size='{new Dimension(700,500)}' layout='{new BorderLayout()}' location='{new Point(0,139)}'> +<JPanel id="input" layout='{new BorderLayout()}'> <javax.swing.tree.DefaultTreeSelectionModel id='navigationSelectionModel' selectionMode='{javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION}'/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2008-12-15 17:46:56 UTC (rev 1674) @@ -48,6 +48,9 @@ import fr.ifremer.isisfish.entities.Port; import fr.ifremer.isisfish.map.IsisMapBean; import fr.ifremer.isisfish.map.OpenMapToolPanel; + import fr.ifremer.isisfish.map.CellSelectionLayer; + import com.bbn.openmap.event.SelectMouseMode; + import com.bbn.openmap.event.MapMouseListener; import com.bbn.openmap.gui.OMToolSet; import fr.ifremer.isisfish.ui.WelcomePanelUI; import org.codelutin.topia.persistence.TopiaEntity; @@ -58,6 +61,7 @@ protected IsisMapBean zoneMap = new IsisMapBean(); protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); protected OMToolSet toolSet = new OMToolSet(); + protected MapMouseListener mapListener = null; public ZoneUI (InputAction action){ @@ -116,7 +120,7 @@ int i = 0; for (Cell c : cellsSelected){ indexs[i] = zoneCellsModel.indexOf(c); - if (log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("refresh " + c + " " + i); } i++; @@ -139,17 +143,85 @@ zoneMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); toolSet.setupListeners(zoneMap); toolMap.add((Component)toolSet); + zoneMap.setActiveMouseMode(new SelectMouseMode()); + zoneMap.setSelectionMode(CellSelectionLayer.MULT_SELECTION); + setMapListener(); zoneMapPanel.add(toolMap, BorderLayout.NORTH); zoneMapPanel.add(zoneMap, BorderLayout.CENTER); valueChanged(false); refreshMap(); } + protected void setMapListener(){ + if (mapListener == null){ + mapListener = new MapMouseListener() { + @Override + public boolean mouseClicked(MouseEvent e) { + java.util.List<Cell> cells = (java.util.List<Cell>) zoneMap.getSelectedCells(); + if (cells != null){ + int[] indexs = new int[cells.size()]; + int i = 0; + for (Cell c : cells){ + indexs[i] = ((DefaultListModel)zoneCells.getModel()).indexOf(c); + if (log.isDebugEnabled()) { + log.debug("refresh " + c + " " + i); + } + i++; + } + zoneCells.setSelectedIndices(indexs); + return true; + } + return false; + } + + @Override + public String[] getMouseModeServiceList() { + return new String[] { + SelectMouseMode.modeID + }; + } + + @Override + public boolean mousePressed(MouseEvent arg0) { + return false; + } + + @Override + public boolean mouseReleased(MouseEvent arg0) { + return false; + } + + @Override + public void mouseEntered(MouseEvent arg0) { + + } + + @Override + public void mouseExited(MouseEvent arg0) { + + } + + @Override + public boolean mouseDragged(MouseEvent arg0) { + return false; + } + + @Override + public boolean mouseMoved(MouseEvent arg0) { + return false; + } + + @Override + public void mouseMoved() { + + } + }; + zoneMap.addMapMouseListener(mapListener); + } + } protected void refreshMap(){ - java.util.List<Cell> cells = new ArrayList<Cell>(); - for (Object o : zoneCells.getSelectedValues()){ - cells.add((Cell) o ); + if (getContextValue(InputAction.class).getZone() != null){ + zoneMap.setSelectedCells(getContextValue(InputAction.class).getZone().getCell()); } - zoneMap.setSelectedCells(cells); } protected void create(){ TopiaEntity topia = getContextValue(InputAction.class).create("Zone"); 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-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-12-15 17:46:56 UTC (rev 1674) @@ -89,7 +89,7 @@ if(selected != null && !selected.trim().isEmpty()) { WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); root.setInfoText(_("isisfish.message.loading.region")); - showMsgBox(getContextValue(SimulAction.class).regionChange(fieldSimulParamsRegion.getSelectedItem().toString())); + getContextValue(SimulAction.class).regionChange(fieldSimulParamsRegion.getSelectedItem().toString()); refresh(); root.setInfoText(_("isisfish.message.region.loaded")); } @@ -103,7 +103,7 @@ if (selected != null && !selected.equals(" ")){ WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); root.setInfoText(_("isisfish.message.loading.old.simulation")); - showMsgBox(getContextValue(SimulAction.class).loadOldSimulation(selected)); + getContextValue(SimulAction.class).loadOldSimulation(selected); refresh(); root.setInfoText(_("isisfish.message.old.simulation.loaded")); } @@ -121,7 +121,7 @@ setRulesItems(); } protected void simul(){ - showMsgBox(getContextValue(SimulAction.class).simul(fieldSimulParamsName.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem())); + getContextValue(SimulAction.class).simul(fieldSimulParamsName.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem()); SimulUI simul = getParentContainer(SimulUI.class); simul.selTab(6); } @@ -148,13 +148,15 @@ } 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++; + if (listSimulParamsStrategiesModel.size() != 0){ + int[] indexs = new int[listSimulParamsStrategiesModel.size()]; + int i = 0; + for (Strategy s : strategiesSelected){ + indexs[i] = listSimulParamsStrategiesModel.indexOf(s); + i++; + } + listSimulParamsStrategies.setSelectedIndices(indexs); } - listSimulParamsStrategies.setSelectedIndices(indexs); } protected void setListSimulParamsPopulationsItems(){ DefaultListModel listSimulParamsPopulationsModel = new DefaultListModel(); @@ -164,14 +166,16 @@ } listSimulParamsPopulations.setModel(listSimulParamsPopulationsModel); 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++; + if (listSimulParamsPopulationsModel.size() != 0){ + int[] indexs = new int[listSimulParamsPopulationsModel.size()]; + int i = 0; + for (Population p : populationsSelected){ + indexs[i] = listSimulParamsPopulationsModel.indexOf(p); + i++; + } + listSimulParamsPopulations.setSelectedIndices(indexs); + populationSelected(); } - listSimulParamsPopulations.setSelectedIndices(indexs); - populationSelected(); } protected void setRulesItems(){ listSimulParamsMesuresList.setListData(getContextValue(SimulAction.class).getRules().toArray()); @@ -241,11 +245,6 @@ } }); } - protected void showMsgBox(String txt){ - if (txt != null){ - showMessageDialog(this, txt); - } - } protected void selectFilter(){ try { getContextValue(SimulAction.class).setOldSimulatorNames(fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil.filterSimulation(getContextValue(SimulAction.class).getOldSimulationItem())); @@ -352,7 +351,7 @@ <JLabel text="isisfish.params.simulationName" minimumSize='{new Dimension(140,25)}' preferredSize='{new Dimension(140,25)}'/> </cell> <cell fill="both" weightx="1.0"> - <JTextField id="fieldSimulParamsName" onKeyPressed='saveName()'/> + <JTextField id="fieldSimulParamsName" onFocusLost='saveName()'/> </cell> </row> </Table> @@ -387,7 +386,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()}' onKeyPressed='saveDescription()'/> + <JTextArea id="fieldSimulParamsDesc" text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' onFocusLost='saveDescription()'/> </JScrollPane> </cell> </row> @@ -531,12 +530,15 @@ <cell> <JLabel id="lblLauncher" text="isisfish.params.lblLauncher"/> </cell> - <cell fill="horizontal" weightx="0.5"> + <cell fill="horizontal" weightx="0.4"> <JComboBox id="comboSelLauncher" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulationLauncher().toArray())}'/> </cell> - <cell fill="horizontal" weightx="0.5"> + <cell fill="horizontal" weightx="0.4"> <JButton id="buttonSimulParamsSimulate" text="isisfish.common.simulate" onActionPerformed='simul()'/> </cell> + <cell fill="horizontal" weightx="0.2"> + <JButton id="saveSimul" text="isisfish.simulation.menu.save" onActionPerformed='getParentContainer(SimulUI.class).saveSimulation()'/> + </cell> </row> </Table> </cell> 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-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2008-12-15 17:46:56 UTC (rev 1674) @@ -62,6 +62,7 @@ import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher; import fr.ifremer.isisfish.ui.Common; import fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil; +import fr.ifremer.isisfish.ui.widget.ErrorDialogUI; import fr.ifremer.isisfish.ui.widget.filter.FilterModel; import java.io.BufferedReader; import java.io.File; @@ -107,7 +108,10 @@ public SimulAction() { init(); } - public String init(){ + protected void showMsgBox(Exception eee){ + ErrorDialogUI.showError(eee); + } + public void init(){ log.debug("Init "); try { param = new SimulationParameter(); @@ -127,39 +131,30 @@ } catch (Exception eee) { log.error("Can't init SimulationParameter", eee); - return (_("isisfish.simulator.simulaction.init",eee.getMessage())); + showMsgBox(eee); } - return null; } protected void setName(String name){ simulName = name; } - protected String importSimulation(File f){ - String result = null; + protected void importSimulation(File f){ FileInputStream fos = null; try { fos = new FileInputStream(f); - BufferedReader br = new BufferedReader(new InputStreamReader(fos)); - String line = br.readLine(); - if (line.matches("^#.*")){ - result = line.substring(1); - } - Properties proper = new Properties(); proper.load(fos); -// TODO : réparer -// param.fromProperties(proper); - simulName = result; + param.fromProperties(SimulationStorage.getSimulationDirectory(), proper); } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } finally { try { fos.close(); } catch (IOException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } - return result; } protected void saveSimulation(File f){ FileOutputStream fos = null; @@ -168,11 +163,13 @@ param.copy().toProperties().store(fos, simulName); } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } finally { try { fos.close(); } catch (IOException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } } @@ -196,6 +193,7 @@ } catch (Exception eee) { if (log.isWarnEnabled()) { log.warn("Can't find result name script", eee); + showMsgBox(eee); } } return result; @@ -206,15 +204,14 @@ log.info(_("User stop simulation %s", job.getItem().getControl().getId())); } - protected String viewLog(SimulationJob job) { + 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); - return (_("isisfish.simulator.simulaction.viewlogerror",eee.getMessage())); + showMsgBox(eee); } - return null; } protected void clearDoneJobs() { @@ -227,7 +224,7 @@ * * @param regionName SimulationParameter/description */ - public String regionChange(String regionName) { + public void regionChange(String regionName) { try{ regionStorage = RegionStorage.getRegion(regionName); param.setRegionName(regionName); @@ -236,9 +233,8 @@ } } catch (Exception eee){ - return (_("isisfish.simulator.simulaction.regionChange",eee.getMessage())); + showMsgBox(eee); } - return null; } /** @@ -247,7 +243,7 @@ * @param simulName name of simulation to load * @return <code>null</code> if ok, an OutputView otherwise with error */ - public String loadOldSimulation(String simulName) { + public void loadOldSimulation(String simulName) { log.debug("call loadOldSimulation: " + simulName); try { this.simulName = simulName; @@ -258,9 +254,8 @@ regionStorage = param.getRegion(); } catch (Exception eee) { log.error("Can't load old Simulation: " + simulName, eee); - return (_("isisfish.simulator.simulaction.loadOldSimulation",eee.getMessage())); + showMsgBox(eee); } - return null; } /* @@ -279,6 +274,7 @@ param.addRule(ruleTmp); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } public List<String> getRuleNames() { @@ -295,6 +291,7 @@ result.add(RuleStorage.getName(r)); } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } return result; @@ -335,6 +332,7 @@ result = RuleStorage.getParameterValue(getRule(ruleName), paramName); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } return result; @@ -345,6 +343,7 @@ RuleStorage.setParameterValue(getRule(ruleName), paramName, o); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } } @@ -357,6 +356,7 @@ result = RegionStorage.getFisheryRegion(param.getRegion().getStorage().beginTransaction()).getStrategy(); } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } return result; } @@ -381,6 +381,7 @@ } } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } return result; } @@ -433,8 +434,10 @@ return oldSimulNames; } catch (ParseException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } catch (IOException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } return null; } @@ -533,6 +536,7 @@ getSimulationParameter().addAnalysePlan(ap); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } public void removeAnalysePlan(String name){ @@ -569,6 +573,7 @@ result = AnalysePlanStorage.getParameterValue(getAnalysePlan(analysePlanName), paramName); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } return result; @@ -579,6 +584,7 @@ AnalysePlanStorage.setParameterValue(getAnalysePlan(analysePlanName), paramName, o); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, null, ex); + showMsgBox(ex); } } } @@ -615,7 +621,7 @@ * @param simulId id of the simulation to simulate * @param inQueue flag to say put in queue */ - public String simul(String simulId, SimulatorLauncher launcher) { + public void simul(String simulId, SimulatorLauncher launcher) { simulId += " " + dateFormat.format(new java.util.Date()); log.debug("call simulate"); try { @@ -630,8 +636,7 @@ } } catch (Exception eee) { log.error("Can't start simulation", eee); - return ("Error.xml" + "error" + eee.getMessage()); + showMsgBox(eee); } - return null; } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2008-12-15 17:46:56 UTC (rev 1674) @@ -34,8 +34,8 @@ <script><![CDATA[ import org.dom4j.DocumentHelper; import org.dom4j.Element; - public SimulUI(SimulAction action){ - + + public SimulUI(SimulAction action){ setContextValue(action); } protected void enablePreSimul(){ @@ -65,22 +65,21 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //This is where a real application would open the file. - String name = getContextValue(SimulAction.class).importSimulation(file); + getContextValue(SimulAction.class).importSimulation(file); refreshAll(); - paramsUI.setName(name); } } protected void saveSimulation(){ JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(null); + int returnVal = fc.showSaveDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //This is where a real application would open the file. -// getContextValue(SimulAction.class).saveSimulation(file); - Element result = DocumentHelper.createElement("simul"); - result.add(paramsUI.save()); - System.out.println(result.asXML()); + getContextValue(SimulAction.class).saveSimulation(file); +// Element result = DocumentHelper.createElement("simul"); +// result.add(paramsUI.save()); +// System.out.println(result.asXML()); } } ]]>
participants (1)
-
sletellier@users.labs.libre-entreprise.org