Author: sletellier Date: 2008-12-12 16:23:58 +0000 (Fri, 12 Dec 2008) New Revision: 1664 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/EffortDescriptionUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/FisheryRegionUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.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 isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationCapturabilityUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationEquationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsTabsUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyMonthInfoUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/TripTypeUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx Log: Save popup works 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-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -98,15 +98,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$cells/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$cells/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Cell"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$cells/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void goToZone(){ @@ -201,10 +201,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -113,16 +113,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$setOfVessels/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("SetOfVessels"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -130,7 +129,7 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(GearUI.class).setChanged(b); save.setEnabled(b); cancel.setEnabled(b); } @@ -366,10 +365,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.3'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.3'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.3'> <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/FisheryRegionUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/FisheryRegionUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/FisheryRegionUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -93,6 +93,7 @@ fieldMapfiles.setModel(model); } protected void valueChanged(boolean b){ + changed = b; save.setEnabled(b); cancel.setEnabled(b); } @@ -155,16 +156,15 @@ protected void save(){ setMsg(_("isisfish.message.checking.cell")); getContextValue(InputAction.class).saveFisheryRegion("FisheryRegion"); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root"); valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root"); setMsg(_("isisfish.message.save.finished")); + refresh(); } protected void cancel(){ - getContextValue(InputAction.class).cancel("FisheryRegion"); + getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root"); } protected void check(){ getContextValue(InputAction.class).checkFisheryRegion(); @@ -312,10 +312,10 @@ </row> <row> <cell fill='horizontal' weightx='0.3'> - <JButton id='save' enabled='false' text="isisfish.common.save" onActionPerformed='save()'/> + <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.3'> - <JButton id='cancel' enabled='false' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> </cell> <cell fill='horizontal' weightx='0.3'> <JButton id='check' text="isisfish.common.check" onActionPerformed='check()'/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -42,7 +42,9 @@ import fr.ifremer.isisfish.ui.WelcomePanelUI; import org.codelutin.topia.persistence.TopiaEntity; import org.codelutin.topia.TopiaException; - + import jaxx.runtime.swing.navigation.NavigationTreeModel; + import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; + public GearTabUI (InputAction action){ setContextValue(action); @@ -82,17 +84,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$gears/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Gear"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -105,9 +105,7 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; - cancel.setEnabled(b); - save.setEnabled(b); + getParentContainer(GearUI.class).setChanged(b); } protected void nameChanged(){ getContextValue(InputAction.class).getGear().setName(fieldGearName.getText()); @@ -204,15 +202,15 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id="save" enabled='{isActif()}' text="isisfish.common.save" onActionPerformed='save()'/> + <JButton id="save" enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' enabled='{isActif()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id="create" text="isisfish.common.new" onActionPerformed='create()' enabled='{isActif()}'/> + <JButton id="create" text="isisfish.common.new" onActionPerformed='create()'/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -44,14 +44,31 @@ <script><![CDATA[ import fr.ifremer.isisfish.entities.Metier; + init(); public GearUI (InputAction action){ - + setContextValue(action); } public void refresh() { gearTabUI.refresh(); selectivityUI.refresh(); } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + gearTabUI.setActif((Boolean)evt.getNewValue()); + selectivityUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + gearTabUI.setChanged((Boolean)evt.getNewValue()); + selectivityUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void goToMetier(){ getParentContainer(InputUI.class).setTreeSelection("$root/$metiers"); } 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-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-12-12 16:23:58 UTC (rev 1664) @@ -125,6 +125,7 @@ protected VesselType vesselType; protected SetOfVessels setOfVessels; protected Strategy strategy; + protected boolean isNull = true; public InputAction() { log.info("new instance"); @@ -133,22 +134,24 @@ 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; +// 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; @@ -185,8 +188,11 @@ strategy = (Strategy) value; break; } - selected = (TopiaEntity) value; + selected = (TopiaEntity) value; } + public boolean isNull(){ + return isNull; + } public void setPath(String path){ this.path = path; } @@ -558,7 +564,7 @@ * interface Tab to refresh after rollback and reload * @return if ok return null else OutView error */ - public TopiaEntity cancel(String type) { + public TopiaEntity cancel() { log.debug("cancel called"); try { isisContext.rollbackTransaction(); 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-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2008-12-12 16:23:58 UTC (rev 1664) @@ -17,6 +17,7 @@ import javax.swing.event.TreeSelectionEvent; import java.awt.Component; import javax.swing.JOptionPane; +import javax.swing.JTree; import static org.codelutin.i18n.I18n._; /** @author letellier */ @@ -25,6 +26,7 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(InputNavigationTreeSelectionAdapter.class); + protected NavigationTreeNode currentNode = null; public InputNavigationTreeSelectionAdapter(InputUI context, boolean register) { super(InputUI.class, null, context, Strategy.PER_UI_TYPE); @@ -74,13 +76,14 @@ // apply refresh method (should a contract for all this ui with a method refresh...) try { InputContent ui = (InputContent) newUI; - boolean parameter = context.getContextValue(InputAction.class).getSelected() != null; + boolean parameter = !context.getContextValue(InputAction.class).isNull(); log.debug(parameter); // Method setActif = newUI.getClass().getDeclaredMethod("setActif", Boolean.class); // setActif.setAccessible(true); // setActif.invoke(newUI, parameter); ui.setActif(parameter); ui.refresh(); + currentNode = node; // Method refresh = newUI.getClass().getDeclaredMethod("refresh"); // refresh.setAccessible(true); // refresh.invoke(newUI); @@ -92,32 +95,46 @@ @Override protected boolean closeUI(TreeSelectionEvent event, Component component) throws Exception { // by default, we says that component was succesfull closed - return checkEdit(component); + boolean exit = checkEdit(event, component); + return exit; } - public boolean checkEdit(Component content) { - boolean wasClosed = true; + public boolean checkEdit(TreeSelectionEvent event, Component content) { + boolean exit = true; if (content != null){ InputContent ui = (InputContent) content; + System.out.println(ui + " " + ui.isChanged() + " " + ui.isActif()); if (ui.isActif()) { if (ui.isChanged()) { // ask user to close edition // still in edit mode, must warn user - boolean willQuit = askUser(content, _("isisfish.message.page.modified")); - if (!willQuit) { - return false; + 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); + JTree tree = (JTree)event.getSource(); + NavigationTreeModel model = (NavigationTreeModel)tree.getModel(); + if (currentNode != null){ + model.nodeChanged(currentNode); + } + exit = true; + } + else{ + exit = false; + } } - context.getContextValue(InputAction.class).save(); - ui.setChanged(false); } } - return wasClosed; + return exit; } - public boolean askUser(Component parent, String message) { + public int askUser(Component parent, String message) { int response = JOptionPane.showConfirmDialog(parent, message, - _("isisfish.input.menu.commit"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); - return response == JOptionPane.OK_OPTION; + _("isisfish.input.menu.commit"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + return response; } @Override 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-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -69,6 +69,8 @@ import fr.ifremer.isisfish.entities.FisheryRegion; import jaxx.runtime.swing.navigation.NavigationTreeCellRenderer; import jaxx.runtime.swing.navigation.NavigationTreeModel; + import jaxx.runtime.Decorator; + import jaxx.runtime.JXPathDecorator; /* tree.addTreeSelectionListener(new TreeSelectionListener() { @Override @@ -244,22 +246,22 @@ NavigationTreeNode setOfVessels = builder.build(root, "SetOfVessels", "../setOfVessels", "$setOfVessels", SetOfVesselsUI.class, null); NavigationTreeNode strategies = builder.build(root, "Strategies", "../strategy", "$strategies", StrategyUI.class, null); - setNode(builder, cells, fisheryRegion.getCell().toArray(), CellUI.class); - setNode(builder, zones, fisheryRegion.getZone().toArray(), ZoneUI.class); - setNode(builder, ports, fisheryRegion.getPort().toArray(), PortUI.class); - setNode(builder, gears, fisheryRegion.getGear().toArray(), GearUI.class); - setNode(builder, metiers, fisheryRegion.getMetier().toArray(), MetierUI.class); - setNode(builder, tripTypes, fisheryRegion.getTripType().toArray(), TripTypeUI.class); - setNode(builder, vesselTypes, fisheryRegion.getVesselType().toArray(), VesselTypeUI.class); - setNode(builder, setOfVessels, fisheryRegion.getSetOfVessels().toArray(), SetOfVesselsUI.class); - setNode(builder, strategies, fisheryRegion.getStrategy().toArray(), StrategyUI.class); + setNode(builder, cells, fisheryRegion.getCell().toArray(), CellUI.class, Cell.class); + setNode(builder, zones, fisheryRegion.getZone().toArray(), ZoneUI.class, Zone.class); + setNode(builder, ports, fisheryRegion.getPort().toArray(), PortUI.class, Port.class); + setNode(builder, gears, fisheryRegion.getGear().toArray(), GearUI.class, Gear.class); + setNode(builder, metiers, fisheryRegion.getMetier().toArray(), MetierUI.class, Metier.class); + setNode(builder, tripTypes, fisheryRegion.getTripType().toArray(), TripTypeUI.class, TripType.class); + setNode(builder, vesselTypes, fisheryRegion.getVesselType().toArray(), VesselTypeUI.class, VesselType.class); + setNode(builder, setOfVessels, fisheryRegion.getSetOfVessels().toArray(), SetOfVesselsUI.class, SetOfVessels.class); + setNode(builder, strategies, fisheryRegion.getStrategy().toArray(), StrategyUI.class, Strategy.class); for (Species specie : fisheryRegion.getSpecies()){ TopiaEntity topiaEntity = (TopiaEntity)specie; NavigationTreeNode speciesChild = builder.build(species, specie.toString() , "..[@topiaId=\"" + topiaEntity.getTopiaId() + "\"]", topiaEntity.getTopiaId(), SpeciesUI.class, null); - NavigationTreeNode populations = builder.build(speciesChild, "Population", "../population", "$populations", PopulationUI.class, null); + NavigationTreeNode populations = builder.build(speciesChild, "Populations", "../population", "$populations", PopulationUI.class, null); if (specie.getPopulation() != null){ - setNode(builder, populations, specie.getPopulation().toArray(), PopulationUI.class); + setNode(builder, populations, specie.getPopulation().toArray(), PopulationUI.class, Population.class); } } @@ -275,14 +277,19 @@ } } } - protected void setNode(NavigationTreeModelBuilder builder, NavigationTreeNode parent, Object[] values, Class ui){ + protected void setNode(NavigationTreeModelBuilder builder, NavigationTreeNode parent, Object[] values, Class ui, Class type){ for (Object o : values){ TopiaEntity topiaEntity = (TopiaEntity)o; - builder.build(parent, o.toString() , "..[@topiaId=\"" + topiaEntity.getTopiaId() + "\"]", topiaEntity.getTopiaId(), ui, null); + Decorator deco = JXPathDecorator.newDecorator(type, "${name}$s"); + builder.build(parent, deco , "..[@topiaId=\"" + topiaEntity.getTopiaId() + "\"]", topiaEntity.getTopiaId(), ui, null); } } - protected void setTreeSelection(String path){ - System.out.println(path); + public void repaintNode(String path){ + NavigationTreeModel model = getContextValue(NavigationTreeModel.class); + NavigationTreeNode currentNode = model.findNode(path); + model.nodeChanged(currentNode); + } + public void setTreeSelection(String path){ NavigationTreeNode node = NavigationUtil.findNode(this, null, path); TreePath pathToRoot = new TreePath(getContextValue(NavigationTreeModel.class).getPathToRoot(node)); navigation.setSelectionPath(pathToRoot); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -192,22 +192,22 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$metiers/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(MetierUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } protected void openEditor(){ getContextValue(InputAction.class).openEditor("TargetFactor","new",fr.ifremer.isisfish.equation.TargetSpeciesTargetFactorEquation.class, fieldTargetFactorScript.getText(), fieldTargetFactorScript); @@ -306,10 +306,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='false'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='false'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -165,16 +165,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$metiers/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); - seasonInit = false; refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -188,8 +188,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ + getParentContainer(MetierUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } protected void zonesChanged(){ Object selected = fieldMetierSeasonChoice.getSelectedItem(); @@ -272,10 +273,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id ='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id ='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -96,17 +96,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$metiers/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -119,9 +117,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; - cancel.setEnabled(b); + getParentContainer(MetierUI.class).setChanged(b); save.setEnabled(b); + cancel.setEnabled(b); } ]]></script> <row> @@ -169,10 +167,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id="save" text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id="save" text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id="cancel" text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id="cancel" text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -43,6 +43,8 @@ <script><![CDATA[ import fr.ifremer.isisfish.entities.TripType; + + init(); public MetierUI (InputAction action){ setContextValue(action); @@ -54,6 +56,24 @@ metierSeasonInfoUI.setSeasonInit(true); metierSeasonInfoUI.refresh(); } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + metierTabUI.setActif((Boolean)evt.getNewValue()); + metierSeasonSpeciesUI.setActif((Boolean)evt.getNewValue()); + metierSeasonInfoUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + metierTabUI.setChanged((Boolean)evt.getNewValue()); + metierSeasonSpeciesUI.setChanged((Boolean)evt.getNewValue()); + metierSeasonInfoUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void goToTripType(){ getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes"); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -120,7 +120,7 @@ GenericCell c = new GenericCell(f.getName(), f, Formule.class); model.addElement(c); if (pop != null){ - if (((Equation)f).equals(pop.getGrowth())){ + if (f.equals((Formule)pop.getGrowth())){ selected = c; } } @@ -275,18 +275,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - Population population = (Population) topia; - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+ population.getSpecies().getTopiaId() +"/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Population"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -299,9 +297,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; - cancel.setEnabled(b); + getParentContainer(PopulationUI.class).setChanged(b); save.setEnabled(b); + cancel.setEnabled(b); } ]]> </script> @@ -446,10 +444,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationCapturabilityUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationCapturabilityUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationCapturabilityUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -80,16 +80,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$population/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -97,9 +97,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } ]]> </script> @@ -127,10 +127,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationEquationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationEquationUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationEquationUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -45,6 +45,7 @@ import fr.ifremer.isisfish.entities.Population; protected Population pop = null; + init(); public PopulationEquationUI (InputAction action){ setContextValue(action); @@ -58,21 +59,39 @@ naturalDeathRate.refresh(); meanWeight.refresh(); price.refresh(); - valueChanged(false); } } + + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + naturalDeathRate.setActif((Boolean)evt.getNewValue()); + meanWeight.setActif((Boolean)evt.getNewValue()); + price.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + naturalDeathRate.setChanged((Boolean)evt.getNewValue()); + meanWeight.setChanged((Boolean)evt.getNewValue()); + price.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Population"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -80,7 +99,7 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); save.setEnabled(b); cancel.setEnabled(b); } @@ -103,10 +122,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" enabled='{isActif()}' onActionPerformed='cancel()'/> + <JButton id='cancel' text="isisfish.common.cancel" enabled='{isChanged()}' onActionPerformed='cancel()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" enabled='{isActif()}' onActionPerformed='save()'/> + <JButton id='save' text="isisfish.common.save" enabled='{isChanged()}' onActionPerformed='save()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -114,16 +114,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Population"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -131,8 +131,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); save.setEnabled(b); + cancel.setEnabled(b); } ]]> </script> @@ -210,10 +211,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' enabled='{isActif()}' text="isisfish.common.save" onActionPerformed='save()'/> + <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' enabled='{isActif()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -45,6 +45,7 @@ protected Population pop = null; protected PopulationSeasonInfo popInfo = null; + init(); public PopulationMigrationEquationUI (InputAction action){ setContextValue(action); @@ -68,6 +69,24 @@ emigrationEquation.refresh(); immigrationEquation.refresh(); } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + migrationEquation.setActif((Boolean)evt.getNewValue()); + emigrationEquation.setActif((Boolean)evt.getNewValue()); + immigrationEquation.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + migrationEquation.setChanged((Boolean)evt.getNewValue()); + emigrationEquation.setChanged((Boolean)evt.getNewValue()); + immigrationEquation.setChanged((Boolean)evt.getNewValue()); + } + }); + } ]]> </script> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -48,6 +48,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + init(); protected Population pop; // protected PopulationSeasonInfo populationSeasonInfoSelected = null; public PopulationMigrationUI (InputAction action){ @@ -79,6 +80,26 @@ fieldPopulationMigrationComment.setText(""); } } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + populationMigrationEquationUI.setActif((Boolean)evt.getNewValue()); + populationMigrationMigrationUI.setActif((Boolean)evt.getNewValue()); + populationMigrationImmigrationUI.setActif((Boolean)evt.getNewValue()); + populationMigrationEmigrationUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + populationMigrationEquationUI.setChanged((Boolean)evt.getNewValue()); + populationMigrationMigrationUI.setChanged((Boolean)evt.getNewValue()); + populationMigrationImmigrationUI.setChanged((Boolean)evt.getNewValue()); + populationMigrationEmigrationUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void setFieldPopulationMigrationSeasonChooserModel(){ DefaultComboBoxModel model = new DefaultComboBoxModel(); for (PopulationSeasonInfo psi : pop.getPopulationSeasonInfo()){ @@ -116,16 +137,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Population"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -133,9 +154,9 @@ root.setInfoText(txt); } public void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } ]]> </script> @@ -179,10 +200,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -135,16 +135,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -152,9 +152,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } ]]> </script> @@ -237,10 +237,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -165,15 +165,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Metier"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -186,9 +187,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } ]]> </script> @@ -245,10 +246,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -46,6 +46,8 @@ <script><![CDATA[ import fr.ifremer.isisfish.entities.Gear; + + init(); public PopulationUI (InputAction action){ setContextValue(action); } @@ -60,6 +62,34 @@ populationMigrationUI.refresh(); setSpecies(); } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + populationBasicsUI.setActif((Boolean)evt.getNewValue()); + populationGroupUI.setActif((Boolean)evt.getNewValue()); + populationEquationUI.setActif((Boolean)evt.getNewValue()); + populationZoneUI.setActif((Boolean)evt.getNewValue()); + populationSeasonsUI.setActif((Boolean)evt.getNewValue()); + populationCapturabilityUI.setActif((Boolean)evt.getNewValue()); + populationRecruitementUI.setActif((Boolean)evt.getNewValue()); + populationMigrationUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + populationBasicsUI.setChanged((Boolean)evt.getNewValue()); + populationGroupUI.setChanged((Boolean)evt.getNewValue()); + populationEquationUI.setChanged((Boolean)evt.getNewValue()); + populationZoneUI.setChanged((Boolean)evt.getNewValue()); + populationSeasonsUI.setChanged((Boolean)evt.getNewValue()); + populationCapturabilityUI.setChanged((Boolean)evt.getNewValue()); + populationRecruitementUI.setChanged((Boolean)evt.getNewValue()); + populationMigrationUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void setSpecies(){ String[] paths = getContextValue(InputAction.class).getPath().split("/"); String topiaId = null; Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -160,16 +160,16 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); + TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + species.getTopiaId() + "/$populations/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Population"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$populations/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -177,7 +177,7 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; + getParentContainer(PopulationUI.class).setChanged(b); save.setEnabled(b); cancel.setEnabled(b); } @@ -226,12 +226,12 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -120,17 +120,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$ports/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$ports/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Port"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$ports/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -147,8 +145,8 @@ } protected void valueChanged(boolean b){ changed=b; - cancel.setEnabled(b); save.setEnabled(b); + cancel.setEnabled(b); } protected void nameChanged(){ getContextValue(InputAction.class).getPort().setName(fieldPortName.getText()); @@ -206,10 +204,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -150,22 +150,19 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$gears/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Gear"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void valueChanged(boolean b){ - changed=b; - cancel.setEnabled(b); - save.setEnabled(b); + getParentContainer(GearUI.class).setChanged(b); } protected void equationChanged(){ GenericCell g = (GenericCell)fieldSelectivityEquation.getSelectedItem(); @@ -252,10 +249,10 @@ </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsTabsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsTabsUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsTabsUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -152,17 +152,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$setOfVessels/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("SetOfVessels"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -175,9 +173,9 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ - changed=b; - cancel.setEnabled(b); + getParentContainer(GearUI.class).setChanged(b); save.setEnabled(b); + cancel.setEnabled(b); } protected void nameChanged(){ getContextValue(InputAction.class).getSetOfVessels().setName(fieldSetOfVesselsName.getText()); @@ -333,10 +331,10 @@ <Table> <row> <cell fill='horizontal' weightx='1.0'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -44,6 +44,7 @@ <script><![CDATA[ import fr.ifremer.isisfish.entities.Strategy; + init(); public SetOfVesselsUI (InputAction action){ setContextValue(action); @@ -51,7 +52,23 @@ public void refresh() { setOfVesselsTabsUI.refresh(); effortDescriptionUI.refresh(); - } + } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + setOfVesselsTabsUI.setActif((Boolean)evt.getNewValue()); + effortDescriptionUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + setOfVesselsTabsUI.setChanged((Boolean)evt.getNewValue()); + effortDescriptionUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void goToStrategies(){ getParentContainer(InputUI.class).setTreeSelection("$root/$strategies"); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -73,6 +73,7 @@ fieldSpeciesComment.setText(""); goToPopulation.setEnabled(false); } + valueChanged(false); } protected void create(){ TopiaEntity topia = getContextValue(InputAction.class).create("Species"); @@ -84,18 +85,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+topia.getTopiaId()); - + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$species/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Species"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -109,8 +107,8 @@ } protected void valueChanged(boolean b){ changed=b; - cancel.setEnabled(b); save.setEnabled(b); + cancel.setEnabled(b); } protected void setInfoText(String txt){ WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); @@ -212,10 +210,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyMonthInfoUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyMonthInfoUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyMonthInfoUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -44,6 +44,7 @@ import fr.ifremer.isisfish.ui.WelcomePanelUI; import org.codelutin.topia.persistence.TopiaEntity; + init(); public StrategyMonthInfoUI (InputAction action){ setContextValue(action); @@ -74,17 +75,53 @@ strategyNovember.refresh(); strategyDecember.refresh(); } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + strategyJanuary.setActif((Boolean)evt.getNewValue()); + strategyFebuary.setActif((Boolean)evt.getNewValue()); + strategyMarch.setActif((Boolean)evt.getNewValue()); + strategyApril.setActif((Boolean)evt.getNewValue()); + strategyMay.setActif((Boolean)evt.getNewValue()); + strategyJune.setActif((Boolean)evt.getNewValue()); + strategyJuly.setActif((Boolean)evt.getNewValue()); + strategyAugust.setActif((Boolean)evt.getNewValue()); + strategySeptember.setActif((Boolean)evt.getNewValue()); + strategyOctober.setActif((Boolean)evt.getNewValue()); + strategyNovember.setActif((Boolean)evt.getNewValue()); + strategyDecember.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + strategyJanuary.setChanged((Boolean)evt.getNewValue()); + strategyFebuary.setChanged((Boolean)evt.getNewValue()); + strategyMarch.setChanged((Boolean)evt.getNewValue()); + strategyApril.setChanged((Boolean)evt.getNewValue()); + strategyMay.setChanged((Boolean)evt.getNewValue()); + strategyJune.setChanged((Boolean)evt.getNewValue()); + strategyJuly.setChanged((Boolean)evt.getNewValue()); + strategyAugust.setChanged((Boolean)evt.getNewValue()); + strategySeptember.setChanged((Boolean)evt.getNewValue()); + strategyOctober.setChanged((Boolean)evt.getNewValue()); + strategyNovember.setChanged((Boolean)evt.getNewValue()); + strategyDecember.setChanged((Boolean)evt.getNewValue()); + } + }); + } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$strategies/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Strategy"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void setInfoText(String txt){ @@ -92,9 +129,9 @@ root.setInfoText(txt); } public void valueChanged(boolean b){ + changed = b; save.setEnabled(b); cancel.setEnabled(b); - changed = b; } ]]></script> <Table constraints='BorderLayout.CENTER'> @@ -150,10 +187,10 @@ <Table constraints='BorderLayout.SOUTH'> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' enabled='false' text="isisfish.common.save" onActionPerformed='save()'/> + <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' enabled='false' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -119,7 +119,6 @@ } protected void valueChanged(boolean b){ getParentContainer(StrategyMonthInfoUI.class).valueChanged(b); - changed = b; } ]]></script> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -147,17 +147,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$strategies/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Strategy"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -171,8 +169,8 @@ } protected void valueChanged(boolean b){ changed=b; - cancel.setEnabled(b); save.setEnabled(b); + cancel.setEnabled(b); } ]]></script> <row> @@ -260,10 +258,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -42,13 +42,30 @@ <Boolean id='changed' javaBean='false'/> <script><![CDATA[ + init(); public StrategyUI (InputAction action){ setContextValue(action); } public void refresh() { strategyTabUI.refresh(); strategyMonthInfoUI.refresh(); - } + } + protected void init(){ + this.addPropertyChangeListener("actif", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + strategyTabUI.setActif((Boolean)evt.getNewValue()); + strategyMonthInfoUI.setActif((Boolean)evt.getNewValue()); + } + }); + this.addPropertyChangeListener("changed", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + strategyTabUI.setChanged((Boolean)evt.getNewValue()); + strategyMonthInfoUI.setChanged((Boolean)evt.getNewValue()); + } + }); + } ]]></script> <tab title='{_("isisfish.strategy.title")}'><StrategyTabUI id='strategyTabUI' constructorParams='getContextValue(InputAction.class)'/></tab> <tab title='{_("isisfish.strategyMonthInfo.title")}'><StrategyMonthInfoUI id='strategyMonthInfoUI' constructorParams='getContextValue(InputAction.class)'/></tab> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/TripTypeUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/TripTypeUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/TripTypeUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -71,8 +71,8 @@ } protected void valueChanged(boolean b){ changed=b; - cancel.setEnabled(b); save.setEnabled(b); + cancel.setEnabled(b); } protected void nameChanged(){ getContextValue(InputAction.class).getTripType().setName(fieldTripTypeName.getText()); @@ -100,17 +100,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$tripTypes/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("TripType"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -168,15 +166,15 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='create' text="isisfish.common.new" onActionPerformed='create()' enabled='{isActif()}'/> + <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> @@ -184,7 +182,7 @@ </row> <row> <cell columns ='2' fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueVesselTypes" onActionPerformed='goToVesselTypes()' enabled='{isActif()}'/> + <JButton text="isisfish.input.continueVesselTypes" onActionPerformed='goToVesselTypes()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx 2008-12-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -94,17 +94,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$vesselTypes/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$vesselTypes/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("VesselType"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$vesselTypes/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -117,32 +115,40 @@ root.setInfoText(txt); } protected void valueChanged(boolean b){ + changed = b; + save.setEnabled(b); cancel.setEnabled(b); - save.setEnabled(b); } protected void goToSetOfVessels(){ getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels"); } protected void nameChanged(){ getContextValue(InputAction.class).getVesselType().setName(fieldVesselTypeName.getText()); + valueChanged(true); } protected void lenghtChanged(){ getContextValue(InputAction.class).getVesselType().setLength(Integer.parseInt(fieldVesselTypeLength.getText())); + valueChanged(true); } protected void speedChanged(){ getContextValue(InputAction.class).getVesselType().setSpeed(Double.parseDouble(fieldVesselTypeSpeed.getText())); + valueChanged(true); } protected void tripDurationChanged(){ getContextValue(InputAction.class).getVesselType().setMaxTripDuration(new TimeUnit(Double.parseDouble(fieldVesselTypeMaxTripDuration.getText()))); + valueChanged(true); } protected void activityRangeChanged(){ getContextValue(InputAction.class).getVesselType().setActivityRange(Double.parseDouble(fieldVesselTypeActivityRange.getText())); + valueChanged(true); } protected void minCrewChanged(){ getContextValue(InputAction.class).getVesselType().setMinCrewSize(Integer.parseInt(fieldVesselTypeMinCrewSize.getText())); + valueChanged(true); } protected void unitFuelCostChanged(){ getContextValue(InputAction.class).getVesselType().setUnitFuelCostOfTravel(Double.parseDouble(fieldVesselTypeUnitFuelCostOfTravel.getText())); + valueChanged(true); } protected void tripTypeChanged(){ Object[] values = vesselTypeTripType.getSelectedValues(); @@ -151,9 +157,11 @@ tripTypes.add((TripType)((GenericCell)o).getValue()); } getContextValue(InputAction.class).getVesselType().setTripType(tripTypes); + valueChanged(true); } protected void commentChanged(){ getContextValue(InputAction.class).getVesselType().setComment(fieldVesselTypeComment.getText()); + valueChanged(true); } ]]></script> <Table constraints='BorderLayout.CENTER'> @@ -244,10 +252,10 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isActif()}'/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isActif()}'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> </cell> </row> <row> 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-12 15:31:49 UTC (rev 1663) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2008-12-12 16:23:58 UTC (rev 1664) @@ -70,8 +70,7 @@ } @Override - public void focusLost(FocusEvent e) { - System.out.println(changed); + public void focusLost(FocusEvent e) {; if (changed){ if (!askAndSave()){ getParentContainer(InputUI.class).setTreeSelection("$root/$zones"+getContextValue(InputAction.class).getZone().getTopiaId()); @@ -103,8 +102,8 @@ return result; } public void refresh() { - Zone z = getContextValue(InputAction.class).getZone(); - if (z != null){ + if (! getContextValue(InputAction.class).isNull()){ + Zone z = getContextValue(InputAction.class).getZone(); DefaultListModel zoneCellsModel = new DefaultListModel(); java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); for (Cell c : cells){ @@ -160,17 +159,15 @@ } protected void save(){ TopiaEntity topia = getContextValue(InputAction.class).save(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$zones/"+topia.getTopiaId()); + valueChanged(false); + getParentContainer(InputUI.class).repaintNode("$root/$zones/" + topia.getTopiaId()); setInfoText(_("isisfish.message.save.finished")); refresh(); - valueChanged(false); } protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel("Zone"); + TopiaEntity topia = getContextValue(InputAction.class).cancel(); valueChanged(false); refresh(); - getParentContainer(InputUI.class).setTreeSelection("$root/$zones/"+topia.getTopiaId()); setInfoText(_("isisfish.message.cancel.finished")); } protected void remove(){ @@ -192,7 +189,6 @@ protected void zoneCellsChange(){ java.util.List<Cell> cells = new ArrayList<Cell>(); for (Object o : zoneCells.getSelectedValues()){ - System.out.println("zoneCellChanged " + o); cells.add((Cell) o); } getContextValue(InputAction.class).getZone().setCell(cells); @@ -200,14 +196,13 @@ refreshMap(); } protected void nameChange(){ - System.out.println("InputAction " + getContextValue(InputAction.class) + " getZone "+getContextValue(InputAction.class).getZone()+" fieldZoneName.getText() "+ fieldZoneName.getText()); getContextValue(InputAction.class).getZone().setName(fieldZoneName.getText()); valueChanged(true); } protected void valueChanged(boolean b){ changed = b; - cancel.setEnabled(b); save.setEnabled(b); + cancel.setEnabled(b); } ]]> </script> @@ -219,12 +214,11 @@ <row> <cell columns='2' fill='horizontal' weightx='1.0'> <JLabel enabled='{isActif()}' text="isisfish.zone.name"/> - </cell> </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldZoneName" enabled='{isActif()}' onKeyTyped='valueChanged(true)'/> + <JTextField id="fieldZoneName" enabled='{isActif()}' onKeyTyped='nameChange()'/> <!-- onFocusLost='nameChange()' --> </cell> </row> @@ -254,10 +248,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" enabled='{isActif()}' onActionPerformed='save()'/> + <JButton id='save' text="isisfish.common.save" enabled='{isChanged()}' onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" enabled='{isActif()}' onActionPerformed='cancel()'/> + <JButton id='cancel' text="isisfish.common.cancel" enabled='{isChanged()}' onActionPerformed='cancel()'/> </cell> </row> <row>