From sletellier@users.labs.libre-entreprise.org Mon Jun 15 00:25:47 2026 From: sletellier@users.labs.libre-entreprise.org To: isis-fish-commits@list.isis-fish.org Subject: [Isis-fish-commits] r1674 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . input simulator Date: Mon, 15 Dec 2008 18:46:56 +0100 Message-ID: <20081215174656.E536F461BF2@labs.libre-entreprise.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6597908112803326281==" --===============6597908112803326281== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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.ja= xx 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.j= axx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 20= 08-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 20= 08-12-15 17:46:56 UTC (rev 1674) @@ -33,15 +33,10 @@ Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.= jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2= 008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2= 008-12-15 17:46:56 UTC (rev 1674) @@ -30,7 +30,7 @@ * by : $Author: sletellier $ */ --> - + =20 =20 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.j= axx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 20= 08-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 20= 08-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 =3D new IsisMapBean(); protected OpenMapToolPanel toolMap =3D new OpenMapToolPanel(); protected OMToolSet toolSet =3D new OMToolSet(); + protected MapMouseListener mapListener =3D null; =20 public ZoneUI (InputAction action){ =20 @@ -116,7 +120,7 @@ int i =3D 0; for (Cell c : cellsSelected){ indexs[i] =3D zoneCellsModel.indexOf(c); - if (log.isDebugEnabled()) { =20 + if (log.isDebugEnabled()) { log.debug("refresh " + c + " " + i); } i++; @@ -139,17 +143,85 @@ zoneMap.setFisheryRegion(getContextValue(InputAction.class).getFishe= ryRegion()); 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 =3D=3D null){ + mapListener =3D new MapMouseListener() { + @Override + public boolean mouseClicked(MouseEvent e) { + java.util.List cells =3D (java.util.List) zo= neMap.getSelectedCells(); + if (cells !=3D null){ + int[] indexs =3D new int[cells.size()]; + int i =3D 0; + for (Cell c : cells){ + indexs[i] =3D ((DefaultListModel)zoneCells.getMo= del()).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 cells =3D new ArrayList(); - for (Object o : zoneCells.getSelectedValues()){ - cells.add((Cell) o ); + if (getContextValue(InputAction.class).getZone() !=3D null){ + zoneMap.setSelectedCells(getContextValue(InputAction.class).getZ= one().getCell()); } - zoneMap.setSelectedCells(cells); } protected void create(){ TopiaEntity topia =3D getContextValue(InputAction.class).create("Zon= e"); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Para= msUI.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.j= axx 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.j= axx 2008-12-15 17:46:56 UTC (rev 1674) @@ -89,7 +89,7 @@ if(selected !=3D null && !selected.trim().isEmpty()) { WelcomePanelUI root =3D getParentContainer(WelcomePanelUI.class); root.setInfoText(_("isisfish.message.loading.region")); - showMsgBox(getContextValue(SimulAction.class).regionChange(fieldSim= ulParamsRegion.getSelectedItem().toString())); + getContextValue(SimulAction.class).regionChange(fieldSimulParamsReg= ion.getSelectedItem().toString()); refresh(); root.setInfoText(_("isisfish.message.region.loaded")); } @@ -103,7 +103,7 @@ if (selected !=3D null && !selected.equals(" ")){ WelcomePanelUI root =3D 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(fieldSimulParams= Name.getText(), (SimulatorLauncher)comboSelLauncher.getSelectedItem())); + getContextValue(SimulAction.class).simul(fieldSimulParamsName.getTex= t(), (SimulatorLauncher)comboSelLauncher.getSelectedItem()); SimulUI simul =3D getParentContainer(SimulUI.class); simul.selTab(6); } @@ -148,13 +148,15 @@ } listSimulParamsStrategies.setModel(listSimulParamsStrategiesModel); java.util.List strategiesSelected =3D getContextValue(Simu= lAction.class).getSimulationParameter().getStrategies(); - int[] indexs =3D new int[listSimulParamsStrategiesModel.size()]; - int i =3D 0; - for (Strategy s : strategiesSelected){ - indexs[i] =3D listSimulParamsStrategiesModel.indexOf(s); - i++; + if (listSimulParamsStrategiesModel.size() !=3D 0){ + int[] indexs =3D new int[listSimulParamsStrategiesModel.size()]; + int i =3D 0; + for (Strategy s : strategiesSelected){ + indexs[i] =3D listSimulParamsStrategiesModel.indexOf(s); + i++; + } + listSimulParamsStrategies.setSelectedIndices(indexs); } - listSimulParamsStrategies.setSelectedIndices(indexs); } protected void setListSimulParamsPopulationsItems(){ DefaultListModel listSimulParamsPopulationsModel =3D new DefaultList= Model(); @@ -164,14 +166,16 @@ } listSimulParamsPopulations.setModel(listSimulParamsPopulationsModel); java.util.List populationsSelected =3D getContextValue(S= imulAction.class).getSimulationParameter().getPopulations(); - int[] indexs =3D new int[listSimulParamsPopulationsModel.size()]; - int i =3D 0; - for (Population p : populationsSelected){ - indexs[i] =3D listSimulParamsPopulationsModel.indexOf(p); - i++; + if (listSimulParamsPopulationsModel.size() !=3D 0){ + int[] indexs =3D new int[listSimulParamsPopulationsModel.size()]; + int i =3D 0; + for (Population p : populationsSelected){ + indexs[i] =3D listSimulParamsPopulationsModel.indexOf(p); + i++; + } + listSimulParamsPopulations.setSelectedIndices(indexs); + populationSelected(); } - listSimulParamsPopulations.setSelectedIndices(indexs); - populationSelected(); } protected void setRulesItems(){ listSimulParamsMesuresList.setListData(getContextValue(SimulAction.cl= ass).getRules().toArray()); @@ -241,11 +245,6 @@ } }); } - protected void showMsgBox(String txt){ - if (txt !=3D null){ - showMessageDialog(this, txt); - } - } protected void selectFilter(){ try { getContextValue(SimulAction.class).setOldSimulatorNames(fr.ifrem= er.isisfish.ui.simulator.filter.SimulationFilterUtil.filterSimulation(getCont= extValue(SimulAction.class).getOldSimulationItem())); @@ -352,7 +351,7 @@ - + @@ -387,7 +386,7 @@ - + @@ -531,12 +530,15 @@ - + - + + + + Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/Simu= lAction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulActio= n.java 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulActio= n.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 =3D 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 =3D name; } - protected String importSimulation(File f){ - String result =3D null; + protected void importSimulation(File f){ FileInputStream fos =3D null; try { fos =3D new FileInputStream(f); - BufferedReader br =3D new BufferedReader(new InputStreamReader(f= os)); - String line =3D br.readLine(); - if (line.matches("^#.*")){ - result =3D line.substring(1); - } - Properties proper =3D new Properties(); proper.load(fos); -// TODO : r=C3=A9parer -// param.fromProperties(proper); - simulName =3D 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.SEVE= RE, null, ex); + showMsgBox(ex); } } - return result; } protected void saveSimulation(File f){ FileOutputStream fos =3D 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.SEVE= RE, 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().get= Id())); } =20 - protected String viewLog(SimulationJob job) { + protected void viewLog(SimulationJob job) { String id =3D 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.getM= essage())); + showMsgBox(eee); } - return null; } =20 protected void clearDoneJobs() { @@ -227,7 +224,7 @@ * * @param regionName SimulationParameter/description */ - public String regionChange(String regionName) { + public void regionChange(String regionName) { try{ regionStorage =3D RegionStorage.getRegion(regionName); param.setRegionName(regionName); @@ -236,9 +233,8 @@ } } catch (Exception eee){ - return (_("isisfish.simulator.simulaction.regionChange",eee.getM= essage())); + showMsgBox(eee); } - return null; } =20 /** @@ -247,7 +243,7 @@ * @param simulName name of simulation to load * @return null 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 =3D simulName; @@ -258,9 +254,8 @@ regionStorage =3D 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; } =20 /* @@ -279,6 +274,7 @@ param.addRule(ruleTmp); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVERE, = null, ex); + showMsgBox(ex); } } public List getRuleNames() { @@ -295,6 +291,7 @@ result.add(RuleStorage.getName(r)); } catch (Exception ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVE= RE, null, ex); + showMsgBox(ex); } } return result; @@ -335,6 +332,7 @@ result =3D RuleStorage.getParameterValue(getRule(ruleName), = paramName); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVE= RE, 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.SEVE= RE, null, ex); + showMsgBox(ex); } } } @@ -357,6 +356,7 @@ result =3D RegionStorage.getFisheryRegion(param.getRegion().getS= torage().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 =3D AnalysePlanStorage.getParameterValue(getAnalysePl= an(analysePlanName), paramName); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVE= RE, null, ex); + showMsgBox(ex); } } return result; @@ -579,6 +584,7 @@ AnalysePlanStorage.setParameterValue(getAnalysePlan(analyseP= lanName), paramName, o); } catch (IsisFishException ex) { Logger.getLogger(SimulAction.class.getName()).log(Level.SEVE= RE, 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 +=3D " " + 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/Simu= lUI.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.ja= xx 2008-12-15 11:42:44 UTC (rev 1673) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.ja= xx 2008-12-15 17:46:56 UTC (rev 1674) @@ -34,8 +34,8 @@