r1670 - in isis-fish/trunk: . src/main/java/fr/ifremer/isisfish/ui/input src/test/java/fr/ifremer/isisfish/ui
Author: tchemit Date: 2008-12-15 00:59:49 +0000 (Mon, 15 Dec 2008) New Revision: 1670 Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/TestJaxx.java Modified: isis-fish/trunk/pom.xml isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java Log: little help to sylvain :) show how binding works on CellUI, in general we should not deal direclty with widget values but prefer data binding... reformat Inputaction always refresh InputAction value bump lutingenerator and topia versions Modified: isis-fish/trunk/pom.xml =================================================================== --- isis-fish/trunk/pom.xml 2008-12-13 10:24:41 UTC (rev 1669) +++ isis-fish/trunk/pom.xml 2008-12-15 00:59:49 UTC (rev 1670) @@ -309,10 +309,10 @@ <jaxx.version>0.8-SNAPSHOT</jaxx.version> <!-- generator version --> - <generator.version>0.62</generator.version> + <generator.version>0.63-SNAPSHOT</generator.version> <!-- topia version --> - <topia.version>2.1.0</topia.version> + <topia.version>2.1.1-SNAPSHOT</topia.version> <!-- lutinwidget version --> <lutinwidget.version>0.11</lutinwidget.version> @@ -384,6 +384,7 @@ </goals> <configuration> <src>${project.basedir}/src/main/java</src> + <addSourcesToClassPath>true</addSourcesToClassPath> </configuration> </execution> </executions> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2008-12-13 10:24:41 UTC (rev 1669) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2008-12-15 00:59:49 UTC (rev 1670) @@ -36,119 +36,92 @@ +--> <Table implements='InputContent'> - <!-- ui state when the activite is active --> + <!-- edit property --> <Boolean id='actif' javaBean='false'/> + <!-- change property --> <Boolean id='changed' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.CellImpl id='bean' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.Cell; - import com.bbn.openmap.gui.OMToolSet; - import fr.ifremer.isisfish.map.IsisMapBean; - import fr.ifremer.isisfish.map.OpenMapToolPanel; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.entities.Zone; - import fr.ifremer.isisfish.ui.WelcomePanelUI; +import fr.ifremer.isisfish.entities.Cell; +import fr.ifremer.isisfish.entities.CellImpl; +import com.bbn.openmap.gui.OMToolSet; +import fr.ifremer.isisfish.map.IsisMapBean; +import fr.ifremer.isisfish.map.OpenMapToolPanel; +import org.codelutin.topia.persistence.TopiaEntity; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.WelcomePanelUI; - protected IsisMapBean cellMap = new IsisMapBean(); - protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); - protected OMToolSet toolSet = new OMToolSet(); - - public CellUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - Cell cell = getContextValue(InputAction.class).getCell(); - DefaultComboBoxModel fieldCellModel = new DefaultComboBoxModel(); - java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); - for (Cell c : cells){ - fieldCellModel.addElement(c); - } - fieldCell.setModel(fieldCellModel); - if (cell != null){ - fieldCellName.setText(cell.getName()); - fieldCellLatitude.setText(cell.getLatitude()+""); - fieldCellLongitude.setText(cell.getLongitude()+""); - fieldCellLand.setSelected(cell.getLand()); - fieldCellComment.setText(getContextValue(InputAction.class).getCell().getComment()); +protected IsisMapBean cellMap = new IsisMapBean(); +protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); +protected OMToolSet toolSet = new OMToolSet(); - cellMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); - toolSet.setupListeners(cellMap); - toolMap.add((Component)toolSet); - cellMapPanel.add(toolMap, BorderLayout.NORTH); - cellMapPanel.add(cellMap, BorderLayout.CENTER); - cellMap.setSelectedCells(cell); - valueChanged(false); - } - else { - +addPropertyChangeListener("bean", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getOldValue() != null || evt.getNewValue() == null) { + // remove previous binding on getBean() + jaxx.runtime.Util.removeDataBinding($Table0, "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldCellName.setText(""); fieldCellLatitude.setText(""); fieldCellLongitude.setText(""); fieldCellComment.setText(""); - - cellMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); - toolSet.setupListeners(cellMap); - toolMap.add((Component)toolSet); - cellMapPanel.add(toolMap, BorderLayout.NORTH); - cellMapPanel.add(cellMap, BorderLayout.CENTER); - valueChanged(false); + fieldCellLand.setSelected(false); } + if (evt.getNewValue() != null) { + // add binding on getBean() + jaxx.runtime.Util.applyDataBinding($Table0, "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$cells/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); +}); + +public void refresh() { + InputAction action = getContextValue(InputAction.class); + setBean(null); + Cell cell = action.getCell(); + setBean((CellImpl) cell); + jaxx.runtime.swing.Utils.fillComboBox(fieldCell,action.getFisheryRegion().getCell(), cell); + + cellMap.setFisheryRegion(action.getFisheryRegion()); + toolSet.setupListeners(cellMap); + toolMap.add((Component)toolSet); + cellMapPanel.add(toolMap, BorderLayout.NORTH); + cellMapPanel.add(cellMap, BorderLayout.CENTER); + + if (cell != null){ + cellMap.setSelectedCells(cell); } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); + setChanged(false); +} + +protected void save() { + TopiaEntity topia = getContextValue(InputAction.class).save(); + getParentContainer(InputUI.class).repaintNode("$root/$cells/" + topia.getTopiaId()); + refresh(); + getParentContainer(WelcomePanelUI.class).setInfoText(_("isisfish.message.save.finished")); +} + +protected void cancel() { + getContextValue(InputAction.class).cancel(); + refresh(); + getParentContainer(WelcomePanelUI.class).setInfoText(_("isisfish.message.cancel.finished")); +} + +protected void fieldCellChanged() { + Cell c = (Cell)fieldCell.getSelectedItem(); + if (c==null) { + return; } - protected void goToZone(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$zones"); + Cell oldC = getBean(); + if (oldC != null && c.getTopiaId().equals(oldC.getTopiaId())) { + // avoid reentrant code + return; } - protected void valueChanged(boolean b){ - //TODO remove method valueChanged - // must use the setter to fire property changes, and make possible bindings - setChanged(b); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void fieldCellChanged(){ - Cell c = (Cell)fieldCell.getSelectedItem(); - getContextValue(InputAction.class).setValue(c); - getParentContainer(InputUI.class).setTreeSelection("$root/$cells/"+c.getTopiaId()); - //fixme no :) as you select a new node, you should not do anything more on ui ? - refresh(); - valueChanged(true); - } - protected void nameChanged(){ - getContextValue(InputAction.class).getCell().setName(fieldCellName.getText()); - //fixme no :) use a propertyChangeListener on the bean - refresh(); - valueChanged(true); - } - protected void cellLandChanged(){ - getContextValue(InputAction.class).getCell().setLand(fieldCellLand.isSelected()); - //fixme no :) use a propertyChangeListener on the bean - refresh(); - valueChanged(true); - } - protected void commentChanged(){ - getContextValue(InputAction.class).getCell().setComment(fieldCellComment.getText()); - //fixme no :) use a propertyChangeListener on the bean - refresh(); - valueChanged(true); - } - ]]> - </script> + getParentContainer(InputUI.class).setTreeSelection("$root/$cells/"+c.getTopiaId()); +} +]]></script> <row> <cell fill='both' weighty='1.0' weightx='1.0'> <JSplitPane id="CellTab" name="Cells" @@ -156,7 +129,7 @@ <Table> <row> <cell fill='horizontal' columns='2' weightx='1.0'> - <JComboBox id="fieldCell" onActionPerformed='fieldCellChanged()' enabled='{isActif()}'/> + <JComboBox id="fieldCell" onActionPerformed='fieldCellChanged()' model='{new DefaultComboBoxModel()}'/> </cell> </row> <row> @@ -164,7 +137,7 @@ <JLabel text="isisfish.cell.name" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> + <JTextField id="fieldCellName" text='{getBean().getName()}' onKeyTyped='setChanged(true)' onFocusLost='if (isChanged()) {getBean().setName(fieldCellName.getText());}' enabled='{isActif()}'/> </cell> </row> <row> @@ -172,7 +145,7 @@ <JLabel text="isisfish.cell.latitude" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLatitude" editable="false" enabled='{isActif()}'/> + <JTextField id="fieldCellLatitude" text='{getBean().getLatitude()}' editable="false" enabled='{isActif()}'/> </cell> </row> <row> @@ -180,7 +153,7 @@ <JLabel text="isisfish.cell.longitude" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLongitude" editable="false" enabled='{isActif()}'/> + <JTextField id="fieldCellLongitude" text='{getBean().getLongitude()}' editable="false" enabled='{isActif()}'/> </cell> </row> <row> @@ -188,7 +161,7 @@ <JLabel text="isisfish.cell.land" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldCellLand" onActionPerformed='cellLandChanged()' enabled='{isActif()}'/> + <JCheckBox id="fieldCellLand" onActionPerformed='setChanged(true); getBean().setLand(fieldCellLand.isSelected());' enabled='{isActif()}' selected='{getBean().getLand()}'/> </cell> </row> <row> @@ -199,7 +172,7 @@ <row> <cell columns='2' fill='both' weighty='1.0' weightx='1.0'> <JScrollPane> - <JTextArea id="fieldCellComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> + <JTextArea id="fieldCellComment" text='{jaxx.runtime.Util.getStringValue(getBean().getComment())}' onKeyTyped='setChanged(true)' onFocusLost='if (isChanged()) { getBean().setComment(fieldCellComment.getText()); }' enabled='{isActif()}'/> </JScrollPane> </cell> </row> @@ -218,7 +191,7 @@ </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueZones" onActionPerformed='goToZone()'/> + <JButton text="isisfish.input.continueZones" onActionPerformed='getParentContainer(InputUI.class).setTreeSelection("$root/$zones")'/> </cell> </row> </Table> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-12-13 10:24:41 UTC (rev 1669) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-12-15 00:59:49 UTC (rev 1670) @@ -37,58 +37,23 @@ import fr.ifremer.isisfish.IsisFishDAOHelper; import fr.ifremer.isisfish.IsisFishEntityEnum; import fr.ifremer.isisfish.datastore.FormuleStorage; -import java.util.List; - import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.datastore.StorageException; import fr.ifremer.isisfish.datastore.update.ImportFromV2; -import fr.ifremer.isisfish.entities.Cell; -import fr.ifremer.isisfish.entities.CellDAO; -import fr.ifremer.isisfish.entities.EffortDescription; -import fr.ifremer.isisfish.entities.EffortDescriptionDAO; -import fr.ifremer.isisfish.entities.Equation; -import fr.ifremer.isisfish.entities.FisheryRegion; -import fr.ifremer.isisfish.entities.Formule; -import fr.ifremer.isisfish.entities.Gear; -import fr.ifremer.isisfish.entities.Metier; -import fr.ifremer.isisfish.entities.MetierSeasonInfo; -import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.PopulationDAO; -import fr.ifremer.isisfish.entities.PopulationGroup; -import fr.ifremer.isisfish.entities.PopulationSeasonInfo; -import fr.ifremer.isisfish.entities.Port; -import fr.ifremer.isisfish.entities.Selectivity; -import fr.ifremer.isisfish.entities.SelectivityDAO; -import fr.ifremer.isisfish.entities.SetOfVessels; -import fr.ifremer.isisfish.entities.Species; -import fr.ifremer.isisfish.entities.Strategy; -import fr.ifremer.isisfish.entities.TargetSpecies; -import fr.ifremer.isisfish.entities.TargetSpeciesDAO; -import fr.ifremer.isisfish.entities.TripType; -import fr.ifremer.isisfish.entities.VesselType; -import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.entities.*; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.ui.input.check.CheckRegion; import fr.ifremer.isisfish.ui.input.check.CheckResult; import fr.ifremer.isisfish.ui.input.check.CheckResultFrame; +import static fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil.selectSimulation; import fr.ifremer.isisfish.ui.widget.ErrorDialogUI; import fr.ifremer.isisfish.util.CellPointcomparator; -import java.awt.geom.Point2D; -import java.io.File; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.lang.ClassUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import static org.codelutin.i18n.I18n._; import org.codelutin.math.matrix.MatrixFactory; import org.codelutin.math.matrix.MatrixND; import org.codelutin.topia.TopiaContext; @@ -97,14 +62,21 @@ import org.codelutin.topia.persistence.TopiaEntity; import org.codelutin.util.FileUtil; import org.codelutin.widget.editor.Editor; -import static org.codelutin.i18n.I18n._; + +import javax.swing.JOptionPane; import static javax.swing.JOptionPane.showInputDialog; -import static fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil.selectSimulation; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import java.awt.geom.Point2D; +import java.io.File; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; -/** - * - * @author letellier - */ +/** @author letellier */ public class InputAction { /** to use log facility, just put in your code: log.info(\"...\"); */ @@ -132,82 +104,90 @@ log.debug("new instance"); } } - protected void showMsgBox(Exception eee){ + + protected void showMsgBox(Exception eee) { ErrorDialogUI.showError(eee); } + public void setValue(Object value) { -// cell = null; -// zone = null; -// port = null; -// species = null; -// population = null; -// gear = null; -// metier = null; -// tripType = null; -// vesselType = null; -// setOfVessels = null; -// strategy = null; -// selected=null; - if (!(value instanceof TopiaEntity)) { - // this is not a TopiaEntity value, so quit - isNull = true; - return; - } - isNull = false; - switch (IsisFishEntityEnum.valueOf(value.getClass())){ - case Zone: - zone = (Zone) value; + if (value == null || !(value instanceof TopiaEntity)) { + // this is not a TopiaEntity value, or a null value : so quit + isNull = true; + cell = null; + zone = null; + port = null; + species = null; + population = null; + gear = null; + metier = null; + tripType = null; + vesselType = null; + setOfVessels = null; + strategy = null; + selected = null; + return; + } + isNull = false; + switch (IsisFishEntityEnum.valueOf(value.getClass())) { + case Zone: + zone = (Zone) value; break; - case Cell: - cell = (Cell) value; + case Cell: + cell = (Cell) value; break; - case Port: - port = (Port) value; + case Port: + port = (Port) value; break; - case Species: - species = (Species) value; + case Species: + species = (Species) value; break; - case Population: - population = (Population) value; - species = population.getSpecies(); + case Population: + population = (Population) value; + species = population.getSpecies(); break; - case Metier: - metier = (Metier) value; + case Metier: + metier = (Metier) value; break; - case TripType: - tripType = (TripType) value; + case TripType: + tripType = (TripType) value; break; - case Gear: - gear = (Gear) value; + case Gear: + gear = (Gear) value; break; - case VesselType: - vesselType = (VesselType) value; + case VesselType: + vesselType = (VesselType) value; break; - case SetOfVessels: - setOfVessels = (SetOfVessels) value; + case SetOfVessels: + setOfVessels = (SetOfVessels) value; break; - case Strategy: - strategy = (Strategy) value; + case Strategy: + strategy = (Strategy) value; break; - } - selected = (TopiaEntity) value; + } + selected = (TopiaEntity) value; } - public boolean isNull(){ + + public boolean isNull() { return isNull; } - public void setPath(String path){ + + public void setPath(String path) { this.path = path; } - public String getPath(){ + + public String getPath() { return path; } - public TopiaContext getIsisContext(){ + + public TopiaContext getIsisContext() { return isisContext; } - public RegionStorage getRegionStorage(){ + + public RegionStorage getRegionStorage() { return regionStorage; } - public void setSpecies(String topiaId){ + + public void setSpecies(String topiaId) { try { species = IsisFishDAOHelper.getSpeciesDAO(isisContext).findByTopiaId(topiaId); } catch (TopiaException ex) { @@ -215,75 +195,75 @@ } } - /** - * Exporter la region dans un zip - * - * @return - */ - public File importRegion() { + /** + * Exporter la region dans un zip + * + * @return TODO + */ + public File importRegion() { File file = null; - try { - file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); - if (file != null) { - RegionStorage.importZip(file); - } - } catch (Exception eee) { - log.error("Can't import region", eee); + try { + file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); + if (file != null) { + RegionStorage.importZip(file); + } + } catch (Exception eee) { + log.error("Can't import region", eee); showMsgBox(eee); - } - return file; - } + } + return file; + } - /** - * Exporter la region dans un zip - * - * @return - */ - public File importRegionAndRename() { + /** + * Exporter la region dans un zip + * + * @return TODO + */ + public File importRegionAndRename() { File file = null; - try { - file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); - if (file != null) { + try { + file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); + if (file != null) { - String newName = + String newName = showInputDialog(_("isisfish.message.name.imported.region")); - RegionStorage.importAndRenameZip(file, newName); - } - } catch (Exception eee) { - log.error("Can't import region", eee); + RegionStorage.importAndRenameZip(file, newName); + } + } catch (Exception eee) { + log.error("Can't import region", eee); showMsgBox(eee); - } - return file; - } + } + return file; + } - /** - * Importer la region depuis un fichier XML de la version 2 - * - * @return - */ - public File importV2Region() { + /** + * Importer la region depuis un fichier XML de la version 2 + * + * @return TODO + */ + public File importV2Region() { File file = null; - try { - file = FileUtil.getFile(".*.xml$", _("isisfish.message.import.region.xml")); - if (file != null) { + try { + file = FileUtil.getFile(".*.xml$", _("isisfish.message.import.region.xml")); + if (file != null) { - new ImportFromV2(true).importXML(file); + new ImportFromV2(true).importXML(file); - } - } catch (Exception eee) { - log.error("Can't import region", eee); + } + } catch (Exception eee) { + log.error("Can't import region", eee); showMsgBox(eee); - } - return file; - } + } + return file; + } - /** - * Extract from a simulation the region, and rename it with name given + /** + * Extract from a simulation the region, and rename it with name given * by user. - * - * return msg - */ + * + * @return msg + */ public String importRegionFromSimulation() { // first step select a simulation and new region name @@ -308,7 +288,7 @@ } // ask new region name - String regionName = showInputDialog(_("isisfish.message.import.region.name"),"region from "+simulationName); + String regionName = showInputDialog(_("isisfish.message.import.region.name"), "region from " + simulationName); if (regionName == null || "".equals(regionName)) { return null; } @@ -330,118 +310,115 @@ return regionName; } - /** - * Exporter la region dans un zip - * - * @return - */ - public File exportRegion() { + /** + * Exporter la region dans un zip + * + * @return TODO + */ + public File exportRegion() { File file = null; - try { - file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); - if (file != null) { - int resp = JOptionPane.YES_OPTION; - if (file.exists()) { - resp = JOptionPane.showConfirmDialog(null, - _("isisfish.message.file.overwrite")); - } - if (resp == JOptionPane.YES_OPTION) { - regionStorage.createZip(file); - } - } - } catch (Exception eee) { - log.error("Can't export region", eee); + try { + file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); + if (file != null) { + int resp = JOptionPane.YES_OPTION; + if (file.exists()) { + resp = JOptionPane.showConfirmDialog(null, + _("isisfish.message.file.overwrite")); + } + if (resp == JOptionPane.YES_OPTION) { + regionStorage.createZip(file); + } + } + } catch (Exception eee) { + log.error("Can't export region", eee); showMsgBox(eee); - } - return file; - } + } + return file; + } - /** - * Copy la region avec un autre nom - * - * @return - */ - public String copyRegion() { + /** + * Copy la region avec un autre nom + * + * @return TODO + */ + public String copyRegion() { String newName = null; - try { - newName = showInputDialog(_("isisfish.message.new.region.name")); + try { + newName = showInputDialog(_("isisfish.message.new.region.name")); - File zip = regionStorage.createZip(); - RegionStorage.importAndRenameZip(zip, newName); + File zip = regionStorage.createZip(); + RegionStorage.importAndRenameZip(zip, newName); - } catch (Exception eee) { - log.error("Can't copy region", eee); + } catch (Exception eee) { + log.error("Can't copy region", eee); showMsgBox(eee); - } - return newName; - } + } + return newName; + } - /** - * Remove region - * - * @param cvsDelete - * if true delete region in CVS too - * @return - */ - public String removeRegion(boolean cvsDelete) { + /** + * Remove region + * + * @param cvsDelete if true delete region in CVS too + * @return TODO + */ + public String removeRegion(boolean cvsDelete) { String result = null; - try { - int resp = JOptionPane.showConfirmDialog(null, _( - "isisfish.message.confirm.remove.region", - regionStorage.getName())); - if (resp == JOptionPane.YES_OPTION) { - regionStorage.delete(cvsDelete); - result = _("isisfish.message.region.removed"); + try { + int resp = JOptionPane.showConfirmDialog(null, _( + "isisfish.message.confirm.remove.region", + regionStorage.getName())); + if (resp == JOptionPane.YES_OPTION) { + regionStorage.delete(cvsDelete); + result = _("isisfish.message.region.removed"); - } else { - result = _("isisfish.message.region.remove.canceled"); - } - } catch (Exception eee) { - log.error("Can't remove region", eee); + } else { + result = _("isisfish.message.region.remove.canceled"); + } + } catch (Exception eee) { + log.error("Can't remove region", eee); showMsgBox(eee); - } - return result; - } + } + return result; + } - /** - * Remove region - * - * @return - */ - public String commitRegionInCVS() { + /** + * Remove region + * + * @return TODO + */ + public String commitRegionInCVS() { String result = null; - try { - String msg = regionStorage.getCommentForNextCommit(); - JTextArea text = new JTextArea(msg); - int resp = JOptionPane.showOptionDialog(null, - new JScrollPane(text), _("isisfish.commit.message"), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, - null, // icon - null, null); - if (resp == JOptionPane.OK_OPTION) { - regionStorage.commit(text.getText()); - regionStorage.clearCommentForNextCommit(); - result = _("isisfish.message.region.commited"); - } else { - result = _("isisfish.message.commit.region.canceled"); - } - } catch (Exception eee) { - log.error("Can't export region", eee); + try { + String msg = regionStorage.getCommentForNextCommit(); + JTextArea text = new JTextArea(msg); + int resp = JOptionPane.showOptionDialog(null, + new JScrollPane(text), _("isisfish.commit.message"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, + null, // icon + null, null); + if (resp == JOptionPane.OK_OPTION) { + regionStorage.commit(text.getText()); + regionStorage.clearCommentForNextCommit(); + result = _("isisfish.message.region.commited"); + } else { + result = _("isisfish.message.commit.region.canceled"); + } + } catch (Exception eee) { + log.error("Can't export region", eee); showMsgBox(eee); - } - return result; - } + } + return result; + } /** * load region. - * <p> + * <p/> * RegionStorage, TopiaContext, FisheryRegion are put in uiContext data. - * <p> + * <p/> * tree ans * - * @param name - * name of region - * @return if ok return null else OutView error + * @param name name of region */ public void loadRegion(String name) { if (log.isTraceEnabled()) { @@ -466,77 +443,75 @@ * Create new region, and select it in combo, and show input pane region in * input area. * - * @param name - * name of the new region - * @return if ok return null else OutView error + * @param name name of the new region */ public void newRegion(String name) { if (log.isTraceEnabled()) { log.trace("newRegion called"); } try { - if ("".equals(name)) { + if ("".equals(name)) { // showMsgBox("error " + _("isisfish.error.region.name.empty")); - } - if (RegionStorage.getRegionNames().contains(name)) { + } + if (RegionStorage.getRegionNames().contains(name)) { // showMsgBox("Error " + _("isisfish.error.region.already.exists")); - } - RegionStorage.create(name); - } catch (Exception eee) { - log.error("Can't create region", eee); - showMsgBox(eee); } + RegionStorage.create(name); + } catch (Exception eee) { + log.error("Can't create region", eee); + showMsgBox(eee); + } } /** * If some entities has been modified by the user (EntityModified state is * true) then ask the user if he want save, don't save modification, or * cancel current wanted action. - * + * <p/> * If this method return true, only button (save, cancel) will be refreshed * not the current input panel - * + * <p/> * if this method return false, nothing is do * * @return false if user want cancel action, true otherwize */ protected boolean askForSave() { - boolean result = true; - return result; + return true; } /** * Permet de creer simplement un nouvelle objet portant un nom par defaut. * Le nouvel element est automatiquement selectionné dans l'arbre * - * @param type - * le type de l'entite a creer, le type est compose seulement du - * nom de l'entite et pas du package. + * @param type le type de l'entite a creer, le type est compose seulement du + * nom de l'entite et pas du package. * @return null ou un fenetre d'erreur */ @SuppressWarnings("unchecked") public TopiaEntity create(String type) { - if (log.isTraceEnabled()) { - log.trace("create called for " + type); - } - try { - String name = type + "_new"; + if (log.isTraceEnabled()) { + log.trace("create called for " + type); + } + try { + //TODO use the IsisFishEntityEnum for this purpose : + //TopiaDAO<TopiaEntity> dao = IsisFishEntityEnum.getEntry(type).getDAO(isisContext); + String name = type + "_new"; - Method method = MethodUtils.getAccessibleMethod( - IsisFishDAOHelper.class, "get" + type + "DAO", - TopiaContext.class); - TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) method.invoke(null, new Object[] { isisContext }); + Method method = MethodUtils.getAccessibleMethod( + IsisFishDAOHelper.class, "get" + type + "DAO", + TopiaContext.class); + TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) method.invoke(null, isisContext); - TopiaEntity entity = dao.create("name", name); - entity.update(); - isisContext.commitTransaction(); - return entity; + TopiaEntity entity = dao.create("name", name); + entity.update(); + isisContext.commitTransaction(); + return entity; - } catch (Exception eee) { - log.error("Can't create entity", eee); - showMsgBox(eee); - } - return null; + } catch (Exception eee) { + log.error("Can't create entity", eee); + showMsgBox(eee); + } + return null; } /** @@ -545,26 +520,26 @@ * @return the saved entity */ public TopiaEntity save() { - if (log.isTraceEnabled()) { - log.trace("save called"); + if (log.isTraceEnabled()) { + log.trace("save called"); + } + try { + if (selected == null) { + log.warn("Try to save null entity"); + return null; } - try { - if (selected == null) { - log.warn("Try to save null entity"); - return null; - } - // on est pas en autoUpdate donc il faut faire le update avant le - // commit - selected.update(); + // on est pas en autoUpdate donc il faut faire le update avant le + // commit + selected.update(); - selected.getTopiaContext().commitTransaction(); - } catch (Exception eee) { - log.error("Can't save region", eee); - showMsgBox(eee); - } - return selected; + selected.getTopiaContext().commitTransaction(); + } catch (Exception eee) { + log.error("Can't save region", eee); + showMsgBox(eee); + } + return selected; } - + /** * Cancel all modification on entity (rollback), and force reload it and * refresh all ui component that name match 'type'Tab @@ -572,146 +547,145 @@ * @return the roolbacked entity */ public TopiaEntity cancel() { - if (log.isTraceEnabled()) { - log.trace("cancel called"); - } - try { - isisContext.rollbackTransaction(); + if (log.isTraceEnabled()) { + log.trace("cancel called"); + } + try { + isisContext.rollbackTransaction(); - // reload the object - if (selected != null) { - selected = isisContext.findByTopiaId(selected.getTopiaId()); - setValue(selected); - } - } catch (Exception eee) { - log.error("Can't cancel modification in region", eee); - showMsgBox(eee); + // reload the object + if (selected != null) { + selected = isisContext.findByTopiaId(selected.getTopiaId()); + setValue(selected); } - return selected; + } catch (Exception eee) { + log.error("Can't cancel modification in region", eee); + showMsgBox(eee); + } + return selected; } /** * Delete one entity and commit the change, try to selected intelligently * other node in tree. - * <p> + * <p/> * Refresh all ui component where name match "input<entity type without * package >.*" * * @return if ok return null else OutView error */ public String remove() { - if (log.isTraceEnabled()) { - log.trace("remove called"); - } - String msg = ""; - try { - boolean doDelete = true; - List<TopiaEntity> allWillBeRemoved = selected.getComposite(); - if (allWillBeRemoved.size() > 0) { - String text = _( - "isisfish.message.delete.object", - selected.toString()); - for (TopiaEntity e : allWillBeRemoved) { - text += ClassUtils.getShortClassName(e.getClass()) + " - " - + e.toString() + "\n"; - } - int resp = JOptionPane.showConfirmDialog(null, text, - _("isisfish.message.delete.entities"), JOptionPane.YES_NO_OPTION); - doDelete = resp == JOptionPane.YES_OPTION; - } else { - String text = _("isisfish.message.confirm.delete.object", selected.toString()); - int resp = JOptionPane.showConfirmDialog(null, text, - _("isisfish.message.delete.entity"), JOptionPane.YES_NO_OPTION); - doDelete = resp == JOptionPane.YES_OPTION; + if (log.isTraceEnabled()) { + log.trace("remove called"); + } + String msg = ""; + try { + boolean doDelete; + List<TopiaEntity> allWillBeRemoved = selected.getComposite(); + if (allWillBeRemoved.size() > 0) { + String text = _( + "isisfish.message.delete.object", + selected.toString()); + for (TopiaEntity e : allWillBeRemoved) { + text += ClassUtils.getShortClassName(e.getClass()) + " - " + + e.toString() + "\n"; } + int resp = JOptionPane.showConfirmDialog(null, text, + _("isisfish.message.delete.entities"), JOptionPane.YES_NO_OPTION); + doDelete = resp == JOptionPane.YES_OPTION; + } else { + String text = _("isisfish.message.confirm.delete.object", selected.toString()); + int resp = JOptionPane.showConfirmDialog(null, text, + _("isisfish.message.delete.entity"), JOptionPane.YES_NO_OPTION); + doDelete = resp == JOptionPane.YES_OPTION; + } - if (doDelete) { - selected.delete(); - isisContext.commitTransaction(); - msg = _("isisfish.message.remove.finished"); - } else { - msg = _("isisfish.message.remove.canceled"); - } - } catch (Exception eee) { - log.error("Can't remove entity: " + selected, eee); - showMsgBox(eee); + if (doDelete) { + selected.delete(); + isisContext.commitTransaction(); + msg = _("isisfish.message.remove.finished"); + } else { + msg = _("isisfish.message.remove.canceled"); } - return msg; + } catch (Exception eee) { + log.error("Can't remove entity: " + selected, eee); + showMsgBox(eee); + } + return msg; } - /** - * Save an Equation as model, to reuse it for other equation - * - * @param eq - * equation to put in models - * @return if ok return null else OutputView error message - */ - public Object saveEquationAsModel(Equation eq) { - try { - if (eq != null) { - String name = showInputDialog(""); - if ("".equals(name)) { + /** + * Save an Equation as model, to reuse it for other equation + * + * @param eq equation to put in models + * @return if ok return null else OutputView error message + */ + public Object saveEquationAsModel(Equation eq) { + try { + if (eq != null) { + String name = showInputDialog(""); + if ("".equals(name)) { // showMsgBox("Error " +_("isisfish.error.invalid.equation.name")); - } - if (name != null) { - FormuleStorage storage = FormuleStorage.createFormule(eq - .getCategory(), name, eq.getLanguage()); - storage.setContent(eq.getContent()); - } - } - } catch (Exception eee) { - log.error("Can't save equation as model", eee); - showMsgBox(eee); - } - return null; - } + } + if (name != null) { + FormuleStorage storage = FormuleStorage.createFormule(eq + .getCategory(), name, eq.getLanguage()); + storage.setContent(eq.getContent()); + } + } + } catch (Exception eee) { + log.error("Can't save equation as model", eee); + showMsgBox(eee); + } + return null; + } /** * Save an Equation as model, to reuse it for other equation * - * @param category - * category for this equation - * @param language - * equation to put in models - * @param content content ? + * @param category category for this equation + * @param language equation to put in models + * @param content content ? * @return if ok return null else OutputView error message */ public Object saveAsModel(String category, String language, String content) { - try { - String name = showInputDialog(""); - if ("".equals(name)) { + try { + String name = showInputDialog(""); + if ("".equals(name)) { // showMsgBox("Error " +_("isisfish.error.invalid.equation.name")); - } - if (name != null) { - FormuleStorage storage = FormuleStorage.createFormule(category, name, language); - storage.setContent(content); - } - - } catch (Exception eee) { - log.error("Can't save equation as model", eee); - showMsgBox(eee); } - return null; + if (name != null) { + FormuleStorage storage = FormuleStorage.createFormule(category, name, language); + storage.setContent(content); + } + + } catch (Exception eee) { + log.error("Can't save equation as model", eee); + showMsgBox(eee); + } + return null; } + public Object openEditor(String category, String name, - Class javaInterface, String content, Editor editor) { - if (log.isTraceEnabled()) { - log.trace("openEditor"); + Class javaInterface, String content, Editor editor) { + if (log.isTraceEnabled()) { + log.trace("openEditor"); + } + try { + EquationEditorPaneUI pane = new EquationEditorPaneUI(); + pane.setEquation(category, name, javaInterface, content); + pane.setVisible(true); + if (pane.isOk() && editor != null) { + editor.setText(pane.getEditor().getText()); } - try { - EquationEditorPaneUI pane = new EquationEditorPaneUI(); - pane.setEquation(category, name, javaInterface, content); - pane.setVisible(true); - if (pane.isOk() && editor != null) { - editor.setText(pane.getEditor().getText()); - } - pane.dispose(); - } catch (Exception eee) { - log.error("Can't open editor", eee); - showMsgBox(eee); - } - return null; + pane.dispose(); + } catch (Exception eee) { + log.error("Can't open editor", eee); + showMsgBox(eee); + } + return null; } + protected String getFisheryRegionName() { if (fisheryRegion != null) { return fisheryRegion.getName(); @@ -722,8 +696,8 @@ protected FisheryRegion getFisheryRegion() { return fisheryRegion; } - - protected TopiaEntity getSelected(){ + + protected TopiaEntity getSelected() { return selected; } @@ -770,51 +744,52 @@ protected Strategy getStrategy() { return strategy; } - protected List<Formule> getFormules(String name){ + + protected List<Formule> getFormules(String name) { return FormuleStorage.getFormules(isisContext, name); } - + // InputGear - + public Object addSelectivity(Population pop, String equation) { try { - + SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(isisContext); Selectivity selectivity = dao.create(); - + selectivity.setGear(gear); selectivity.setPopulation(pop); selectivity.getEquation().setContent(equation); selectivity.update(); - + gear.addPopulationSelectivity(selectivity); gear.update(); - + } catch (Exception eee) { log.error("Can't add selectivity", eee); showMsgBox(eee); } return null; } - - public Object removeSelectivity(Selectivity selectivity){ - if (log.isTraceEnabled()) { + + public Object removeSelectivity(Selectivity selectivity) { + if (log.isTraceEnabled()) { log.trace("removeTargetSpecies called: " + selectivity); } try { if (gear != null && selectivity != null) { gear.removePopulationSelectivity(selectivity); } - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't remove TargetSpecies", eee); showMsgBox(eee); } return null; } - + // InputMetier - - public Object createSeasonInfo(){ + + public Object createSeasonInfo() { if (log.isTraceEnabled()) { log.trace("createSeasonInfo called"); } @@ -828,14 +803,14 @@ metier.update(); // isisContext.commitTransaction(); - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't create MetierSeasonInfo", eee); showMsgBox(eee); } return null; } - public Object removeSeasonInfo(MetierSeasonInfo info){ + public Object removeSeasonInfo(MetierSeasonInfo info) { if (log.isTraceEnabled()) { log.trace("createSeasonInfo called"); } @@ -843,33 +818,33 @@ metier.removeMetierSeasonInfo(info); metier.update(); isisContext.commitTransaction(); - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't create MetierSeasonInfo", eee); showMsgBox(eee); } return null; } - - public Object addTargetSpecies(MetierSeasonInfo m, Species species, String targetFactorEquation, boolean primaryCatch){ - if (log.isTraceEnabled()) { + + public Object addTargetSpecies(MetierSeasonInfo m, Species species, String targetFactorEquation, boolean primaryCatch) { + if (log.isTraceEnabled()) { log.trace("addTargetSpecies called: " + metier + " " + species + " " + primaryCatch + " " + targetFactorEquation); } try { TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(isisContext); TargetSpecies targetSpecies = dao.create(); - + targetSpecies.setSpecies(species); targetSpecies.getTargetFactorEquation().setContent(targetFactorEquation); targetSpecies.setPrimaryCatch(primaryCatch); m.addSpeciesTargetSpecies(targetSpecies); - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't add TargetSpecies", eee); showMsgBox(eee); } return null; } - - public Object removeTargetSpecies(MetierSeasonInfo m, TargetSpecies targetSpecies){ + + public Object removeTargetSpecies(MetierSeasonInfo m, TargetSpecies targetSpecies) { if (log.isTraceEnabled()) { log.trace("removeTargetSpecies called: " + targetSpecies); } @@ -877,7 +852,7 @@ if (targetSpecies != null) { m.removeSpeciesTargetSpecies(targetSpecies); } - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't remove TargetSpecies", eee); showMsgBox(eee); } @@ -886,8 +861,8 @@ // SetOfVessels - public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) { - if (log.isTraceEnabled()) { + public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) { + if (log.isTraceEnabled()) { log.trace("addEffortDescription called: " + setOfVessels + " metier: " + metier); } try { @@ -897,14 +872,14 @@ effortDescription.update(); setOfVessels.addPossibleMetiers(effortDescription); setOfVessels.update(); - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't create EffortDescription", eee); showMsgBox(eee); } } - + public Object removeEffortDescription(SetOfVessels sov, EffortDescription effort) { - if (log.isTraceEnabled()) { + if (log.isTraceEnabled()) { log.trace("remove called"); } try { @@ -916,13 +891,13 @@ } return null; } - + // Population public Population createPopulation() { if (log.isTraceEnabled()) { - log.trace("create called"); -} + log.trace("create called"); + } try { String name = "Population_new"; @@ -947,7 +922,7 @@ } public Object createRecruitmentDistribution() { - if (log.isTraceEnabled()) { + if (log.isTraceEnabled()) { log.trace("createRecruitmentDistributionontext called: " + population); } try { @@ -962,14 +937,14 @@ } } } - - if ( num > 0) { + + if (num > 0) { List<String> sem = new ArrayList<String>(num); - for (int i=0; i<num; i++) { + for (int i = 0; i < num; i++) { sem.add(_("isisfish.common.month", i)); } - MatrixND newMat = MatrixFactory.getInstance().create(new List[]{sem}); - + MatrixND newMat = MatrixFactory.getInstance().create(new List[]{sem}); + MatrixND mat = population.getRecruitmentDistribution(); if (mat != null) { newMat.paste(mat); @@ -983,67 +958,65 @@ } return null; } - + // Migration - - public Object addMigration(PopulationSeasonInfo info, PopulationGroup group, Zone departure, Zone arrival, double coeff) { - if (log.isTraceEnabled()) { - log.trace("addMigration called"); - } - try { - MatrixND mat = info.getMigrationMatrix().copy(); - mat.setValue(group, departure, arrival, coeff); - info.setMigrationMatrix(mat); - - }catch(Exception eee){ - log.error("Can't add migration", eee); - showMsgBox(eee); - } - return null; + + public Object addMigration(PopulationSeasonInfo info, PopulationGroup group, Zone departure, Zone arrival, double coeff) { + if (log.isTraceEnabled()) { + log.trace("addMigration called"); + } + try { + MatrixND mat = info.getMigrationMatrix().copy(); + mat.setValue(group, departure, arrival, coeff); + info.setMigrationMatrix(mat); + + } catch (Exception eee) { + log.error("Can't add migration", eee); + showMsgBox(eee); + } + return null; } public Object addEmigration(PopulationSeasonInfo info, PopulationGroup group, Zone departure, double coeff) { - if (log.isTraceEnabled()) { - log.trace("addEmigration called"); - } - try { - MatrixND mat = info.getEmigrationMatrix().copy(); - mat.setValue(group, departure, coeff); - info.setEmigrationMatrix(mat); - - }catch(Exception eee){ - log.error("Can't add emigration", eee); - showMsgBox(eee); - } - return null; + if (log.isTraceEnabled()) { + log.trace("addEmigration called"); + } + try { + MatrixND mat = info.getEmigrationMatrix().copy(); + mat.setValue(group, departure, coeff); + info.setEmigrationMatrix(mat); + + } catch (Exception eee) { + log.error("Can't add emigration", eee); + showMsgBox(eee); + } + return null; } - + public Object addImmigration(PopulationSeasonInfo info, PopulationGroup group, Zone arrival, double coeff) { - if (log.isTraceEnabled()) { - log.trace("addImmigration called"); - } - try { - MatrixND mat = info.getImmigrationMatrix().copy(); - mat.setValue(group, arrival, coeff); - info.setImmigrationMatrix(mat); - - }catch(Exception eee){ - log.error("Can't add immigration", eee); - showMsgBox(eee); - } - return null; + if (log.isTraceEnabled()) { + log.trace("addImmigration called"); + } + try { + MatrixND mat = info.getImmigrationMatrix().copy(); + mat.setValue(group, arrival, coeff); + info.setImmigrationMatrix(mat); + + } catch (Exception eee) { + log.error("Can't add immigration", eee); + showMsgBox(eee); + } + return null; } -// FisheryRegion - /** - * - * @return TODO - */ - public Object addMap(){ - if (log.isTraceEnabled()) { - log.trace("AddMap called"); - } + // FisheryRegion + /** @return TODO */ + public Object addMap() { + if (log.isTraceEnabled()) { + log.trace("AddMap called"); + } + File shp = FileUtil.getFile(".*\\.shp", "shp file"); try { if (shp != null) { @@ -1073,7 +1046,7 @@ maps.add(basename); fisheryRegion.setMapFileList(maps); } - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't copy .shp or .ssx file for: " + shp, eee); showMsgBox(eee); } @@ -1081,11 +1054,11 @@ } /** - * @param selectedMaps la list dans lequel il faut retirer la carte + * @param selectedMaps la list dans lequel il faut retirer la carte * @return TODO - */ - public Object removeMap(Object[] selectedMaps){ - if (log.isTraceEnabled()) { + */ + public Object removeMap(Object[] selectedMaps) { + if (log.isTraceEnabled()) { log.trace("removeMap called"); } try { @@ -1106,7 +1079,7 @@ fisheryRegion.setMapFileList(maps); - }catch(Exception eee){ + } catch (Exception eee) { log.error("Can't remove map", eee); showMsgBox(eee); } @@ -1117,25 +1090,26 @@ * Affiche une boite de dialogue demandant a l'utilisateur de rentrer * un nom de fichier, et met ce nom dans la textField. * Passe le saveButton en enabled pour marque que la region a ete modifié + * * @param cellFile file of cells */ - public void loadCellFile(String cellFile){ + public void loadCellFile(String cellFile) { if (log.isTraceEnabled()) { log.trace("loadCell called"); } - // FIXME todo loadCellFile - } + // FIXME todo loadCellFile + } - public Object saveFisheryRegion(String type){ + public Object saveFisheryRegion(String type) { if (log.isTraceEnabled()) { log.trace("save called"); } - try{ + try { TopiaContext isisContext = fisheryRegion.getTopiaContext(); // frame.setInfoText(_("isisfish.message.checking.cell")); - int latNumber = (int)Math.round((fisheryRegion.getMaxLatitude() - fisheryRegion.getMinLatitude()) / fisheryRegion.getCellLengthLatitude()); - int lonNumber = (int)Math.round((fisheryRegion.getMaxLongitude() - fisheryRegion.getMinLongitude()) / fisheryRegion.getCellLengthLongitude()); + int latNumber = (int) Math.round((fisheryRegion.getMaxLatitude() - fisheryRegion.getMinLatitude()) / fisheryRegion.getCellLengthLatitude()); + int lonNumber = (int) Math.round((fisheryRegion.getMaxLongitude() - fisheryRegion.getMinLongitude()) / fisheryRegion.getCellLengthLongitude()); // frame.setProgressMin(0); // frame.setProgressMax(latNumber * lonNumber); @@ -1148,20 +1122,20 @@ Collections.sort(cells, cellPointcomparator); Point2D.Float point = new Point2D.Float(); - for(float lati = fisheryRegion.getMinLatitude();lati<fisheryRegion.getMaxLatitude();lati+=fisheryRegion.getCellLengthLatitude()){ - lati = Math.round(lati*1000f); - lati= lati / 1000.0f; - for(float longi = fisheryRegion.getMinLongitude();longi<fisheryRegion.getMaxLongitude();longi+=fisheryRegion.getCellLengthLongitude()){ - longi = Math.round(longi*1000f) / 1000.0f; + for (float lati = fisheryRegion.getMinLatitude(); lati < fisheryRegion.getMaxLatitude(); lati += fisheryRegion.getCellLengthLatitude()) { + lati = Math.round(lati * 1000f); + lati = lati / 1000.0f; + for (float longi = fisheryRegion.getMinLongitude(); longi < fisheryRegion.getMaxLongitude(); longi += fisheryRegion.getCellLengthLongitude()) { + longi = Math.round(longi * 1000f) / 1000.0f; point.setLocation(lati, longi); int position = Collections.binarySearch(cells, point, cellPointcomparator); - if(position >= 0){ + if (position >= 0) { // deja existant on l'enleve de la liste, et on ne cree rien cells.remove(position); } else { // n'existe pas on la cree Cell cell = cellPS.create(); - cell.setName("La"+lati+"Lo"+longi); + cell.setName("La" + lati + "Lo" + longi); cell.setLatitude(lati); cell.setLongitude(longi); cell.setLand(false); @@ -1180,7 +1154,7 @@ // frame.setProgressMin(0); // frame.setProgressMax(cells.size()); progresscpt = 0; - for(Cell cell:cells){ + for (Cell cell : cells) { // FIXME il faudrait aussi rechercher les objets dependants // des mailles que l'on va supprimer et demander confirmation // a l'utilisateur qu'il souhaite reellement supprimer tous @@ -1195,14 +1169,14 @@ // frame.refreshView("inputFisheryRegion"); // frame.setInfoText(_("isisfish.message.save.finished")); - }catch(Exception eee){ + } catch (Exception eee) { log.error(_("isisfish.error.save.region"), eee); showMsgBox(eee); } return null; } - public Object checkFisheryRegion(){ + public Object checkFisheryRegion() { try { if (log.isTraceEnabled()) { log.trace("check called: "); @@ -1213,7 +1187,7 @@ CheckResultFrame dialog = new CheckResultFrame(); dialog.setCheckResult(result); dialog.setVisible(true); - }catch(Exception eee){ + } catch (Exception eee) { log.error(_("isisfish.error.check.region"), eee); showMsgBox(eee); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2008-12-13 10:24:41 UTC (rev 1669) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2008-12-15 00:59:49 UTC (rev 1670) @@ -131,7 +131,6 @@ int responce = askUser(content, _("isisfish.message.page.modified")); if (responce == JOptionPane.NO_OPTION) { context.getContextValue(InputAction.class).cancel(); - exit = true; } else if (responce == JOptionPane.OK_OPTION) { context.getContextValue(InputAction.class).save(); ui.setChanged(false); @@ -140,7 +139,6 @@ if (currentNode != null) { model.nodeChanged(currentNode); } - exit = true; } else { exit = false; } @@ -162,9 +160,10 @@ log.debug("find data for contextPath <" + node.getContextPath() + "> : " + (data == null ? null : data.getClass())); } InputAction action = context.getContextValue(InputAction.class); - if (data != null) { + action.setValue(data); + /*if (data != null) { action.setValue(data); - } + }*/ action.setPath(node.getContextPath()); } Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/TestJaxx.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/TestJaxx.java (rev 0) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/TestJaxx.java 2008-12-15 00:59:49 UTC (rev 1670) @@ -0,0 +1,38 @@ +package fr.ifremer.isisfish.ui; + +import jaxx.reflect.ClassDescriptor; +import jaxx.reflect.JavaFileParser; +import org.junit.Assert; +import org.junit.Test; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; + +/** @author chemit */ +public class TestJaxx { + + @Test + public void testParseEntity() throws Exception { + URL javaSource = new File("target/generated-sources/java/fr/ifremer/isisfish/entities/Cell.java").toURI().toURL(); + + InputStream in = javaSource.openStream(); + Reader reader = new InputStreamReader(in, "utf-8"); + ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, getClass().getClassLoader()); + reader.close(); + Assert.assertNotNull(result); + } + + @Test + public void testParseEntityImpl() throws Exception { + URL javaSource = new File("src/main/java/fr/ifremer/isisfish/entities/CellImpl.java").toURI().toURL(); + + InputStream in = javaSource.openStream(); + Reader reader = new InputStreamReader(in, "utf-8"); + ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, getClass().getClassLoader()); + reader.close(); + Assert.assertNotNull(result); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org