Author: sletellier Date: 2009-01-02 17:22:04 +0000 (Fri, 02 Jan 2009) New Revision: 1724 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContent.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/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/PopulationMigrationEmigrationUI.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/PopulationMigrationImmigrationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.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/PopulationOneEquationUI.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/WizardGroupCreationUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx Log: Utilisation des binding Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,6 +35,8 @@ import fr.ifremer.isisfish.ui.simulator.SimulAction; import fr.ifremer.isisfish.ui.input.InputAction; import fr.ifremer.isisfish.ui.result.ResultAction; + import jaxx.runtime.JAXXInitialContext; + import fr.ifremer.isisfish.ui.input.InputSaveVerifier; simulUI.getContextValue(SimulAction.class).init(); ]]> @@ -47,7 +49,7 @@ <fr.ifremer.isisfish.ui.result.ResultView/> </tab> <tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'> - <fr.ifremer.isisfish.ui.input.InputUI constructorParams='new InputAction()'/> + <fr.ifremer.isisfish.ui.input.InputUI constructorParams='new JAXXInitialContext().add(new InputAction()).add(new InputSaveVerifier())'/> </tab> <tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/bookPage.gif"))}'> <fr.ifremer.isisfish.ui.script.ScriptUI/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -45,6 +45,8 @@ import fr.ifremer.isisfish.IsisConfig; import javax.swing.JFrame; import org.codelutin.widget.AboutFrame; + import jaxx.runtime.JAXXInitialContext; + import fr.ifremer.isisfish.ui.input.InputSaveVerifier; welcomePanelUI.setContent(new WelcomeTabUI()); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -111,7 +113,7 @@ <JMenu text="isisfish.welcome.menu.frame"> <JMenuItem text="isisfish.welcome.menu.simulation" onActionPerformed='openFrame(new SimulUI(new SimulAction()), _("isisfish.simulation.title"))'/> <JMenuItem text="isisfish.welcome.menu.result" onActionPerformed='openFrame(new ResultView(), _("isisfish.result.title"))'/> - <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(new InputAction()), _("isisfish.input.title"))'/> + <JMenuItem text="isisfish.welcome.menu.input" onActionPerformed='openFrame(new InputUI(new JAXXInitialContext().add(new InputAction()).add(new InputSaveVerifier())), _("isisfish.input.title"))'/> <JMenuItem text="isisfish.welcome.menu.script" onActionPerformed='openFrame(new ScriptUI(), _("isisfish.script.title"))'/> <JSeparator/> <JMenuItem text="isisfish.welcome.menu.queue" onActionPerformed='openFrame(new QueueUI(), _("isisfish.queue.title"))'/> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,18 +30,13 @@ * by : $Author: sletellier $ */ --> - + + <!-- + Cell +--> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- 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'/> @@ -49,29 +44,20 @@ 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; -import com.bbn.openmap.event.MapMouseListener; import com.bbn.openmap.event.SelectMouseMode; import fr.ifremer.isisfish.map.CellSelectionLayer; -import java.util.logging.Level; -import com.bbn.openmap.omGraphics.OMGraphic; -import java.util.logging.Logger; -import org.codelutin.topia.TopiaException; - -protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); protected OMToolSet toolSet = new OMToolSet(); protected OpenMapEvents mapListener = null; +setType("Cell"); +setButtonTitle("isisfish.input.continueZones"); +setNextPath("$root/$zones"); 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"); + //jaxx.runtime.Util.removeDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldCellName.setText(""); fieldCellLatitude.setText(""); fieldCellLongitude.setText(""); @@ -80,31 +66,27 @@ } if (evt.getNewValue() != null) { // add binding on getBean() - jaxx.runtime.Util.applyDataBinding($Table0, "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } } }); public void refresh() { - InputAction action = getContextValue(InputAction.class); - setBean(null); - Cell cell = action.getCell(); + Cell cell = (Cell)getVerifier().getEntity(Cell.class); setBean((CellImpl) cell); - jaxx.runtime.swing.Utils.fillComboBox(fieldCell,action.getFisheryRegion().getCell(), cell); - cellMap.setFisheryRegion(action.getFisheryRegion()); + jaxx.runtime.swing.Utils.fillComboBox(fieldCell,getRegion().getCell(), cell); + cellMap.setFisheryRegion(getRegion()); if (mapListener == null){ cellMap.setSelectionMode(CellSelectionLayer.SINGLE_SELECTION); cellMap.setActiveMouseMode(new SelectMouseMode()); toolSet.setupListeners(cellMap); toolMap.add((Component)toolSet); - map.add(toolMap, BorderLayout.NORTH); setMapListener(); } if (cell != null){ cellMap.setSelectedCells(cell); } - setChanged(false); } protected void setMapListener(){ if (mapListener == null){ @@ -120,19 +102,7 @@ }; } } -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) { @@ -146,9 +116,8 @@ getParentContainer(InputUI.class).setTreeSelection("$root/$cells/"+c.getTopiaId()); } ]]></script> - <row> - <cell fill='both' weighty='1.0' weightx='1.0'> - <JSplitPane id="CellTab" name="Cells" + <JPanel id='body' layout='{new BorderLayout()}'> + <JSplitPane id="CellTab" name="Cells" constraints='BorderLayout.CENTER' oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> <Table> <row> @@ -161,7 +130,7 @@ <JLabel text="isisfish.cell.name" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellName" text='{getBean().getName()}' onKeyTyped='setChanged(true)' onFocusLost='if (isChanged()) {getBean().setName(fieldCellName.getText());}' enabled='{isActif()}'/> + <JTextField id="fieldCellName" text='{jaxx.runtime.Util.getStringValue(getBean().getName())}' onKeyReleased='setChanged(true)' onFocusLost='getBean().setName(fieldCellName.getText())' enabled='{isActif()}'/> </cell> </row> <row> @@ -185,7 +154,7 @@ <JLabel text="isisfish.cell.land" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldCellLand" onActionPerformed='setChanged(true); getBean().setLand(fieldCellLand.isSelected());' enabled='{isActif()}' selected='{getBean().getLand()}'/> + <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActif()}' selected='{getBean().getLand()}'/> </cell> </row> <row> @@ -196,28 +165,23 @@ <row> <cell columns='2' fill='both' weighty='1.0' weightx='1.0'> <JScrollPane> - <JTextArea id="fieldCellComment" text='{jaxx.runtime.Util.getStringValue(getBean().getComment())}' onKeyTyped='setChanged(true)' onFocusLost='if (isChanged()) { getBean().setComment(fieldCellComment.getText()); }' enabled='{isActif()}'/> + <JTextArea id="fieldCellComment" text='{jaxx.runtime.Util.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldCellComment.getText())' enabled='{isActif()}'/> </JScrollPane> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> </cell> </row> </Table> <JPanel id='map' layout='{new BorderLayout()}'> - <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()'/> + <fr.ifremer.isisfish.map.OpenMapToolPanel id='toolMap' javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' constraints='BorderLayout.NORTH'/> + <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' constraints='BorderLayout.CENTER'/> </JPanel> </JSplitPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueZones" onActionPerformed='getParentContainer(InputUI.class).setTreeSelection("$root/$zones")'/> - </cell> - </row> -</Table> \ No newline at end of file + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,354 +30,209 @@ * by : $Author: sletellier $ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.SetOfVesselsImpl id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.EffortDescriptionImpl id='effortDescription' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.EffortDescription; - import fr.ifremer.isisfish.entities.Metier; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.types.TimeUnit; +import fr.ifremer.isisfish.entities.EffortDescription; +import fr.ifremer.isisfish.entities.EffortDescriptionImpl; +import fr.ifremer.isisfish.entities.SetOfVesselsImpl; +import fr.ifremer.isisfish.entities.SetOfVessels; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.types.TimeUnit; - public EffortDescriptionUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - fr.ifremer.isisfish.entities.SetOfVessels setOfVessels = getContextValue(InputAction.class).getSetOfVessels(); - if (setOfVessels != null){ - setEffortDescriptionMetierListModel(); - if (fieldEffortDescriptionEffortDescriptionList.getSelectedValue() == null){ - setEffortDescriptionEffortDescriptionListModel(getContextValue(InputAction.class).getSetOfVessels()); - } - Object value = fieldEffortDescriptionEffortDescriptionList.getSelectedValue(); - if (value != null){ - setEffortDescriptionEffortDescriptionListModel(getContextValue(InputAction.class).getSetOfVessels()); - EffortDescription effort = (EffortDescription)((GenericCell)value).getValue(); - fieldEffortDescriptionFishingOperation.setText(effort.getFishingOperation() + ""); - fieldEffortDescriptionFishingOperationDuration.setText(effort.getFishingOperationDuration() + ""); - fieldEffortDescriptionGearsNumberPerOperation.setText(effort.getGearsNumberPerOperation() + ""); - fieldEffortDescriptionCrewSize.setText(effort.getCrewSize() + ""); - fieldEffortDescriptionUnitCostOfFishing.setText(effort.getUnitCostOfFishing() + ""); - fieldEffortDescriptionFixedCrewSalary.setText(effort.getFixedCrewSalary() + ""); - fieldEffortDescriptionCrewFoodCost.setText(effort.getCrewFoodCost() + ""); - fieldEffortDescriptionCrewShareRate.setText(effort.getCrewShareRate() + ""); - fieldEffortDescriptionRepairAndMaintenanceGearCost.setText(effort.getRepairAndMaintenanceGearCost() + ""); - fieldEffortDescriptionLandingCosts.setText(effort.getLandingCosts() + ""); - fieldEffortDescriptionOtherRunningCost.setText(effort.getOtherRunningCost() + ""); - } - else{ - DefaultListModel model = new DefaultListModel(); - fieldEffortDescriptionEffortDescriptionList.setModel(model); - fieldEffortDescriptionFishingOperation.setText(""); - fieldEffortDescriptionFishingOperationDuration.setText(""); - fieldEffortDescriptionGearsNumberPerOperation.setText(""); - fieldEffortDescriptionCrewSize.setText(""); - fieldEffortDescriptionUnitCostOfFishing.setText(""); - fieldEffortDescriptionFixedCrewSalary.setText(""); - fieldEffortDescriptionCrewFoodCost.setText(""); - fieldEffortDescriptionCrewShareRate.setText(""); - fieldEffortDescriptionRepairAndMaintenanceGearCost.setText(""); - fieldEffortDescriptionLandingCosts.setText(""); - fieldEffortDescriptionOtherRunningCost.setText(""); - - } +setType("SetOfVessels"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + fieldEffortDescriptionFishingOperation.setText(""); + fieldEffortDescriptionFishingOperationDuration.setText(""); + fieldEffortDescriptionGearsNumberPerOperation.setText(""); + fieldEffortDescriptionCrewSize.setText(""); + fieldEffortDescriptionUnitCostOfFishing.setText(""); + fieldEffortDescriptionFixedCrewSalary.setText(""); + fieldEffortDescriptionCrewFoodCost.setText(""); + fieldEffortDescriptionCrewShareRate.setText(""); + fieldEffortDescriptionRepairAndMaintenanceGearCost.setText(""); + fieldEffortDescriptionLandingCosts.setText(""); + fieldEffortDescriptionOtherRunningCost.setText(""); } - } - protected void setEffortDescriptionMetierListModel(){ - java.util.List<Metier> metiers = getContextValue(InputAction.class).getFisheryRegion().getMetier(); - DefaultListModel model = new DefaultListModel(); - if (metiers != null){ - for (Metier m : metiers){ - model.addElement(new GenericCell(m.getName(), m, Metier.class)); - } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldEffortDescriptionMetierList.setModel(model); } - protected void setEffortDescriptionEffortDescriptionListModel(fr.ifremer.isisfish.entities.SetOfVessels setOfVessels){ - Collection<EffortDescription> possibleMetiers = setOfVessels.getPossibleMetiers(); - DefaultListModel model = new DefaultListModel(); - if (possibleMetiers != null){ - for (EffortDescription m : possibleMetiers){ - model.addElement(new GenericCell(m.getPossibleMetiers().getName(), m, EffortDescription.class)); - } - } - fieldEffortDescriptionEffortDescriptionList.setModel(model); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$setOfVessels/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(GearUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } - protected void add(){ - fr.ifremer.isisfish.entities.SetOfVessels setOfVessels = getContextValue(InputAction.class).getSetOfVessels(); - if (setOfVessels != null){ - Object value = fieldEffortDescriptionMetierList.getSelectedValue(); - if (value != null){ - Metier m = (Metier)((GenericCell)value).getValue(); - getContextValue(InputAction.class).addEffortDescription(setOfVessels, m); - setEffortDescriptionEffortDescriptionListModel(getContextValue(InputAction.class).getSetOfVessels()); - valueChanged(true); - } - } -// refresh(); - } - protected void remove(){ - fr.ifremer.isisfish.entities.SetOfVessels setOfVessels = getContextValue(InputAction.class).getSetOfVessels(); - if (setOfVessels != null){ - Object value = fieldEffortDescriptionEffortDescriptionList.getSelectedValue(); - if (value != null){ - EffortDescription e = (EffortDescription)((GenericCell)value).getValue(); - getContextValue(InputAction.class).removeEffortDescription(setOfVessels, e); - valueChanged(false); - setEffortDescriptionEffortDescriptionListModel(getContextValue(InputAction.class).getSetOfVessels()); - refresh(); - } - } - } - protected EffortDescription getEffortDescription(){ - Object value = fieldEffortDescriptionMetierList.getSelectedValue(); - EffortDescription result = null; - if (value != null){ - Metier m = (Metier)((GenericCell)value).getValue(); - result = getContextValue(InputAction.class).getSetOfVessels().getPossibleMetiers(m); - } - return result; - } - protected void fishingOperationChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setFishingOperation(Integer.parseInt(fieldEffortDescriptionFishingOperation.getText())); - valueChanged(true); - } - } - protected void fishingOperationDurationChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setFishingOperationDuration(new TimeUnit(Double.parseDouble(fieldEffortDescriptionFishingOperationDuration.getText()))); - valueChanged(true); - } - } - protected void gearsNumberPerOperationChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setGearsNumberPerOperation(Integer.parseInt(fieldEffortDescriptionGearsNumberPerOperation.getText())); - valueChanged(true); - } - } - protected void descriptionCrewSizeChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setCrewSize(Integer.parseInt(fieldEffortDescriptionCrewSize.getText())); - valueChanged(true); - } - } - protected void costOfFishingChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setUnitCostOfFishing(Double.parseDouble(fieldEffortDescriptionUnitCostOfFishing.getText())); - valueChanged(true); - } - } - protected void fixedCrewSalaryChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setFixedCrewSalary(Double.parseDouble(fieldEffortDescriptionFixedCrewSalary.getText())); - valueChanged(true); - } - } - protected void crewFoodCostChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setCrewFoodCost(Double.parseDouble(fieldEffortDescriptionCrewFoodCost.getText())); - valueChanged(true); - } - } - protected void crewShareRateChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setCrewShareRate(Double.parseDouble(fieldEffortDescriptionCrewShareRate.getText())); - valueChanged(true); - } - } - protected void repairAndMaintenanceGearCostChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setRepairAndMaintenanceGearCost(Double.parseDouble(fieldEffortDescriptionRepairAndMaintenanceGearCost.getText())); - valueChanged(true); - } - } - protected void langdingCostsChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setLandingCosts(Double.parseDouble(fieldEffortDescriptionLandingCosts.getText())); - } - } - protected void otherRunningCostChanged(){ - EffortDescription possibleMetier = getEffortDescription(); - if (possibleMetier != null){ - possibleMetier.setOtherRunningCost(Double.parseDouble(fieldEffortDescriptionOtherRunningCost.getText())); - valueChanged(true); - } - } +}); + +public void refresh(){ + SetOfVessels setOfVessels = (SetOfVessels)getVerifier().getEntity(SetOfVessels.class); + setBean((SetOfVesselsImpl) setOfVessels); + jaxx.runtime.swing.Utils.fillList(fieldEffortDescriptionMetierList,getRegion().getMetier(), null); + setEffortDescriptionEffortDescriptionList(); +} +protected void setEffortDescriptionEffortDescriptionList(){ + jaxx.runtime.swing.Utils.fillList(fieldEffortDescriptionEffortDescriptionList,getBean().getPossibleMetiers(), null); +} +protected void add(){ + Object value = fieldEffortDescriptionMetierList.getSelectedValue(); + if (value != null){ + Metier m = (Metier)value; + getContextValue(InputAction.class).addEffortDescription(getBean(), m); + setEffortDescriptionEffortDescriptionList(); + } +} +protected void remove(){ + Object value = fieldEffortDescriptionEffortDescriptionList.getSelectedValue(); + if (value != null){ + EffortDescription e = (EffortDescription)value; + getContextValue(InputAction.class).removeEffortDescription(getBean(), e); + setEffortDescriptionEffortDescriptionList(); + } +} ]]> </script> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JList id="fieldEffortDescriptionMetierList" selectionMode="0" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='both' weightx='0.5'> - <Table> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="0" onValueChanged='refresh()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='0.5'> - <Table> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.fishingOperation" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionFishingOperation" onKeyTyped='valueChanged(true)' onFocusLost='fishingOperationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.fishingOperationDuration" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionFishingOperationDuration" onKeyTyped='valueChanged(true)' onFocusLost='fishingOperationDurationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.gearsNumberPerOperation" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionGearsNumberPerOperation" onKeyTyped='valueChanged(true)' onFocusLost='gearsNumberPerOperationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.crewSize" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionCrewSize" onKeyTyped='valueChanged(true)' onFocusLost='descriptionCrewSizeChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.unitCostOfFishing" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionUnitCostOfFishing" onKeyTyped='valueChanged(true)' onFocusLost='costOfFishingChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.fixedCrewSalary" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionFixedCrewSalary" onKeyTyped='valueChanged(true)' onFocusLost='fixedCrewSalaryChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.crewFoodCost" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionCrewFoodCost" onKeyTyped='valueChanged(true)' onFocusLost='crewFoodCostChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.crewShareRate" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionCrewShareRate" onKeyTyped='valueChanged(true)' onFocusLost='crewShareRateChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.repairAndMaintenanceGearCost" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionRepairAndMaintenanceGearCost" onKeyTyped='valueChanged(true)' onFocusLost='repairAndMaintenanceGearCostChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.landingCosts" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionLandingCosts" onKeyTyped='valueChanged(true)' onFocusLost='langdingCostsChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.effortDescription.otherRunningCost" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldEffortDescriptionOtherRunningCost" onKeyTyped='valueChanged(true)' onFocusLost='otherRunningCostChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.3'> - <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='{isChanged()}'/> - </cell> - <cell fill='horizontal' weightx='0.3'> - <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JList id="fieldEffortDescriptionMetierList" selectionMode="0" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='both' weightx='0.5'> + <Table> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="0" onMouseClicked='setEffortDescription((EffortDescriptionImpl)fieldEffortDescriptionEffortDescriptionList.getSelectedValue())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='0.5'> + <Table> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.fishingOperation" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionFishingOperation" text='getEffortDescription().getFishingOperation()' onKeyTyped='getEffortDescription().setFishingOperation(Integer.parseInt(fieldEffortDescriptionFishingOperation.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.fishingOperationDuration" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionFishingOperationDuration" text='getEffortDescription().getFishingOperationDuration()' onKeyTyped='getEffortDescription().setFishingOperationDuration(new TimeUnit(Double.parseDouble(fieldEffortDescriptionFishingOperationDuration.getText())))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.gearsNumberPerOperation" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionGearsNumberPerOperation" text='getEffortDescription().getGearsNumberPerOperation()' onKeyTyped='getEffortDescription().setGearsNumberPerOperation(Integer.parseInt(fieldEffortDescriptionGearsNumberPerOperation.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.crewSize" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionCrewSize" text='getEffortDescription().getCrewSize()' onKeyTyped='getEffortDescription().setCrewSize(Integer.parseInt(fieldEffortDescriptionCrewSize.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.unitCostOfFishing" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionUnitCostOfFishing" text='getEffortDescription().getUnitCostOfFishing()' onKeyTyped='getEffortDescription().setUnitCostOfFishing(Double.parseDouble(fieldEffortDescriptionUnitCostOfFishing.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.fixedCrewSalary" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionFixedCrewSalary" text='getEffortDescription().getFixedCrewSalary()' onKeyTyped='getEffortDescription().setFixedCrewSalary(Double.parseDouble(fieldEffortDescriptionFixedCrewSalary.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.crewFoodCost" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionCrewFoodCost" text='getEffortDescription().getCrewFoodCost()' onKeyTyped='getEffortDescription().setCrewFoodCost(Double.parseDouble(fieldEffortDescriptionCrewFoodCost.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.crewShareRate" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionCrewShareRate" text='getEffortDescription().getCrewShareRate()' onKeyTyped='getEffortDescription().setCrewShareRate(Double.parseDouble(fieldEffortDescriptionCrewShareRate.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.repairAndMaintenanceGearCost" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionRepairAndMaintenanceGearCost" text='getEffortDescription().getRepairAndMaintenanceGearCost()' onKeyTyped='getEffortDescription().setRepairAndMaintenanceGearCost(Double.parseDouble(fieldEffortDescriptionRepairAndMaintenanceGearCost.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.landingCosts" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionLandingCosts" text='getEffortDescription().getLandingCosts()' onKeyTyped='getEffortDescription().setLandingCosts(Double.parseDouble(fieldEffortDescriptionLandingCosts.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.effortDescription.otherRunningCost" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldEffortDescriptionOtherRunningCost" text='getEffortDescription().getOtherRunningCost()' onKeyTyped='getEffortDescription().setOtherRunningCost(Double.parseDouble(fieldEffortDescriptionOtherRunningCost.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.3'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.3'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + <cell fill='horizontal' weightx='0.3'> + <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/FisheryRegionUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -33,63 +33,33 @@ <!-- + FisheryRegion +--> -<Table id="inputFisheryRegion" implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.FisheryRegionImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> + <script><![CDATA[ +import fr.ifremer.isisfish.entities.FisheryRegion; +import com.bbn.openmap.gui.OMToolSet; +import fr.ifremer.isisfish.map.CellSelectionLayer; +import com.bbn.openmap.event.SelectMouseMode; +import fr.ifremer.isisfish.entities.FisheryRegionImpl; +protected OMToolSet toolSet = new OMToolSet(); - <script> - <![CDATA[ - import fr.ifremer.isisfish.entities.FisheryRegion; - import com.bbn.openmap.gui.OMToolSet; - import fr.ifremer.isisfish.map.IsisMapBean; - import fr.ifremer.isisfish.map.CellSelectionLayer; - import com.bbn.openmap.event.SelectMouseMode; - import fr.ifremer.isisfish.map.OpenMapToolPanel; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - - protected FisheryRegion region = null; - protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); - protected OMToolSet toolSet = new OMToolSet(); - - init(); - public FisheryRegionUI(InputAction action){ - setContextValue(action); - } - protected void init(){ - region = getContextValue(InputAction.class).getFisheryRegion(); + public void refresh(){ + setBean(null); + FisheryRegion region = (FisheryRegion) getVerifier().getEntity(FisheryRegion.class); + setBean((FisheryRegionImpl)region); if (region != null){ + setFieldMapfilesModel(getBean()); cellMap.setSelectionMode(CellSelectionLayer.SINGLE_SELECTION); cellMap.setActiveMouseMode(new SelectMouseMode()); - cellMap.setFisheryRegion(region); + cellMap.setFisheryRegion(getBean()); toolSet.setupListeners(cellMap); toolMap.add((Component)toolSet); - map.add(toolMap, BorderLayout.NORTH); } } - public void refresh(){ - if (region != getContextValue(InputAction.class).getFisheryRegion()){ - init(); - } - if (region != null){ - fieldRegion.setText(region.getName()); - fieldLatMin.setText(region.getMinLatitude() + ""); - fieldLatMax.setText(region.getMaxLatitude() + ""); - fieldLongMin.setText(region.getMinLongitude() + ""); - fieldLongMax.setText(region.getMaxLongitude() + ""); - fieldCellLengthLatitude.setText(region.getCellLengthLatitude() + ""); - fieldCellLengthLongitude.setText(region.getCellLengthLongitude() + ""); - setFieldMapfilesModel(region); - fieldComment.setText(region.getComment()); - refreshMap(); - } - } - protected void refreshMap(){ -// cellMap.repaint(); - } protected void setFieldMapfilesModel(FisheryRegion region){ DefaultListModel model = new DefaultListModel(); java.util.List<String> mapList = region.getMapFileList(); @@ -102,39 +72,6 @@ } fieldMapfiles.setModel(model); } - protected void valueChanged(boolean b){ - changed = b; - save.setEnabled(b); - cancel.setEnabled(b); - } - protected void regionChanged(){ - region.setName(fieldRegion.getText()); - refreshMap(); - } - protected void latMinChanged(){ - region.setMinLatitude(Float.parseFloat(fieldLatMin.getText())); - refreshMap(); - } - protected void latMaxChanged(){ - region.setMaxLatitude(Float.parseFloat(fieldLatMax.getText())); - refreshMap(); - } - protected void longMinChanged(){ - region.setMinLongitude(Float.parseFloat(fieldLongMin.getText())); - refreshMap(); - } - protected void longMaxChanged(){ - region.setMaxLongitude(Float.parseFloat(fieldLongMax.getText())); - refreshMap(); - } - protected void cellLenghtLatChanged(){ - region.setCellLengthLatitude(Float.parseFloat(fieldCellLengthLatitude.getText())); - refreshMap(); - } - protected void cellLenghtLongChanged(){ - region.setCellLengthLongitude(Float.parseFloat(fieldCellLengthLongitude.getText())); - refreshMap(); - } protected void mapFieldChanged(){ Object[] values = fieldMapfiles.getSelectedValues(); java.util.List<String> valuesList = new ArrayList<String>(); @@ -143,59 +80,47 @@ valuesList.add((String)o); } } - region.setMapFileList(valuesList); - refreshMap(); + getBean().setMapFileList(valuesList); } protected void addMap(){ - getContextValue(InputAction.class).addMap(); - refreshMap(); + getContextValue(InputAction.class).addMap(getBean()); } protected void delMap(){ - getContextValue(InputAction.class).removeMap(fieldMapfiles.getSelectedValues()); - refreshMap(); + getContextValue(InputAction.class).removeMap(getBean(), fieldMapfiles.getSelectedValues()); } - protected void commentChanged(){ - region.setComment(fieldComment.getText()); - } protected void cellFillChanged(){ } protected void cellFile(){ getContextValue(InputAction.class).loadCellFile(fieldCellFile.getText()); - refreshMap(); } - protected void save(){ - setMsg(_("isisfish.message.checking.cell")); - getContextValue(InputAction.class).saveFisheryRegion("FisheryRegion"); - valueChanged(false); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setFieldCurrentRegionModel(); - setMsg(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - } +// protected void save(){ +// setMsg(_("isisfish.message.checking.cell")); +// getContextValue(InputAction.class).saveFisheryRegion("FisheryRegion"); +// valueChanged(false); +// getParentContainer(InputUI.class).setTreeModel(); +// getParentContainer(InputUI.class).setFieldCurrentRegionModel(); +// setMsg(_("isisfish.message.save.finished")); +// refresh(); +// } +// protected void cancel(){ +// getContextValue(InputAction.class).cancel(); +// valueChanged(false); +// refresh(); +// } protected void check(){ - getContextValue(InputAction.class).checkFisheryRegion(); - setMsg(_("isisfish.message.check.region")); + getContextValue(InputAction.class).checkFisheryRegion(getBean()); + setInfoText(_("isisfish.message.check.region")); } - protected void goToCell(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$cells"); - } - protected void setMsg(String msg){ - getParentContainer(WelcomePanelUI.class).setInfoText(msg); - } +// protected void goToCell(){ +// getParentContainer(InputUI.class).setTreeSelection("$root/$cells"); +// } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JSplitPane id="FisheryRegionTab" name="FisheryRegion" + <JPanel id='body' layout='{new BorderLayout()}'> + <JSplitPane id="FisheryRegionTab" name="FisheryRegion" constraints='BorderLayout.CENTER' oneTouchExpandable="true" dividerLocation="200" orientation="HORIZONTAL"> <Table> - <!-- Widget --> <row> <cell columns='3'> <JLabel text="isisfish.fisheryRegion.name"/> @@ -203,7 +128,7 @@ </row> <row> <cell columns='3' fill='horizontal' weightx='1.0'> - <JTextField id="fieldRegion" onKeyTyped='valueChanged(true)' onFocusLost='regionChanged()'/> + <JTextField id="fieldRegion" text='{jaxx.runtime.Util.getStringValue(getBean().getName())}' onKeyReleased='getBean().setName(fieldRegion.getText())'/> </cell> </row> <row> @@ -216,7 +141,7 @@ <JLabel text="isisfish.fisheryRegion.latitude.min"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldLatMin" onKeyTyped='valueChanged(true)' onFocusLost='latMinChanged()'/> + <JTextField id="fieldLatMin" text='{getBean().getMinLatitude()}' onKeyReleased='getBean().setMinLatitude(Float.parseFloat(fieldLatMin.getText()))'/> </cell> </row> <row> @@ -224,7 +149,7 @@ <JLabel text="isisfish.fisheryRegion.latitude.max"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldLatMax" onKeyTyped='valueChanged(true)' onFocusLost='latMaxChanged()'/> + <JTextField id="fieldLatMax" text='{getBean().getMaxLatitude()}' onKeyReleased='getBean().setMaxLatitude(Float.parseFloat(fieldLatMax.getText()))'/> </cell> </row> <row> @@ -232,7 +157,7 @@ <JLabel text="isisfish.fisheryRegion.longitude.min"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldLongMin" onKeyTyped='valueChanged(true)' onFocusLost='longMinChanged()'/> + <JTextField id="fieldLongMin" text='{getBean().getMinLongitude()}' onKeyReleased='getBean().setMinLongitude(Float.parseFloat(fieldLongMin.getText()))'/> </cell> </row> <row> @@ -240,7 +165,7 @@ <JLabel text="isisfish.fisheryRegion.longitude.max"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldLongMax" onKeyTyped='valueChanged(true)' onFocusLost='longMaxChanged()'/> + <JTextField id="fieldLongMax" text='{getBean().getMaxLongitude()}' onKeyReleased='getBean().setMaxLongitude(Float.parseFloat(fieldLongMax.getText()))'/> </cell> </row> <row> @@ -253,7 +178,7 @@ <JLabel text="isisfish.fisheryRegion.latitude"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLengthLatitude" onKeyTyped='valueChanged(true)' onFocusLost='cellLenghtLatChanged()'/> + <JTextField id="fieldCellLengthLatitude" text='{getBean().getCellLengthLatitude()}' onKeyReleased='getBean().setCellLengthLatitude(Float.parseFloat(fieldCellLengthLatitude.getText()))'/> </cell> </row> <row> @@ -261,7 +186,7 @@ <JLabel text="isisfish.fisheryRegion.longitude"/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLengthLongitude" onKeyTyped='valueChanged(true)' onFocusLost='cellLenghtLongChanged()'/> + <JTextField id="fieldCellLengthLongitude" text='{getBean().getCellLengthLongitude()}' onKeyReleased='getBean().setCellLengthLongitude(Float.parseFloat(fieldCellLengthLongitude.getText()))'/> </cell> </row> <row> @@ -293,7 +218,7 @@ <row> <cell columns='3' fill='both' weightx='1.0' weighty='0.4'> <JScrollPane> - <JTextArea id="fieldComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()'/> + <JTextArea id="fieldComment" text='{jaxx.runtime.Util.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldComment.getText())'/> </JScrollPane> </cell> </row> @@ -312,7 +237,7 @@ <Table> <row> <cell columns='4' fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellFile" onKeyTyped='valueChanged(true)' onFocusLost='cellFillChanged()'/> + <JTextField id="fieldCellFile" onKeyReleased='cellFillChanged()'/> </cell> <cell> <JButton id="buttonCellFile" text="isisfish.common.ellipsis" onActionPerformed='cellFile()'/> @@ -323,10 +248,10 @@ </row> <row> <cell fill='horizontal' weightx='0.3'> - <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> </cell> <cell fill='horizontal' weightx='0.3'> - <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> </cell> <cell fill='horizontal' weightx='0.3'> <JButton id='check' text="isisfish.common.check" onActionPerformed='check()'/> @@ -334,14 +259,9 @@ </row> </Table> <JPanel id='map' layout='{new BorderLayout()}'> - <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()'/> + <fr.ifremer.isisfish.map.OpenMapToolPanel id='toolMap' javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' constraints='BorderLayout.NORTH'/> + <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' fisheryRegion='{getBean()}' constraints='BorderLayout.CENTER'/> </JPanel> </JSplitPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueCells" onActionPerformed='goToCell()'/> - </cell> - </row> -</Table> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,27 +30,24 @@ * by : $Author: sletellier $ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.GearImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> <script><![CDATA[ import fr.ifremer.isisfish.entities.Gear; + import fr.ifremer.isisfish.entities.GearImpl; 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); - } public void refresh() { - Gear gear = getContextValue(InputAction.class).getGear(); + Gear gear = (Gear)getVerifier().getEntity(Gear.class); + setBean((GearImpl) gear); if (gear != null){ fieldGearName.setText(gear.getName()); fieldGearEffortUnit.setText(gear.getEffortUnit()); @@ -74,153 +71,113 @@ fieldGearComment.setText(""); } } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Gear"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$gears/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$gears"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(GearUI.class).setChanged(b); - } protected void nameChanged(){ - getContextValue(InputAction.class).getGear().setName(fieldGearName.getText()); - valueChanged(true); + getBean().setName(fieldGearName.getText()); } protected void effortUnitChanged(){ - getContextValue(InputAction.class).getGear().setEffortUnit(fieldGearEffortUnit.getText()); - valueChanged(true); + getBean().setEffortUnit(fieldGearEffortUnit.getText()); } protected void standardisationFactorChanged(){ - getContextValue(InputAction.class).getGear().setStandardisationFactor(Double.parseDouble(fieldGearStandardisationFactor.getText())); - valueChanged(true); + getBean().setStandardisationFactor(Double.parseDouble(fieldGearStandardisationFactor.getText())); } protected void paramNameChanged(){ - getContextValue(InputAction.class).getGear().setParameterName(fieldGearParamName.getSelectedText()); - valueChanged(true); + getBean().setParameterName(fieldGearParamName.getSelectedText()); } protected void paramTypeChanged(){ // TODO // getContextValue(InputAction.class).getGear().setParameterName(fieldGearParamName.getSelectedText()); -// valueChanged(true); } protected void paramPossibleValueChanged(){ if (fieldGearParamPossibleValue.getText() != ""){ - getContextValue(InputAction.class).getGear().setStandardisationFactor(Double.parseDouble(fieldGearParamPossibleValue.getText())); + getBean().setStandardisationFactor(Double.parseDouble(fieldGearParamPossibleValue.getText())); } - valueChanged(true); } protected void commentChanged(){ - getContextValue(InputAction.class).getGear().setComment(fieldGearComment.getText()); - valueChanged(true); + getBean().setComment(fieldGearComment.getText()); } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.name" enabled='{isActif()}'/> - </cell> - <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.effortUnit" enabled='{isActif()}'/> - </cell> - <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearEffortUnit" onKeyTyped='valueChanged(true)' onFocusLost='effortUnitChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.standardisationFactor" enabled='{isActif()}'/> - </cell> - <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearStandardisationFactor" onKeyTyped='valueChanged(true)' onFocusLost='standardisationFactorChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.technicalParameter" enabled='{isActif()}'/> - </cell> - <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearParamName" onKeyTyped='valueChanged(true)' onFocusLost='paramNameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.rangeValues" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldGearParamType" onActionPerformed='paramTypeChanged()' enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldGearParamPossibleValue" onKeyTyped='valueChanged(true)' onFocusLost='paramPossibleValueChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.gear.comments" enabled='{isActif()}'/> - </cell> - <cell columns="2" fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTextArea id="fieldGearComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id="save" enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <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()'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.name" enabled='{isActif()}'/> + </cell> + <cell columns="2" fill='horizontal' weightx='1.0'> + <JTextField id="fieldGearName" onKeyTyped='nameChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.effortUnit" enabled='{isActif()}'/> + </cell> + <cell columns="2" fill='horizontal' weightx='1.0'> + <JTextField id="fieldGearEffortUnit" onKeyTyped='effortUnitChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.standardisationFactor" enabled='{isActif()}'/> + </cell> + <cell columns="2" fill='horizontal' weightx='1.0'> + <JTextField id="fieldGearStandardisationFactor" onKeyTyped='standardisationFactorChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.technicalParameter" enabled='{isActif()}'/> + </cell> + <cell columns="2" fill='horizontal' weightx='1.0'> + <JTextField id="fieldGearParamName" onKeyTyped='paramNameChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.rangeValues" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldGearParamType" onActionPerformed='paramTypeChanged()' enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldGearParamPossibleValue" onKeyTyped='paramPossibleValueChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.gear.comments" enabled='{isActif()}'/> + </cell> + <cell columns="2" fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTextArea id="fieldGearComment" onKeyTyped='commentChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='remove' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,20 +35,11 @@ <!-- + Gear +--> -<JPanel id='panel' layout='{new BorderLayout()}' implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ import fr.ifremer.isisfish.entities.Metier; init(); - public GearUI (InputAction action){ - - setContextValue(action); - } public void refresh() { gearTabUI.refresh(); selectivityUI.refresh(); @@ -73,9 +64,11 @@ getParentContainer(InputUI.class).setTreeSelection("$root/$metiers"); } ]]></script> - <JTabbedPane constraints='BorderLayout.CENTER' id="GearTab" name="Gear"> - <tab title='{_("isisfish.gear.title")}'><GearTabUI id="gearTabUI" constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.selectivity.title")}'><SelectivityUI id="selectivityUI" constructorParams='getContextValue(InputAction.class)'/></tab> - </JTabbedPane> - <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueMetiers" onActionPerformed='goToMetier()'/> -</JPanel> + <JPanel id='body' layout='{new BorderLayout()}'> + <JTabbedPane constraints='BorderLayout.CENTER' id="GearTab" name="Gear"> + <tab title='{_("isisfish.gear.title")}'><GearTabUI id="gearTabUI"/></tab> + <tab title='{_("isisfish.selectivity.title")}'><SelectivityUI id="selectivityUI"/></tab> + </JTabbedPane> + </JPanel> + <!--JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueMetiers" onActionPerformed='goToMetier()'/--> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,7 +35,6 @@ */ import fr.ifremer.isisfish.IsisFishDAOHelper; -import fr.ifremer.isisfish.IsisFishEntityEnum; import fr.ifremer.isisfish.datastore.FormuleStorage; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.SimulationStorage; @@ -57,7 +56,6 @@ import org.codelutin.math.matrix.MatrixFactory; import org.codelutin.math.matrix.MatrixND; import org.codelutin.topia.TopiaContext; -import org.codelutin.topia.TopiaException; import org.codelutin.topia.persistence.TopiaDAO; import org.codelutin.topia.persistence.TopiaEntity; import org.codelutin.util.FileUtil; @@ -73,31 +71,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** @author letellier */ public class InputAction { /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(InputAction.class); - protected RegionStorage regionStorage = null; - protected FisheryRegion fisheryRegion = null; - protected TopiaContext isisContext = null; - protected TopiaEntity selected; - protected String path = null; - protected Cell cell; - protected Zone zone; - protected Port port; - protected Species species; - protected Population population; - protected Gear gear; - protected Metier metier; - protected TripType tripType; - protected VesselType vesselType; - protected SetOfVessels setOfVessels; - protected Strategy strategy; - protected boolean isNull = true; public InputAction() { if (log.isDebugEnabled()) { @@ -109,92 +88,7 @@ ErrorDialogUI.showError(eee); } - public void setValue(Object 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; - break; - case Port: - port = (Port) value; - break; - case Species: - species = (Species) value; - break; - case Population: - population = (Population) value; - species = population.getSpecies(); - break; - case Metier: - metier = (Metier) value; - break; - case TripType: - tripType = (TripType) value; - break; - case Gear: - gear = (Gear) value; - break; - case VesselType: - vesselType = (VesselType) value; - break; - case SetOfVessels: - setOfVessels = (SetOfVessels) value; - break; - case Strategy: - strategy = (Strategy) value; - break; - } - selected = (TopiaEntity) value; - } - public boolean isNull() { - return isNull; - } - - public void setPath(String path) { - this.path = path; - } - - public String getPath() { - return path; - } - - public TopiaContext getIsisContext() { - return isisContext; - } - - public RegionStorage getRegionStorage() { - return regionStorage; - } - - public void setSpecies(String topiaId) { - try { - species = IsisFishDAOHelper.getSpeciesDAO(isisContext).findByTopiaId(topiaId); - } catch (TopiaException ex) { - Logger.getLogger(InputAction.class.getName()).log(Level.SEVERE, null, ex); - } - } - /** * Exporter la region dans un zip * @@ -315,7 +209,7 @@ * * @return TODO */ - public File exportRegion() { + public File exportRegion(RegionStorage regionStorage) { File file = null; try { file = FileUtil.getFile(".*.zip$", _("isisfish.message.import.region.zipped")); @@ -341,7 +235,7 @@ * * @return TODO */ - public String copyRegion() { + public String copyRegion(RegionStorage regionStorage) { String newName = null; try { newName = showInputDialog(_("isisfish.message.new.region.name")); @@ -362,7 +256,7 @@ * @param cvsDelete if true delete region in CVS too * @return TODO */ - public String removeRegion(boolean cvsDelete) { + public String removeRegion(RegionStorage regionStorage, boolean cvsDelete) { String result = null; try { int resp = JOptionPane.showConfirmDialog(null, _( @@ -387,7 +281,7 @@ * * @return TODO */ - public String commitRegionInCVS() { + public String commitRegionInCVS(RegionStorage regionStorage) { String result = null; try { String msg = regionStorage.getCommentForNextCommit(); @@ -420,19 +314,22 @@ * * @param name name of region */ - public void loadRegion(String name) { + public void loadRegion(InputUI ui, String name) { if (log.isTraceEnabled()) { log.trace("loadRegion called"); } try { - regionStorage = null; - fisheryRegion = null; - isisContext = null; + RegionStorage regionStorage = null; + FisheryRegion fisheryRegion = null; + TopiaContext isisContext = null; if (name != null && !" ".equals(name)) { regionStorage = RegionStorage.getRegion(name); isisContext = regionStorage.getStorage().beginTransaction(); fisheryRegion = RegionStorage.getFisheryRegion(isisContext); } + ui.setContextValue(regionStorage); + ui.setContextValue(isisContext); + ui.setContextValue(fisheryRegion); } catch (Exception eee) { log.error("Can't load region", eee); showMsgBox(eee); @@ -464,22 +361,6 @@ } /** - * 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() { - return true; - } - - /** * Permet de creer simplement un nouvelle objet portant un nom par defaut. * Le nouvel element est automatiquement selectionné dans l'arbre * @@ -488,7 +369,7 @@ * @return null ou un fenetre d'erreur */ @SuppressWarnings("unchecked") - public TopiaEntity create(String type) { + public TopiaEntity create(TopiaContext isisContext, String type) { if (log.isTraceEnabled()) { log.trace("create called for " + type); } @@ -519,7 +400,7 @@ * * @return the saved entity */ - public TopiaEntity save() { + public TopiaEntity save(TopiaEntity selected) { if (log.isTraceEnabled()) { log.trace("save called"); } @@ -546,17 +427,17 @@ * * @return the roolbacked entity */ - public TopiaEntity cancel() { + public TopiaEntity cancel(TopiaEntity selected) { if (log.isTraceEnabled()) { log.trace("cancel called"); } try { + TopiaContext isisContext = selected.getTopiaContext(); 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); @@ -574,7 +455,7 @@ * * @return if ok return null else OutView error */ - public String remove() { + public String remove(TopiaEntity selected) { if (log.isTraceEnabled()) { log.trace("remove called"); } @@ -602,7 +483,7 @@ if (doDelete) { selected.delete(); - isisContext.commitTransaction(); + selected.getTopiaContext().commitTransaction(); msg = _("isisfish.message.remove.finished"); } else { msg = _("isisfish.message.remove.canceled"); @@ -686,75 +567,16 @@ return null; } - protected String getFisheryRegionName() { - if (fisheryRegion != null) { - return fisheryRegion.getName(); - } - return null; - } - - protected FisheryRegion getFisheryRegion() { - return fisheryRegion; - } - - protected TopiaEntity getSelected() { - return selected; - } - - protected Cell getCell() { - return cell; - } - - protected Zone getZone() { - return zone; - } - - protected Port getPort() { - return port; - } - - protected Species getSpecies() { - return species; - } - - protected Population getPopulation() { - return population; - } - - protected Gear getGear() { - return gear; - } - - protected Metier getMetier() { - return metier; - } - - protected TripType getTripType() { - return tripType; - } - - protected VesselType getVesselType() { - return vesselType; - } - - protected SetOfVessels getSetOfVessels() { - return setOfVessels; - } - - protected Strategy getStrategy() { - return strategy; - } - - protected List<Formule> getFormules(String name) { + protected List<Formule> getFormules(TopiaContext isisContext, String name) { return FormuleStorage.getFormules(isisContext, name); } // InputGear - public Object addSelectivity(Population pop, String equation) { + public Object addSelectivity(Population pop, String equation, Gear gear) { try { - SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(isisContext); + SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(pop.getTopiaContext()); Selectivity selectivity = dao.create(); selectivity.setGear(gear); @@ -772,7 +594,7 @@ return null; } - public Object removeSelectivity(Selectivity selectivity) { + public Object removeSelectivity(Gear gear, Selectivity selectivity) { if (log.isTraceEnabled()) { log.trace("removeTargetSpecies called: " + selectivity); } @@ -789,12 +611,12 @@ // InputMetier - public Object createSeasonInfo() { + public Object createSeasonInfo(Metier metier) { if (log.isTraceEnabled()) { log.trace("createSeasonInfo called"); } try { - MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper.getMetierSeasonInfoDAO(isisContext); + MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper.getMetierSeasonInfoDAO(metier.getTopiaContext()); MetierSeasonInfo metierSeasonInfo = metierSeasonInfoPS.create(); metierSeasonInfo.setFirstMonth(Month.MONTH[0]); metierSeasonInfo.setLastMonth(Month.MONTH[3]); @@ -810,14 +632,14 @@ return null; } - public Object removeSeasonInfo(MetierSeasonInfo info) { + public Object removeSeasonInfo(Metier metier, MetierSeasonInfo info) { if (log.isTraceEnabled()) { log.trace("createSeasonInfo called"); } try { metier.removeMetierSeasonInfo(info); metier.update(); - isisContext.commitTransaction(); + metier.getTopiaContext().commitTransaction(); } catch (Exception eee) { log.error("Can't create MetierSeasonInfo", eee); showMsgBox(eee); @@ -825,12 +647,12 @@ return null; } - public Object addTargetSpecies(MetierSeasonInfo m, Species species, String targetFactorEquation, boolean primaryCatch) { + public Object addTargetSpecies(Metier metier, 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); + TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(metier.getTopiaContext()); TargetSpecies targetSpecies = dao.create(); targetSpecies.setSpecies(species); @@ -866,7 +688,7 @@ log.trace("addEffortDescription called: " + setOfVessels + " metier: " + metier); } try { - EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper.getEffortDescriptionDAO(isisContext); + EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper.getEffortDescriptionDAO(metier.getTopiaContext()); EffortDescription effortDescription = effortDescriptionPS.create(); effortDescription.setPossibleMetiers(metier); effortDescription.update(); @@ -884,7 +706,7 @@ } try { sov.removePossibleMetiers(effort); - isisContext.commitTransaction(); + sov.getTopiaContext().commitTransaction(); } catch (Exception eee) { log.error("Can't remove entity: " + effort, eee); showMsgBox(eee); @@ -894,14 +716,14 @@ // Population - public Population createPopulation() { + public Population createPopulation(Species species) { if (log.isTraceEnabled()) { log.trace("create called"); } try { String name = "Population_new"; - PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(isisContext); + PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(species.getTopiaContext()); Population pop = dao.create(); pop.setName(name); @@ -911,7 +733,7 @@ // population = pop; // population.update(); species.update(); - isisContext.commitTransaction(); + species.getTopiaContext().commitTransaction(); return pop; } catch (Exception eee) { log.error("Can't create Population", eee); @@ -921,9 +743,9 @@ return null; } - public Object createRecruitmentDistribution() { + public Object createRecruitmentDistribution(Population pop) { if (log.isTraceEnabled()) { - log.trace("createRecruitmentDistributionontext called: " + population); + log.trace("createRecruitmentDistributionontext called: " + pop); } try { String val = JOptionPane.showInputDialog(_("isisfish.message.recruitment.number.month")); @@ -945,12 +767,12 @@ } MatrixND newMat = MatrixFactory.getInstance().create(new List[]{sem}); - MatrixND mat = population.getRecruitmentDistribution(); + MatrixND mat = pop.getRecruitmentDistribution(); if (mat != null) { newMat.paste(mat); } - population.setRecruitmentDistribution(newMat); - population.update(); + pop.setRecruitmentDistribution(newMat); + pop.update(); } } catch (Exception eee) { log.error("Can't remove PopulationSeasonInfo", eee); @@ -1012,7 +834,7 @@ // FisheryRegion /** @return TODO */ - public Object addMap() { + public Object addMap(FisheryRegion fisheryRegion) { if (log.isTraceEnabled()) { log.trace("AddMap called"); } @@ -1057,7 +879,7 @@ * @param selectedMaps la list dans lequel il faut retirer la carte * @return TODO */ - public Object removeMap(Object[] selectedMaps) { + public Object removeMap(FisheryRegion fisheryRegion, Object[] selectedMaps) { if (log.isTraceEnabled()) { log.trace("removeMap called"); } @@ -1100,7 +922,7 @@ // FIXME todo loadCellFile } - public Object saveFisheryRegion(String type) { + public Object saveFisheryRegion(FisheryRegion fisheryRegion, String type) { if (log.isTraceEnabled()) { log.trace("save called"); } @@ -1176,7 +998,7 @@ return null; } - public Object checkFisheryRegion() { + public Object checkFisheryRegion(FisheryRegion fisheryRegion) { try { if (log.isTraceEnabled()) { log.trace("check called: "); Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContent.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContent.java 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContent.java 2009-01-02 17:22:04 UTC (rev 1724) @@ -1,27 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package fr.ifremer.isisfish.ui.input; - -import jaxx.runtime.JAXXObject; - -/** - * - * @author letellier - */ -public interface InputContent extends JAXXObject { - - void refresh(); - - java.lang.Boolean isActif(); - - java.lang.Boolean isChanged(); - - void setActif(java.lang.Boolean b); - - void setChanged(java.lang.Boolean b); - - String getName(); -} Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -0,0 +1,60 @@ +<JPanel layout='{new BorderLayout()}'> + + <!-- ui state when editing --> + <Boolean id='actif' javaBean='false'/> + + <!-- ui state when editing and modified --> + <Boolean id='changed' javaBean='false'/> + + <!-- ui state when a bean is selected in list --> + <Boolean id='selected' javaBean='false'/> + + <!-- New button enabled --> + <Boolean id='newEnabled' javaBean='false'/> + + <!-- Cancel button enabled --> + <Boolean id='cancelEnabled' javaBean='false'/> + + <!-- Save button enabled --> + <Boolean id='saveEnabled' javaBean='false'/> + + <!-- Delete button enabled --> + <Boolean id='deleteEnabled' javaBean='false'/> + + <!-- Next button enabled --> + <Boolean id='buttonEnabled' javaBean='true'/> + + <!-- Next button title --> + <java.lang.String id='buttonTitle' javaBean='""'/> + + <!-- Next button title --> + <java.lang.String id='nextPath' javaBean='null'/> + + <!-- Next button title --> + <java.lang.String id='type' javaBean='null'/> + + <script><![CDATA[ +import fr.ifremer.isisfish.ui.WelcomePanelUI; +import fr.ifremer.isisfish.entities.FisheryRegion; +public void refresh(){ +} +public InputAction getAction() { + return getContextValue(InputAction.class); +} +public InputSaveVerifier getVerifier(){ + return getContextValue(InputSaveVerifier.class); +} +public FisheryRegion getRegion(){ + return getContextValue(FisheryRegion.class); +} +public void setInfoText(String msg){ + getParentContainer(WelcomePanelUI.class).setInfoText(msg); +} +protected void goTo(){ + getParentContainer(InputUI.class).setTreeSelection(getNextPath()); +} +]]> + </script> + <JPanel id='body' constraints='BorderLayout.CENTER'/> + <JButton id='next' text='{getButtonTitle()}' constraints='BorderLayout.SOUTH' enabled='{isButtonEnabled()}' visible='{getNextPath() != null}' onActionPerformed='goTo()'/> +</JPanel> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,6 +35,7 @@ import javax.swing.JTree; import javax.swing.event.TreeSelectionEvent; import java.awt.Component; +import org.hibernate.transaction.JOTMTransactionManagerLookup; /** @author letellier */ public class InputNavigationTreeSelectionAdapter extends NavigationTreeSelectionAdapterWithCardLayout { @@ -43,6 +44,7 @@ static private final Log log = LogFactory.getLog(InputNavigationTreeSelectionAdapter.class); protected NavigationTreeNode currentNode = null; + protected InputContentUI currentUI = null; public InputNavigationTreeSelectionAdapter(InputUI context, boolean register) { super(InputUI.class, null, context, Strategy.PER_UI_TYPE); @@ -92,20 +94,12 @@ super.openUI(newUI, node); // 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).isNull(); - if (log.isDebugEnabled()) { - log.debug(parameter); - } -// Method setActif = newUI.getClass().getDeclaredMethod("setActif", Boolean.class); -// setActif.setAccessible(true); -// setActif.invoke(newUI, parameter); - ui.setActif(parameter); - ui.refresh(); + currentUI = (InputContentUI) newUI; + InputSaveVerifier verif = context.getContextValue(InputSaveVerifier.class); + verif.removeAllPanels(); + verif.addCurrentPanel(currentUI); + currentUI.refresh(); currentNode = node; -// Method refresh = newUI.getClass().getDeclaredMethod("refresh"); -// refresh.setAccessible(true); -// refresh.invoke(newUI); } catch (Exception e) { log.debug(e.getMessage(), e); } @@ -113,63 +107,41 @@ @Override protected boolean closeUI(TreeSelectionEvent event, Component component) throws Exception { - // by default, we says that component was succesfull closed - boolean exit = checkEdit(event, component); - return exit; - } - public boolean checkEdit(TreeSelectionEvent event, Component content) { boolean exit = true; - if (content != null) { - InputContent ui = (InputContent) content; - if (log.isDebugEnabled()) { - log.debug(ui.getClass()+"["+ui.getName() + "] <changed:" + ui.isChanged() + ", actif: " + ui.isActif()+">"); + // by default, we says that component was succesfull closed + InputSaveVerifier verif = context.getContextValue(InputSaveVerifier.class); + int responce = verif.checkEdit(); + //boolean exit = checkEdit(event, component); + if (responce == JOptionPane.OK_OPTION){ + JTree tree = (JTree) event.getSource(); + NavigationTreeModel model = (NavigationTreeModel) tree.getModel(); + if (currentNode != null) { + model.nodeChanged(currentNode); } - if (ui.isActif()) { - if (ui.isChanged()) { - // ask user to close edition - // still in edit mode, must warn user - int responce = askUser(content, _("isisfish.message.page.modified")); - if (responce == JOptionPane.NO_OPTION) { - context.getContextValue(InputAction.class).cancel(); - } 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); - } - } else { - exit = false; - } - } - } } + else if (responce == JOptionPane.CANCEL_OPTION){ + exit = false; + } return exit; } - public int askUser(Component parent, String message) { - int response = JOptionPane.showConfirmDialog(parent, message, - _("isisfish.input.menu.commit"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); - return response; - } - @Override protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) { if (log.isDebugEnabled()) { log.debug("find data for contextPath <" + node.getContextPath() + "> : " + (data == null ? null : data.getClass())); } - InputAction action = context.getContextValue(InputAction.class); - action.setValue(data); - /*if (data != null) { - action.setValue(data); - }*/ - action.setPath(node.getContextPath()); + InputSaveVerifier verif = context.getContextValue(InputSaveVerifier.class); + + verif.removeAllEntity(); + verif.setRootPanel((InputUI)context); + if (TopiaEntity.class.isInstance(data)){ + verif.addCurrentEntity((TopiaEntity) data); + } + verif.setCurrentNode(node); } public static NavigationTreeModel getTreeModel(String regionName, FisheryRegion fisheryRegion) { - //String regionName = context.getContextValue(InputAction.class).getFisheryRegionName(); NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/"); if (regionName == null) { Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputSaveVerifier.java 2009-01-02 17:22:04 UTC (rev 1724) @@ -0,0 +1,386 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package fr.ifremer.isisfish.ui.input; + +import fr.ifremer.isisfish.IsisFishDAOHelper; +import fr.ifremer.isisfish.ui.widget.ErrorDialogUI; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JButton; +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; +import jaxx.runtime.JAXXAction; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXInitialContext; +import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; +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 org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.persistence.TopiaDAO; +import org.codelutin.topia.persistence.TopiaEntity; +import static org.codelutin.i18n.I18n._; + +/** + * + * @author letellier + */ +public class InputSaveVerifier implements JAXXAction { + protected JButton newButton = null; + protected JButton deleteButton = null; + protected JButton saveButton = null; + protected JButton cancelButton = null; + protected boolean editable = false; + protected boolean changed = false; + + protected NavigationTreeNode currentNode = null; + protected String currentOnglet = null; + + protected TopiaContext isisContext = null; + protected List<TopiaEntity> currentEntities = new ArrayList <TopiaEntity>(); + protected List<InputContentUI> currentPanels = new ArrayList <InputContentUI>(); + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(InputAction.class); + protected InputUI rootUI; + + public InputSaveVerifier(){ + newButton = new JButton(_("isisfish.common.new")); + newButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + topiaCreate(); + } + }); + deleteButton = new JButton(_("isisfish.common.remove")); + deleteButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + topiaRemove(); + } + }); + saveButton = new JButton(_("isisfish.common.save")); + saveButton.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + topiaSave(); + } + + }); + cancelButton = new JButton(_("isisfish.common.cancel")); + cancelButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + topiaCancel(); + } + }); + } + @Override + public JAXXInitialContext init(JAXXContext parentContent, Object... datas) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int checkEdit() { + int responce = JOptionPane.NO_OPTION; + if (editable) { + if (changed) { + // ask user to close edition + // still in edit mode, must warn user + responce = askUser(_("isisfish.message.page.modified")); + if (responce == JOptionPane.NO_OPTION) { + topiaCancel(); + } else if (responce == JOptionPane.OK_OPTION) { + topiaSave(); + } + } + } + return responce; + } + + public int askUser(String message) { + int response = JOptionPane.showConfirmDialog(rootUI, message, + _("isisfish.input.menu.commit"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + return response; + } + + protected void topiaChanged(){ + changed = true; + setPanelsActifs(); + saveButton.setEnabled(true); + cancelButton.setEnabled(true); + newButton.setEnabled(false); + deleteButton.setEnabled(false); + } + protected void noModif(){ + changed = false; + setPanelsActifs(); + saveButton.setEnabled(false); + cancelButton.setEnabled(false); + newButton.setEnabled(true); + deleteButton.setEnabled(true); + } + + /** + * Delete one entity and commit the change, try to selected intelligently + * other node in tree. + * <p/> + * Refresh all ui component where name match "input<entity type without + * package >.*" + * + * @return if ok return null else OutView error + */ + public void topiaRemove() { + if (log.isTraceEnabled()) { + log.trace("remove called"); + } + String msg = ""; + try { + boolean doDelete; + ArrayList<TopiaEntity> allWillBeRemoved = new ArrayList<TopiaEntity>(); + for (TopiaEntity te : currentEntities){ + allWillBeRemoved.addAll(te.getComposite()); + } + if (allWillBeRemoved.size() > 0) { + String text = _( + "isisfish.message.delete.object", currentEntities.get(0).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", currentEntities.get(0).toString()); + int resp = JOptionPane.showConfirmDialog(null, text, + _("isisfish.message.delete.entity"), JOptionPane.YES_NO_OPTION); + doDelete = resp == JOptionPane.YES_OPTION; + } + + if (doDelete) { + for (TopiaEntity te : allWillBeRemoved){ + te.delete(); + } + isisContext.commitTransaction(); + msg = _("isisfish.message.remove.finished"); + } else { + msg = _("isisfish.message.remove.canceled"); + } + } catch (Exception eee) { + log.error("Can't remove entity: " + currentEntities.get(0), eee); + ErrorDialogUI.showError(eee); + } + rootUI.setInfoText(msg); + TreePath treeParentPath = rootUI.getNavigation().getSelectionPath().getParentPath(); + rootUI.setTreeModel(); + rootUI.setTreeSelection(treeParentPath.toString()); + noModif(); + } + + + protected void topiaCreate(){ + String type = currentPanels.get(0).getType(); + + 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, isisContext); + + TopiaEntity entity = dao.create("name", name); + entity.update(); + isisContext.commitTransaction(); + + rootUI.setTreeModel(); + String parentPath = currentNode.getParent().getContextPath() + entity.getTopiaId(); + System.out.println(parentPath); + rootUI.setTreeSelection(parentPath); + + rootUI.setInfoText(_("isisfish.message.creation.finished")); + + } catch (Exception eee) { + log.error("Can't create entity", eee); + showMsgBox(eee); + } + } + + public void topiaSave(){ + try { + noModif(); + for (TopiaEntity t : currentEntities){ + t.update(); + } + isisContext.commitTransaction(); +// rootUI.repaintNode("$root/$ports/" + t.getTopiaId()); + rootUI.repaintNode(currentNode.getContextPath()); + rootUI.setInfoText(_("isisfish.message.save.finished")); + } catch (TopiaException eee) { + log.error("Can't save region", eee); + showMsgBox(eee); + } + } + + /** + * Cancel all modification on entity (rollback), and force reload it and + * refresh all ui component that name match 'type'Tab + * + * @return the roolbacked entity + */ + public void topiaCancel() { + try { + noModif(); + isisContext.rollbackTransaction(); + List<TopiaEntity> canceledEntity = new ArrayList<TopiaEntity>(); + for (TopiaEntity t : currentEntities){ + t = isisContext.findByTopiaId(t.getTopiaId()); + rootUI.repaintNode(currentNode.getContextPath()); + rootUI.setTreeSelection(currentNode.getContextPath()); + canceledEntity.add(t); + } + currentEntities = canceledEntity; + rootUI.setInfoText(_("isisfish.message.cancel.finished")); + } catch (Exception eee) { + log.error("Can't cancel modification in region", eee); + showMsgBox(eee); + } + } + + protected void showMsgBox(Exception eee) { + ErrorDialogUI.showError(eee); + } + protected void setPanelsActifs(){ + if (!currentPanels.isEmpty()){ + for (InputContentUI panel : currentPanels){ + panel.setActif(editable); + } + } + } + protected void refreshAll(){ + for (InputContentUI panel : currentPanels){ + panel.refresh(); + } + } + public void addCurrentEntity(TopiaEntity currentEntity) { + if (currentEntity != null){ + editable = true; + isisContext = currentEntity.getTopiaContext(); + currentEntity.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + topiaChanged(); + } + }); + this.currentEntities.add(currentEntity); + } + else{ + editable = false; + } + } + public void removeAllEntity(){ + currentEntities.clear(); + editable = false; + noModif(); + } + public void addCurrentPanel(InputContentUI currentPanel) { + if (currentPanel != null){ + this.currentPanels.add(currentPanel); + setPanelsActifs(); + } + } + public void removeAllPanels(){ + currentPanels.clear(); + } + + public boolean isEditable() { + return editable; + } + + public JButton getCancelButton() { + return cancelButton; + } + + public JButton getDeleteButton() { + return deleteButton; + } + + public JButton getNewButton() { + return newButton; + } + + public JButton getSaveButton() { + return saveButton; + } + + public TopiaContext getIsisContext() { + return isisContext; + } + + public List<TopiaEntity> getCurrentEntities() { + return currentEntities; + } + + public TopiaEntity getEntity(Class clazz){ + for (TopiaEntity te : currentEntities){ + if (clazz.isInstance(te)){ + return te; + } + } + return null; + } + + public List<InputContentUI> getCurrentPanels() { + return currentPanels; + } + + public String getCurrentOnglet() { + return currentOnglet; + } + + public NavigationTreeNode getCurrentNode() { + return currentNode; + } + + public void setIsisContext(TopiaContext isisContext) { + this.isisContext = isisContext; + } + + public void setEditable(boolean editable) { + this.editable = editable; + } + + public void setCurrentOnglet(String currentOnglet) { + this.currentOnglet = currentOnglet; + } + + public void setCurrentNode(NavigationTreeNode currentNode) { + this.currentNode = currentNode; + } + + void setRootPanel(InputUI inputUI) { + this.rootUI = inputUI; + } +} Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2009-01-02 17:22:04 UTC (rev 1724) @@ -0,0 +1,45 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package fr.ifremer.isisfish.ui.input; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +/** + * + * @author letellier + */ +public class InputTabbedPaneListener implements ChangeListener{ + + @Override + public void stateChanged(ChangeEvent e) { + try { + JTabbedPane pane = (JTabbedPane)e.getSource(); + int cacheSelectedIndex = pane.getSelectedIndex(); + InputContentUI ui = (InputContentUI) pane.getSelectedComponent(); + if (!closeUI(e, ui)) { + pane.setSelectedIndex(cacheSelectedIndex); + } + } catch (Exception ex) { + Logger.getLogger(MetierUI.class.getName()).log(Level.SEVERE, null, ex); + } + } + + protected boolean closeUI(ChangeEvent event, InputContentUI context) throws Exception { + boolean exit = true; + // by default, we says that component was succesfull closed + InputSaveVerifier verif = context.getContextValue(InputSaveVerifier.class); + int responce = verif.checkEdit(); + //boolean exit = checkEdit(event, component); + if (responce == JOptionPane.CANCEL_OPTION){ + exit = false; + } + return exit; + } +} 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -37,163 +37,157 @@ <jaxx.runtime.swing.CardLayout2 id='cardlayout'/> <script><![CDATA[ - import fr.ifremer.isisfish.ui.Common; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import javax.swing.tree.DefaultMutableTreeNode; - import javax.swing.tree.DefaultTreeModel; - import java.util.logging.Level; - import java.util.logging.Logger; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; - import fr.ifremer.isisfish.entities.Cell; - import fr.ifremer.isisfish.entities.Gear; - import fr.ifremer.isisfish.entities.Metier; - import fr.ifremer.isisfish.entities.Port; - import fr.ifremer.isisfish.entities.SetOfVessels; - import fr.ifremer.isisfish.entities.Species; - import fr.ifremer.isisfish.entities.Strategy; - import fr.ifremer.isisfish.entities.TripType; - import fr.ifremer.isisfish.entities.VesselType; - import fr.ifremer.isisfish.entities.Zone; - import fr.ifremer.isisfish.entities.Population; - import javax.swing.tree.TreeNode; - import javax.swing.tree.TreePath; - import org.codelutin.topia.persistence.TopiaEntity; - import org.codelutin.topia.TopiaException; - import fr.ifremer.isisfish.IsisFishEntityEnum; - import jaxx.runtime.JAXXContextEntryDef; - import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; - import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; - import jaxx.runtime.swing.navigation.NavigationUtil; - 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 - public void valueChanged(TreeSelectionEvent e) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); - String name = null; - if (node != null) { - GenericCell selectedValue = (GenericCell) node.getUserObject(); - if (selectedValue.getType() != null) { - name = selectedValue.getType().getSimpleName(); - getContextValue(InputAction.class).setValue(selectedValue.getValue(),selectedValue.getType()); - refreshAll(selectedValue); - } - else { - name = "none"; - } - ((CardLayout) inputPane.getLayout()).show(inputPane, name); - } - } - });*/ - - public InputUI (InputAction action){ - - setContextValue(action); - } - protected void setFieldCurrentRegionModel(){ - fieldCurrentRegion.setModel(getFieldCurrentRegionModel()); - } - protected DefaultComboBoxModel getFieldCurrentRegionModel(){ - return new DefaultComboBoxModel(Common.getRegionItem()); - } - protected void regionChange(){ - final String name = fieldCurrentRegion.getSelectedItem().toString(); - setInfoText(_("isisfish.message.loading.region", name)); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - getContextValue(InputAction.class).loadRegion(name); - setInfoText(_("isisfish.message.load.finished")); - setTreeModel(); - } - }); - } - protected void setTreeModel(){ - String regionName = getContextValue(InputAction.class).getFisheryRegionName(); - FisheryRegion fisheryRegion = getContextValue(InputAction.class).getFisheryRegion(); - if (fisheryRegion != null){ - setContextValue(fisheryRegion); - NavigationTreeModel model = InputNavigationTreeSelectionAdapter.getTreeModel(regionName, fisheryRegion); - navigation.setSelectionModel(navigationSelectionModel); - navigation.setCellRenderer(new NavigationTreeCellRenderer(this)); +import fr.ifremer.isisfish.ui.Common; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import fr.ifremer.isisfish.ui.WelcomePanelUI; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.entities.Cell; +import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Port; +import fr.ifremer.isisfish.entities.SetOfVessels; +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.entities.VesselType; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.entities.Population; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import org.codelutin.topia.persistence.TopiaEntity; +import org.codelutin.topia.TopiaException; +import fr.ifremer.isisfish.IsisFishEntityEnum; +import jaxx.runtime.JAXXContextEntryDef; +import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; +import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; +import jaxx.runtime.swing.navigation.NavigationUtil; +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; +import org.codelutin.topia.TopiaContext; +import fr.ifremer.isisfish.entities.FisheryRegion; +import fr.ifremer.isisfish.datastore.RegionStorage; - setContextValue(model); - navigation.setModel(model); - new InputNavigationTreeSelectionAdapter(this, true); - setTreeSelection("$root"); +protected FisheryRegion getRegion(){ + return getContextValue(FisheryRegion.class); +} +protected InputAction getAction(){ + return getContextValue(InputAction.class); +} +protected InputSaveVerifier getVerifier(){ + return getContextValue(InputSaveVerifier.class); +} +protected RegionStorage getRegionStorage(){ + return getContextValue(RegionStorage.class); +} +protected void setFieldCurrentRegionModel(){ + fieldCurrentRegion.setModel(getFieldCurrentRegionModel()); +} +protected DefaultComboBoxModel getFieldCurrentRegionModel(){ + return new DefaultComboBoxModel(Common.getRegionItem()); +} +protected void regionChange(){ + final String name = fieldCurrentRegion.getSelectedItem().toString(); + setInfoText(_("isisfish.message.loading.region", name)); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + loadRegion(name); + getVerifier().setIsisContext(getContextValue(TopiaContext.class)); + setInfoText(_("isisfish.message.load.finished")); + setTreeModel(); } - } + }); +} +protected void loadRegion(String name){ + getAction().loadRegion(this, name); +} +protected void setTreeModel(){ + String regionName = getRegion().getName(); + if (getRegion() != null){ + setContextValue(getRegion()); + NavigationTreeModel model = InputNavigationTreeSelectionAdapter.getTreeModel(regionName, getRegion()); + navigation.setSelectionModel(navigationSelectionModel); + navigation.setCellRenderer(new NavigationTreeCellRenderer(this)); - public void repaintNode(String path){ - NavigationTreeModel model = getContextValue(NavigationTreeModel.class); - NavigationTreeNode currentNode = model.findNode(path); - model.nodeChanged(currentNode); + setContextValue(model); + navigation.setModel(model); + new InputNavigationTreeSelectionAdapter(this, true); + setTreeSelection("$root"); } - public void setTreeSelection(String path){ - NavigationTreeNode node = NavigationUtil.findNode(this, null, path); - TreePath pathToRoot = new TreePath(getContextValue(NavigationTreeModel.class).getPathToRoot(node)); - navigation.setSelectionPath(pathToRoot); - navigation.scrollPathToVisible(pathToRoot); - } - protected void setInfoText(String s){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(s); - } - protected void newRegion(){ - String name = fieldNewRegion.getText(); - setInfoText(_("isisfish.message.creating.region", name)); - getContextValue(InputAction.class).newRegion(name); - setInfoText(_("isisfish.message.creating.region", name)); - setFieldCurrentRegionModel(); - fieldCurrentRegion.setSelectedItem(name); - JButtonNewRegion.setEnabled(false); - setInfoText(_("isisfish.message.creation.finished")); - } - protected void newChanged(){ - JButtonNewRegion.setEnabled(true); - } - protected void importRegion(){ - setInfoText(_("isisfish.message.import.zip" + getContextValue(InputAction.class).importRegion())); - setFieldCurrentRegionModel(); - setInfoText(_("isisfish.message.import.finished")); - } - protected void importRegionAndRename(){ - setInfoText(_("isisfish.message.import.zip" + getContextValue(InputAction.class).importRegionAndRename())); - setFieldCurrentRegionModel(); - setInfoText(_("isisfish.message.import.finished")); - } - protected void importV2Region(){ - setInfoText(_("isisfish.message.import.xml.v2.file") + getContextValue(InputAction.class).importV2Region()); - setFieldCurrentRegionModel(); - setInfoText(_("isisfish.message.import.finished")); - } - protected void importRegionFromSimulation(){ - setInfoText(_("isisfish.message.import", getContextValue(InputAction.class).importRegionFromSimulation())); - } - protected void exportRegion(){ - setInfoText(_("isisfish.message.export.zip", getContextValue(InputAction.class).exportRegion())); - setFieldCurrentRegionModel(); - setInfoText(_("isisfish.message.export.done")); - } - protected void copyRegion(){ - setInfoText(_("isisfish.message.copy.region", getContextValue(InputAction.class).copyRegion())); - setFieldCurrentRegionModel(); - setInfoText(_("isisfish.message.copy.finished")); - } - protected void removeRegion(){ - setInfoText(_("isisfish.message.removing.region" + getContextValue(InputAction.class).getRegionStorage().getName())); - setFieldCurrentRegionModel(); - setInfoText(getContextValue(InputAction.class).removeRegion(false)); - } - protected void commitRegionInCVS(){ - setInfoText(_("isisfish.message.commiting.region" + getContextValue(InputAction.class).getRegionStorage().getName())); - setInfoText(getContextValue(InputAction.class).commitRegionInCVS()); - } +} + +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); + navigation.scrollPathToVisible(pathToRoot); +} +protected void setInfoText(String s){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(s); +} +protected void newRegion(){ + String name = fieldNewRegion.getText(); + setInfoText(_("isisfish.message.creating.region", name)); + getContextValue(InputAction.class).newRegion(name); + setInfoText(_("isisfish.message.creating.region", name)); + setFieldCurrentRegionModel(); + fieldCurrentRegion.setSelectedItem(name); + JButtonNewRegion.setEnabled(false); + setInfoText(_("isisfish.message.creation.finished")); +} +protected void newChanged(){ + JButtonNewRegion.setEnabled(true); +} +protected void importRegion(){ + setInfoText(_("isisfish.message.import.zip" + getContextValue(InputAction.class).importRegion())); + setFieldCurrentRegionModel(); + setInfoText(_("isisfish.message.import.finished")); +} +protected void importRegionAndRename(){ + setInfoText(_("isisfish.message.import.zip" + getContextValue(InputAction.class).importRegionAndRename())); + setFieldCurrentRegionModel(); + setInfoText(_("isisfish.message.import.finished")); +} +protected void importV2Region(){ + setInfoText(_("isisfish.message.import.xml.v2.file") + getContextValue(InputAction.class).importV2Region()); + setFieldCurrentRegionModel(); + setInfoText(_("isisfish.message.import.finished")); +} +protected void importRegionFromSimulation(){ + setInfoText(_("isisfish.message.import", getContextValue(InputAction.class).importRegionFromSimulation())); +} +protected void exportRegion(){ + setInfoText(_("isisfish.message.export.zip", getContextValue(InputAction.class).exportRegion(getRegionStorage()))); + setFieldCurrentRegionModel(); + setInfoText(_("isisfish.message.export.done")); +} +protected void copyRegion(){ + setInfoText(_("isisfish.message.copy.region", getContextValue(InputAction.class).copyRegion(getRegionStorage()))); + setFieldCurrentRegionModel(); + setInfoText(_("isisfish.message.copy.finished")); +} +protected void removeRegion(){ + setInfoText(_("isisfish.message.removing.region" + getRegionStorage().getName())); + setFieldCurrentRegionModel(); + setInfoText(getContextValue(InputAction.class).removeRegion(getRegionStorage(), false)); +} +protected void commitRegionInCVS(){ + setInfoText(_("isisfish.message.commiting.region" + getRegionStorage().getName())); + setInfoText(getContextValue(InputAction.class).commitRegionInCVS(getRegionStorage())); +} ]]> </script> <JMenuBar id="menu" constraints='BorderLayout.NORTH'> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,12 +31,11 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.MetierImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> <script><![CDATA[ import com.l2fprod.common.swing.renderer.BooleanCellRenderer; @@ -45,6 +44,7 @@ import fr.ifremer.isisfish.entities.Equation; import fr.ifremer.isisfish.entities.Formule; import fr.ifremer.isisfish.entities.Metier; + import fr.ifremer.isisfish.entities.MetierImpl; import fr.ifremer.isisfish.entities.MetierSeasonInfo; import fr.ifremer.isisfish.entities.TargetSpecies; import fr.ifremer.isisfish.ui.widget.editor.GenericCell; @@ -53,14 +53,13 @@ import org.codelutin.topia.persistence.TopiaEntity; import javax.swing.table.DefaultTableModel; import fr.ifremer.isisfish.entities.Species; + import org.codelutin.topia.TopiaContext; import javax.swing.table.TableCellEditor; - public MetierSeasonInfoSpeciesUI (InputAction action){ - - setContextValue(action); - } public void refresh() { - if (getContextValue(InputAction.class).getMetier() != null){ + Metier metier = (Metier)getVerifier().getEntity(Metier.class); + setBean((MetierImpl) metier); + if (getBean() != null){ if (fieldMetierSeasonInfo.getSelectedIndex() <= 0){ setSeasonModel(); } @@ -88,9 +87,8 @@ } } protected void setSeasonModel(){ - Metier metier = getContextValue(InputAction.class).getMetier(); DefaultComboBoxModel seasonModel = new DefaultComboBoxModel(); - java.util.List<MetierSeasonInfo> metierSeasonInfo = metier.getMetierSeasonInfo(); + java.util.List<MetierSeasonInfo> metierSeasonInfo = getBean().getMetierSeasonInfo(); if (metierSeasonInfo != null){ seasonModel.addElement(new GenericCell(" ", null, null)); for (MetierSeasonInfo m : metierSeasonInfo){ @@ -101,7 +99,7 @@ } protected void setTargetSpeciesModel(){ DefaultComboBoxModel fieldTargetSpeciesModel = new DefaultComboBoxModel(); - java.util.List<Species> species = getContextValue(InputAction.class).getFisheryRegion().getSpecies(); + java.util.List<Species> species = getRegion().getSpecies(); if (species != null){ fieldTargetSpeciesModel.addElement(new GenericCell(" ", null, null)); for (Species s : species){ @@ -111,7 +109,7 @@ fieldTargetSpecies.setModel(fieldTargetSpeciesModel); } protected void setTargetFactorEquationModel(){ - java.util.List<Formule> formules = fr.ifremer.isisfish.datastore.FormuleStorage.getFormules(getContextValue(InputAction.class).getIsisContext(), "TargetFactor"); + java.util.List<Formule> formules = fr.ifremer.isisfish.datastore.FormuleStorage.getFormules(getContextValue(TopiaContext.class), "TargetFactor"); DefaultComboBoxModel fieldTargetFactorEquationModel = new DefaultComboBoxModel(); if (formules != null){ fieldTargetFactorEquationModel.addElement(new GenericCell(" ", null, null)); @@ -169,150 +167,129 @@ } } } - protected void saveAsModel(){ - getContextValue(InputAction.class).saveAsModel("Metier", "Java", fieldTargetFactorScript.getText()); - setInfoText(_("isisfish.message.saveModel.finished")); - } protected void add(){ Object season = ((GenericCell)fieldMetierSeasonInfo.getSelectedItem()).getValue(); Object species = ((GenericCell)fieldTargetSpecies.getSelectedItem()).getValue(); if (season != null && species != null){ getContextValue(InputAction.class).addTargetSpecies( + getBean(), (MetierSeasonInfo)season, (Species)species, fieldTargetFactorScript.getText(), fieldPrimaryCatch.isSelected()); - valueChanged(true); refresh(); } } protected void remove(){ - // getContextValue(InputAction.class).removeSelectivity((Selectivity) getContextValue(InputAction.class).getGear().getPopulationSelectivity((Population) selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0))); refresh(); } - 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")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void valueChanged(boolean b){ - getParentContainer(MetierUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } protected void openEditor(){ - getContextValue(InputAction.class).openEditor("TargetFactor","new",fr.ifremer.isisfish.equation.TargetSpeciesTargetFactorEquation.class, fieldTargetFactorScript.getText(), fieldTargetFactorScript); + getContextValue(InputAction.class).openEditor("TargetSpeciesTargetFactorEquation","new",fr.ifremer.isisfish.equation.TargetSpeciesTargetFactorEquation.class, fieldTargetFactorScript.getText(), fieldTargetFactorScript); } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); + protected void saveAsModel(){ + getContextValue(InputAction.class).saveAsModel("TargetSpeciesTargetFactorEquation", "Java", fieldTargetFactorScript.getText()); + setTargetFactorEquationModel(); + setInfoText(_("isisfish.message.saveModel.finished")); } protected void metierSeasonChanged(){ setTableTargetSpeciesModel(); } ]]></script> - <row> - <cell fill='both' weightx='1.0' weighty='0.5'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason"/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierSeasonInfo" onActionPerformed='metierSeasonChanged()'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoSpecies.selectSpecies"/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldTargetSpecies"/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoSpecies.targetFactor"/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldTargetFactorEquation" onActionPerformed='equationChanged()'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal'> - <JButton id='saveModel' text="isisfish.common.saveModel" onActionPerformed='saveAsModel()'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton id='openEditor' text="isisfish.common.openEditor" onActionPerformed='openEditor()'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <org.codelutin.widget.editor.Editor id='fieldTargetFactorScript' askIfNotSaved="false"/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JPanel/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldPrimaryCatch" text="isisfish.metierSeasonInfoSpecies.mainSpecies"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='0.5'> - <Table> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonMetierSpeciesAddTargetSpecies" text="isisfish.common.add" onActionPerformed='add()'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTable id="tableTargetSpecies"/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonMetierSpeciesRemoveTargetSpecies" text="isisfish.common.remove" onActionPerformed='remove()'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='0.5'> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason"/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldMetierSeasonInfo" onActionPerformed='metierSeasonChanged()'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoSpecies.selectSpecies"/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldTargetSpecies"/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoSpecies.targetFactor"/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldTargetFactorEquation" onActionPerformed='equationChanged()'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal'> + <JButton id='saveModel' text="isisfish.common.saveModel" onActionPerformed='saveAsModel()'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton id='openEditor' text="isisfish.common.openEditor" onActionPerformed='openEditor()'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <org.codelutin.widget.editor.Editor id='fieldTargetFactorScript' askIfNotSaved="false"/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JPanel/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JCheckBox id="fieldPrimaryCatch" text="isisfish.metierSeasonInfoSpecies.mainSpecies"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='0.5'> + <Table> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="buttonMetierSpeciesAddTargetSpecies" text="isisfish.common.add" onActionPerformed='add()'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JTable id="tableTargetSpecies"/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="buttonMetierSpeciesRemoveTargetSpecies" text="isisfish.common.remove" onActionPerformed='remove()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,13 +31,11 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.MetierImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ import fr.ifremer.isisfish.entities.Season; import fr.ifremer.isisfish.types.Month; @@ -47,18 +45,47 @@ import fr.ifremer.isisfish.ui.widget.IntervalPanel; import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.entities.Metier; + import fr.ifremer.isisfish.entities.MetierImpl; import org.codelutin.topia.persistence.TopiaEntity; import fr.ifremer.isisfish.ui.WelcomePanelUI; protected boolean seasonInit = true; protected IntervalPanel ip = new IntervalPanel(); displayMetierSeason.add(ip, BorderLayout.CENTER); - public MetierSeasonInfoZoneUI (InputAction action){ - - setContextValue(action); - } + ip.addPropertyChangeListener("first", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Object selected = fieldMetierSeasonChoice.getSelectedItem(); + if (selected != null){ + Object value = ((GenericCell)selected).getValue(); + // Data extraction + Season season = (Season) value; + Month first = season.getFirstMonth(); + first.setMonthNumber(ip.getModel().getFirst()); + season.setFirstMonth(first); + } + } + }); + + ip.addPropertyChangeListener("last", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Object selected = fieldMetierSeasonChoice.getSelectedItem(); + if (selected != null){ + Object value = ((GenericCell)selected).getValue(); + // Data extraction + Season season = (Season) value; + Month last = season.getLastMonth(); + last.setMonthNumber(ip.getModel().getLast()); + season.setLastMonth(last); + } + } + }); public void refresh() { - Metier metier = getContextValue(InputAction.class).getMetier(); + Metier metier = (Metier)getVerifier().getEntity(Metier.class); + setBean((MetierImpl) metier); if (metier != null){ if (seasonInit){ DefaultComboBoxModel seasonModel = new DefaultComboBoxModel(); @@ -113,7 +140,7 @@ DefaultListModel zonesModel = new DefaultListModel(); - java.util.List<Zone> metierZone = getContextValue(InputAction.class).getFisheryRegion().getZone(); + java.util.List<Zone> metierZone = getRegion().getZone(); if (metierZone != null){ for (Zone z : metierZone ){ zonesModel.addElement(z); @@ -144,7 +171,7 @@ ip.setModel(interval); fieldMetierSeasonZoneComment.setText(""); DefaultListModel zonesModel = new DefaultListModel(); - java.util.List<Zone> metierZone = getContextValue(InputAction.class).getFisheryRegion().getZone(); + java.util.List<Zone> metierZone = getRegion().getZone(); if (metierZone != null){ for (Zone z : metierZone ){ zonesModel.addElement(z); @@ -155,45 +182,6 @@ } } } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Metier"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - 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")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers"); - valueChanged(false); - seasonInit = false; - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(MetierUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } protected void zonesChanged(){ Object selected = fieldMetierSeasonChoice.getSelectedItem(); if (selected != null){ @@ -206,7 +194,6 @@ } } } - valueChanged(true); } protected void commentChanged(){ Object selected = fieldMetierSeasonChoice.getSelectedItem(); @@ -218,7 +205,6 @@ season.setSeasonZoneComment(fieldMetierSeasonZoneComment.getText()); } } - valueChanged(true); } public void setSeasonInit(boolean b){ seasonInit = b; @@ -228,68 +214,70 @@ refresh(); } ]]></script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierSeasonChoice" onActionPerformed='metierSeasonChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoZone.season" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JPanel id='displayMetierSeason' layout='{new BorderLayout()}' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.common.zone" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.7'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="metierZones" onValueChanged='zonesChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoZone.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.3'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTextArea id="fieldMetierSeasonZoneComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldMetierSeasonChoice" onActionPerformed='metierSeasonChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoZone.season" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JPanel id='displayMetierSeason' layout='{new BorderLayout()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.common.zone" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.7'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JList id="metierZones" onValueChanged='zonesChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metierSeasonInfoZone.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.3'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JTextArea id="fieldMetierSeasonZoneComment" onKeyTyped='commentChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,32 +31,28 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.MetierImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ import fr.ifremer.isisfish.entities.Gear; import fr.ifremer.isisfish.entities.TripType; import fr.ifremer.isisfish.entities.Metier; + import fr.ifremer.isisfish.entities.MetierImpl; import fr.ifremer.isisfish.ui.WelcomePanelUI; import org.codelutin.topia.persistence.TopiaEntity; import org.codelutin.topia.TopiaException; import java.util.logging.Level; import java.util.logging.Logger; - - public MetierTabUI (InputAction action){ - - setContextValue(action); - } + public void refresh() { try { - Metier metier = getContextValue(InputAction.class).getMetier(); - DefaultComboBoxModel model = new DefaultComboBoxModel(getContextValue(InputAction.class).getFisheryRegion().getGear().toArray()); + Metier metier = (Metier)getVerifier().getEntity(Metier.class); + setBean((MetierImpl) metier); + DefaultComboBoxModel model = new DefaultComboBoxModel(getRegion().getGear().toArray()); fieldMetierGear.setModel(model); if (metier != null){ fieldMetierName.setText(metier.getName()); @@ -73,117 +69,80 @@ } } protected void nameChanged(){ - getContextValue(InputAction.class).getMetier().setName(fieldMetierName.getText()); - valueChanged(true); + getBean().setName(fieldMetierName.getText()); } protected void gearChanged(){ - getContextValue(InputAction.class).getMetier().setGear((Gear)fieldMetierGear.getSelectedItem()); - valueChanged(true); + getBean().setGear((Gear)fieldMetierGear.getSelectedItem()); } protected void paramChanged(){ - getContextValue(InputAction.class).getMetier().setGearParameterValue(fieldMetierParam.getText()); - valueChanged(true); + getBean().setGearParameterValue(fieldMetierParam.getText()); } protected void commentChanged(){ - getContextValue(InputAction.class).getMetier().setComment(fieldMetierComment.getText()); - valueChanged(true); + getBean().setComment(fieldMetierComment.getText()); } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Metier"); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers/"+topia.getTopiaId()); - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$metiers/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$metiers"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(MetierUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } ]]></script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metier.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldMetierName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.common.gear" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierGear" onActionPerformed='gearChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metier.rangeValues" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldMetierParam" onKeyTyped='valueChanged(true)' onFocusLost='paramChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metier.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTextArea id="fieldMetierComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='bady'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metier.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldMetierName" onKeyTyped='nameChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.common.gear" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldMetierGear" onActionPerformed='gearChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metier.rangeValues" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldMetierParam" onKeyTyped='paramChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.metier.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JTextArea id="fieldMetierComment" onKeyTyped='commentChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='remove' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -34,22 +34,21 @@ <!-- + Metier +--> -<JPanel layout='{new BorderLayout()}' implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.MetierImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ import fr.ifremer.isisfish.entities.TripType; + import fr.ifremer.isisfish.entities.MetierImpl; + import fr.ifremer.isisfish.entities.Metier; init(); - public MetierUI (InputAction action){ - - setContextValue(action); - } public void refresh() { + setBean(null); + Metier metier = (Metier)getVerifier().getEntity(Metier.class); + setBean((MetierImpl) metier); metierTabUI.refresh(); metierSeasonSpeciesUI.refresh(); @@ -57,6 +56,7 @@ metierSeasonInfoUI.refresh(); } protected void init(){ + metierTab.addChangeListener(new InputTabbedPaneListener()); this.addPropertyChangeListener("actif", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -78,10 +78,12 @@ getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes"); } ]]></script> - <JTabbedPane id="MetierTab" name="Metier" constraints='BorderLayout.CENTER'> - <tab title='{_("isisfish.metier.title")}'><MetierTabUI id="metierTabUI" constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><MetierSeasonInfoZoneUI id="metierSeasonInfoUI" constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><MetierSeasonInfoSpeciesUI id="metierSeasonSpeciesUI" constructorParams='getContextValue(InputAction.class)'/></tab> - </JTabbedPane> - <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueTripTypes" onActionPerformed='goToTripType()'/> -</JPanel> \ No newline at end of file + <JPanel id='body' layout='{new BorderLayout()}'> + <JTabbedPane id="metierTab" name="Metier" constraints='BorderLayout.CENTER' > + <tab title='{_("isisfish.metier.title")}'><MetierTabUI id="metierTabUI" constructorParams='this'/></tab> + <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><MetierSeasonInfoZoneUI id="metierSeasonInfoUI" constructorParams='this'/></tab> + <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><MetierSeasonInfoSpeciesUI id="metierSeasonSpeciesUI" constructorParams='this'/></tab> + </JTabbedPane> + <!--JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueTripTypes" onActionPerformed='goToTripType()'/--> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,34 +31,45 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Equation; - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.entities.Species; - import fr.ifremer.isisfish.entities.PopulationGroup; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Population; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import javax.swing.table.DefaultTableModel; - import java.util.logging.Level; - import java.util.logging.Logger; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.table.DefaultTableModel; - protected Population pop = null; - public PopulationBasicsUI (InputAction action){ - - setContextValue(action); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); + fieldPopulationBasicsGeographicID.setText(""); + fieldPopulationBasicsNbClasses.setText(""); + fieldPopulationBasicsComment.setText(""); + fieldPopulationBasicsMatureClass.setSelectedItem(null); + } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } +}); public void refresh(){ - jaxx.runtime.Util.assignment(pop = getContextValue(InputAction.class).getPopulation(), "pop", fr.ifremer.isisfish.ui.input.PopulationBasicsUI.this); + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); try { editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); editorReverse.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); @@ -67,150 +78,44 @@ } setFieldPopulationBasicsGrowthModel(); setfieldPopulationBasicsGrowthReverseModel(); - if (pop != null){ - fieldPopulationBasicsName.setText(pop.getName()); - fieldPopulationBasicsGeographicID.setText(pop.getGeographicId()); - fieldPopulationBasicsNbClasses.setText(pop.sizePopulationGroup() + ""); - setFieldPopulationBasicsMatureClassModel(); - fieldPopulationBasicsPlusGroup.setSelected(pop.getPlusGroup()); - fieldPopulationBasicsComment.setText(pop.getComment()); - growthReverseChanged(); - basicsGrowthChanged(); + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationBasicsGrowthReverse,getAction().getFormules(getBean().getTopiaContext(), "GrowthReverse"), null); + if (getBean() != null){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationBasicsMatureClass,getBean().getPopulationGroup(), getBean().getMaturityGroup()); +// growthReverseChanged(); +// basicsGrowthChanged(); setTableAgeLengthModel(); } - else{ -// pop = (Population) getContextValue(InputAction.class).create("Population"); - fieldPopulationBasicsName.setText(""); - fieldPopulationBasicsGeographicID.setText(""); - fieldPopulationBasicsNbClasses.setText(""); - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationBasicsMatureClass.setModel(model); - fieldPopulationBasicsComment.setText(""); - growthReverseChanged(); - basicsGrowthChanged(); - DefaultTableModel tableModel = new DefaultTableModel(); - tableAgeLength.setModel(tableModel); - - } } - protected void setFieldPopulationBasicsMatureClassModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - PopulationGroup selected = null; - model.addElement(null); - if (pop.getPopulationGroup() != null){ - for (PopulationGroup p : pop.getPopulationGroup()){ - model.addElement(p); - if (pop.getMaturityGroup() == p){ - selected = p; - } - } - } - fieldPopulationBasicsMatureClass.setModel(model); - if (selected != null){ - fieldPopulationBasicsMatureClass.setSelectedItem(selected); - } - } protected void setFieldPopulationBasicsGrowthModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - GenericCell selected = null; - model.addElement(new GenericCell(" ", null, null)); - for (Formule f : getContextValue(InputAction.class).getFormules("Growth")){ - GenericCell c = new GenericCell(f.getName(), f, Formule.class); - model.addElement(c); - if (pop != null){ - if (f.equals((Formule)pop.getGrowth())){ - selected = c; - } - } - } - fieldPopulationBasicsGrowth.setModel(model); - if (selected != null){ - fieldPopulationBasicsGrowth.setSelectedItem(selected); - basicsGrowthChanged(); - } + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationBasicsGrowth,getAction().getFormules(getBean().getTopiaContext(), "Growth"), null); } protected void setfieldPopulationBasicsGrowthReverseModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - model.addElement(new GenericCell(" ", null, null)); - GenericCell selected = null; - java.util.List<Formule> formules = getContextValue(InputAction.class).getFormules("GrowthReverse"); - if (formules != null){ - for (Formule f : formules){ - GenericCell c = new GenericCell(f.getName(), f, Formule.class); - model.addElement(c); - if (pop != null){ - if (((Equation)f).equals(pop.getGrowthReverse())){ - selected = c; - } - } - } - } - fieldPopulationBasicsGrowthReverse.setModel(model); - if (selected != null){ - fieldPopulationBasicsGrowthReverse.setSelectedItem(selected); - growthReverseChanged(); - } + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationBasicsGrowthReverse,getAction().getFormules(getBean().getTopiaContext(), "GrowthReverse"), null); } - protected Equation getEquation(){ - Equation result = null; - Object o = fieldPopulationBasicsGrowth.getSelectedItem(); - if (o != null){ - GenericCell c = (GenericCell)o; - if (c.getValue() != null){ - result = (Equation)c.getValue(); - } - } - return result; - } - protected Equation getReverseEquation(){ - Equation result = null; - Object o = fieldPopulationBasicsGrowthReverse.getSelectedItem(); - if (o != null){ - GenericCell c = (GenericCell)o; - if (c.getValue() != null){ - result = (Equation)c.getValue(); - } - } - return result; - } - protected void nameChanged(){ - pop.setName(fieldPopulationBasicsName.getText()); - } - protected void geographicChanged(){ - if (pop != null){ - pop.setGeographicId(fieldPopulationBasicsGeographicID.getText()); - } - } protected void createClasses(){ - if (pop != null){ - JFrame wizardFrame = new JFrame(); - wizardFrame.setLayout(new BorderLayout()); - WizardGroupCreationUI wizard = new WizardGroupCreationUI(getContextValue(InputAction.class), this); - wizardFrame.add(wizard, BorderLayout.CENTER); - wizardFrame.setTitle(_("isisfish.wizardGroupCreation.title")); - wizardFrame.setVisible(true); - wizardFrame.pack(); - wizard.setAgeType(pop.getSpecies().getAgeGroupType()); - if (wizard.isAgeType()) { - wizard.setCard("singleGroupAge"); - } else { - wizard.setCard("beginGroupLength"); - } - valueChanged(true); - refresh(); + JFrame wizardFrame = new JFrame(); + wizardFrame.setLayout(new BorderLayout()); + WizardGroupCreationUI wizard = new WizardGroupCreationUI(getContextValue(InputAction.class), this); + wizardFrame.add(wizard, BorderLayout.CENTER); + wizardFrame.setTitle(_("isisfish.wizardGroupCreation.title")); + wizardFrame.setVisible(true); + wizardFrame.pack(); + wizard.setAgeType(getBean().getSpecies().getAgeGroupType()); + if (wizard.isAgeType()) { + wizard.setCard("singleGroupAge"); + } else { + wizard.setCard("beginGroupLength"); } + refresh(); } protected void matureClassChanged(){ Object selected = fieldPopulationBasicsMatureClass.getSelectedItem(); if (selected != null){ - pop.setMaturityGroup((PopulationGroup) selected); + getBean().setMaturityGroup((PopulationGroup) selected); } } - protected void plusGroupChanged(){ - pop.setPlusGroup(fieldPopulationBasicsPlusGroup.isSelected()); - } protected void basicsGrowthChanged(){ - Equation f = getEquation(); + Equation f = (Equation) fieldPopulationBasicsGrowth.getSelectedItem(); if (f != null){ editor.setText(f.getContent()); } @@ -219,45 +124,26 @@ getContextValue(InputAction.class).saveAsModel("PopulationGrowth", "Java", editor.getText()); setFieldPopulationBasicsGrowthModel(); setInfoText(_("isisfish.message.saveModel.finished")); -// Equation e = getEquation(); -// if (e != null){ -// getContextValue(InputAction.class).saveAsModel(e.getCategory(), e.getLanguage(), e.getContent()); -// } } protected void openGrowthEditor(){ getContextValue(InputAction.class).openEditor("PopulationGrowth","new",fr.ifremer.isisfish.equation.PopulationGrowth.class, editor.getText(), editor); -// Equation e = getEquation(); -// if (e != null){ -// getContextValue(InputAction.class).openEditor(e.getCategory(), e.getName(), fr.ifremer.isisfish.equation.PopulationGrowth.class, e.getContent(), editor); -// } } protected void growthReverseChanged(){ - Equation f = getReverseEquation(); + Equation f = (Equation)fieldPopulationBasicsGrowthReverse.getSelectedItem(); if (f != null){ editorReverse.setText(f.getContent()); } } protected void saveGrowthReverseModel(){ - getContextValue(InputAction.class).saveAsModel("PopulationGrowth", "Java", editor.getText()); + getContextValue(InputAction.class).saveAsModel("PopulationGrowthReverse", "Java", editor.getText()); setfieldPopulationBasicsGrowthReverseModel(); setInfoText(_("isisfish.message.saveModel.finished")); -// Equation e = getEquation(); -// if (e != null){ -// getContextValue(InputAction.class).saveAsModel(e.getCategory(), e.getLanguage(), e.getContent()); -// } } protected void openGrowthReverseEditor(){ - getContextValue(InputAction.class).openEditor("PopulationGrowth","new",fr.ifremer.isisfish.equation.PopulationGrowthReverse.class, editorReverse.getText(), editorReverse); -// Equation e = getEquation(); -// if (e != null){ -// getContextValue(InputAction.class).openEditor(e.getCategory(), e.getName(), fr.ifremer.isisfish.equation.PopulationGrowthReverse.class, e.getContent(), editorReverse); -// } + getContextValue(InputAction.class).openEditor("PopulationGrowthReverse","new",fr.ifremer.isisfish.equation.PopulationGrowthReverse.class, editorReverse.getText(), editorReverse); } - protected void commentChanged(){ - pop.setComment(fieldPopulationBasicsComment.getText()); - } protected void setTableAgeLengthModel(){ - java.util.List<PopulationGroup> popGroup = pop.getPopulationGroup(); + java.util.List<PopulationGroup> popGroup = getBean().getPopulationGroup(); if (popGroup != null){ DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1); model.setValueAt("Age", 0, 0); @@ -271,208 +157,169 @@ tableAgeLength.setModel(model); } } - protected void create(){ - Species species = getContextValue(InputAction.class).getSpecies(); - TopiaEntity topia = getContextValue(InputAction.class).createPopulation(); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+ species.getTopiaId() +"/$populations/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/" + species.getTopiaId() + "/$populations"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.name" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationBasicsName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.geographicID" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationBasicsGeographicID" onKeyTyped='valueChanged(true)' onFocusLost='geographicChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.numberGroup" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationBasicsNbClasses" editable="false" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id="buttonPopulationBasicsCreateClasses" text="isisfish.populationBasics.recreateClasses" onActionPerformed='createClasses()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.maturityGroup" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationBasicsMatureClass" onActionPerformed='matureClassChanged()' enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup" onActionPerformed='plusGroupChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='3' fill='both' weightx='1.0'> - <JTable id='tableAgeLength' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.growth" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JComboBox id="fieldPopulationBasicsGrowth" onActionPerformed='basicsGrowthChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveGrowthModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openGrowthEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell columns='2' fill='both' weightx='1.0' weighty='0.4'> - <JScrollPane> - <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationBasics.growthReverse" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JComboBox id="fieldPopulationBasicsGrowthReverse" onActionPerformed='growthReverseChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveGrowthReverseModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openGrowthReverseEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell columns='2' fill='both' weightx='1.0' weighty='0.4'> - <JScrollPane> - <org.codelutin.widget.editor.Editor id='editorReverse' askIfNotSaved="false" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.population.comments" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='both' weightx='1.0' weighty='0.2'> - <JScrollPane> - <JTextArea id="fieldPopulationBasicsComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> - </cell> - </row> -</Table> - + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.name" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationBasicsName" text='getBean().getName()' onKeyTyped='getBean().setName(fieldPopulationBasicsName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.geographicID" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationBasicsGeographicID" text='getBean().getGeographicId()' onKeyTyped='getBean().setGeographicId(fieldPopulationBasicsGeographicID.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.numberGroup" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldPopulationBasicsNbClasses" text='getBean().sizePopulationGroup()' editable="false" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id="buttonPopulationBasicsCreateClasses" text="isisfish.populationBasics.recreateClasses" onActionPerformed='createClasses()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.maturityGroup" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationBasicsMatureClass" onActionPerformed='matureClassChanged()' enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup" selected='{getBean().getPlusGroup()}' onActionPerformed='getBean().setPlusGroup(fieldPopulationBasicsPlusGroup.isSelected())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='3' fill='both' weightx='1.0'> + <JTable id='tableAgeLength' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.growth" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JComboBox id="fieldPopulationBasicsGrowth" onActionPerformed='basicsGrowthChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveGrowthModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openGrowthEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell columns='2' fill='both' weightx='1.0' weighty='0.4'> + <JScrollPane> + <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationBasics.growthReverse" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JComboBox id="fieldPopulationBasicsGrowthReverse" onActionPerformed='growthReverseChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveGrowthReverseModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openGrowthReverseEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell columns='2' fill='both' weightx='1.0' weighty='0.4'> + <JScrollPane> + <org.codelutin.widget.editor.Editor id='editorReverse' askIfNotSaved="false" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.population.comments" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='both' weightx='1.0' weighty='0.2'> + <JScrollPane> + <JTextArea id="fieldPopulationBasicsComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldPopulationBasicsComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationCapturabilityUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,107 +31,77 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Population; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; - import org.codelutin.math.matrix.gui.MatrixPanelListener; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import org.codelutin.math.matrix.gui.MatrixPanelListener; - protected Population pop = null; - public PopulationCapturabilityUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - fieldPopulationCapturabilityComment.setText(pop.getCapturabilityComment()); - if (pop.getCapturability() != null){ - fieldPopulationCapturability.setMatrix(pop.getCapturability().copy()); - } - fieldPopulationCapturability.addMatrixListener(new MatrixPanelListener() { - - @Override - public void matrixChanged(MatrixPanelEvent arg0) { - pop.setCapturability(fieldPopulationCapturability.getMatrix()); - valueChanged(true); - } - }); - valueChanged(false); - } - else{ +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); fieldPopulationCapturabilityComment.setText(""); fieldPopulationCapturability.setMatrix(null); - valueChanged(false); } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } - protected void commentChanged(){ - pop.setCapturabilityComment(fieldPopulationCapturabilityComment.getText()); - valueChanged(true); - } - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +}); +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + fieldPopulationCapturability.addMatrixListener(new MatrixPanelListener() { + @Override + public void matrixChanged(MatrixPanelEvent arg0) { + getBean().setCapturability(fieldPopulationCapturability.getMatrix()); + } + }); +} ]]> </script> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' anchor='east'> - <JLabel text="isisfish.populationCapturability.selectCoefficient" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationCapturability' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' anchor='east'> - <JLabel text="isisfish.populationCapturability.comments" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTextArea id="fieldPopulationCapturabilityComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> -</Table> - + <Table id='body'> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' anchor='east'> + <JLabel text="isisfish.populationCapturability.selectCoefficient" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationCapturability' matrix='{getBean().getCapturability().copy()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' anchor='east'> + <JLabel text="isisfish.populationCapturability.comments" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTextArea id="fieldPopulationCapturabilityComment" text='getBean().getCapturabilityComment()' onKeyTyped='getBean().setCapturabilityComment(fieldPopulationCapturabilityComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationEquationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,102 +30,57 @@ * by : $Author: sletellier $ */ --> -<Table implements='InputContent'> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <Boolean id='changed' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; - protected Population pop = null; - init(); - public PopulationEquationUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - naturalDeathRate.init(_("isisfish.populationEquation.naturalDeathRate"), (Formule)pop.getNaturalDeathRate(), "NaturalDeathRate", fr.ifremer.isisfish.equation.PopulationNaturalDeathRate.class); - meanWeight.init(_("isisfish.populationEquation.meanWeight"), (Formule)pop.getMeanWeight(), "MeanWeight", fr.ifremer.isisfish.equation.PopulationMeanWeight.class); - price.init(_("isisfish.populationEquation.price"), (Formule)pop.getPrice(), "Price", fr.ifremer.isisfish.equation.PopulationPrice.class); - naturalDeathRate.refresh(); - meanWeight.refresh(); - price.refresh(); - } - } - - 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(); - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +setType("Population"); +setButtonTitle(""); +setNextPath(null); +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + naturalDeathRate.init(_("isisfish.populationEquation.naturalDeathRate"), (Formule)getBean().getNaturalDeathRate(), "PopulationNaturalDeathRate", fr.ifremer.isisfish.equation.PopulationNaturalDeathRate.class); + meanWeight.init(_("isisfish.populationEquation.meanWeight"), (Formule)getBean().getMeanWeight(), "PopulationMeanWeight", fr.ifremer.isisfish.equation.PopulationMeanWeight.class); + price.init(_("isisfish.populationEquation.price"), (Formule)getBean().getPrice(), "PopulationPrice", fr.ifremer.isisfish.equation.PopulationPrice.class); + naturalDeathRate.refresh(); + meanWeight.refresh(); + price.refresh(); +} ]]> </script> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='naturalDeathRate' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='meanWeight' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='price' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}' onActionPerformed='save()'/> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='naturalDeathRate' constructorParams='this'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='meanWeight' constructorParams='this'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='price' constructorParams='this'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,44 +31,30 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> + <fr.ifremer.isisfish.entities.PopulationGroupImpl id='populationGroup' javaBean='null'/> <script><![CDATA[ - import fr.ifremer.isisfish.entities.PopulationGroup; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Population; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.math.matrix.gui.MatrixPanelListener; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationGroupImpl; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import org.codelutin.math.matrix.gui.MatrixPanelListener; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; - protected Population pop = null; - protected PopulationGroup populationGroup = null; - public PopulationGroupUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (populationGroup != null){ - setFieldPopulationGroupPopulationGroupModel(); - fieldPopulationGroupMeanWeight.setText(populationGroup.getMeanWeight() + ""); - fieldPopulationGroupPrice.setText(populationGroup.getPrice() + ""); - fieldPopulationGroupReproductionRate.setText(populationGroup.getReproductionRate() + ""); - fieldPopulationGroupAge.setText(populationGroup.getAge() + ""); - fieldPopulationGroupMinLength.setText(populationGroup.getMinLength() + ""); - fieldPopulationGroupMaxLength.setText(populationGroup.getMaxLength() + ""); - fieldPopulationGroupComment.setText(populationGroup.getComment()); - setFieldPopulationGroupNaturalDeathRateModel(); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); fieldPopulationGroupMeanWeight.setText(""); fieldPopulationGroupPrice.setText(""); fieldPopulationGroupReproductionRate.setText(""); @@ -76,153 +62,103 @@ fieldPopulationGroupMinLength.setText(""); fieldPopulationGroupMaxLength.setText(""); fieldPopulationGroupComment.setText(""); - fieldPopulationGroupNaturalDeathRate.setMatrix(null); +// fieldPopulationGroupNaturalDeathRate.setMatrix(null); } - } - protected void setFieldPopulationGroupNaturalDeathRateModel(){ - fieldPopulationGroupNaturalDeathRate.setMatrix(pop.getNaturalDeathRateMatrix()); - } - protected void setFieldPopulationGroupPopulationGroupModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<PopulationGroup> popGroups = pop.getPopulationGroup(); - model.addElement(new GenericCell(" ", null, null)); - for (PopulationGroup pg : popGroups){ - model.addElement(new GenericCell(pop.getName() + " - " + pg.getId(), pg, PopulationGroup.class)); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationGroupPopulationGroup.setModel(model); } - protected void populationGroupChanged(){ - if (fieldPopulationGroupPopulationGroup.getSelectedItem() != null){ - GenericCell cell = (GenericCell) fieldPopulationGroupPopulationGroup.getSelectedItem(); - if (cell.getValue() != null){ - jaxx.runtime.Util.assignment(populationGroup = (PopulationGroup)cell.getValue(), "populationGroup", fr.ifremer.isisfish.ui.input.PopulationGroupUI.this); - valueChanged(true); - refresh(); - } - } - } - protected void reproductionRateChanged(){ - populationGroup.setReproductionRate(Double.parseDouble(fieldPopulationGroupReproductionRate.getText())); - valueChanged(true); - } - protected void groupMinLengthChanged(){ - populationGroup.setMinLength(Double.parseDouble(fieldPopulationGroupMinLength.getText())); - valueChanged(true); - } - protected void groupMaxLengthChanged(){ - populationGroup.setMaxLength(Double.parseDouble(fieldPopulationGroupMaxLength.getText())); - valueChanged(true); - } - protected void groupCommentChanged(){ - populationGroup.setComment(fieldPopulationGroupComment.getText()); - valueChanged(true); - } - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +}); +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationGroupPopulationGroup,getBean().getPopulationGroup(), null); +} ]]> </script> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JComboBox id='fieldPopulationGroupPopulationGroup' onActionPerformed='populationGroupChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.meanWeigth" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupMeanWeight" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.price" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupPrice" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.naturalDeathRate" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='both' weightx='1.0' weighty='0.5'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationGroupNaturalDeathRate' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.reproductionRate" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupReproductionRate" onKeyTyped='valueChanged(true)' onFocusLost='reproductionRateChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.age" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupAge" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.length" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='0.5'> - <JTextField id="fieldPopulationGroupMinLength" onKeyTyped='valueChanged(true)' onFocusLost='groupMinLengthChanged()' enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='0.5'> - <JTextField id="fieldPopulationGroupMaxLength" onKeyTyped='valueChanged(true)' onFocusLost='groupMaxLengthChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.populationGroup.comments" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='both' weightx='1.0' weighty='0.5'> - <JScrollPane> - <JTextArea id="fieldPopulationGroupComment" onKeyTyped='valueChanged(true)' onFocusLost='groupCommentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='3' fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JComboBox id='fieldPopulationGroupPopulationGroup' onActionPerformed='setPopulationGroup((PopulationGroupImpl)fieldPopulationGroupPopulationGroup.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.meanWeigth" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationGroupMeanWeight" text='getPopulationGroup().getMeanWeight()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.price" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationGroupPrice" text='getPopulationGroup().getPrice()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.naturalDeathRate" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='both' weightx='1.0' weighty='0.5'> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.reproductionRate" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationGroupReproductionRate" text='getPopulationGroup().getReproductionRate()' onKeyTyped='getPopulationGroup().setReproductionRate(Double.parseDouble(fieldPopulationGroupReproductionRate.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.age" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationGroupAge" text='getPopulationGroup().getAge()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.length" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='0.5'> + <JTextField id="fieldPopulationGroupMinLength" text='getPopulationGroup().getMinLength()' onKeyTyped='getPopulationGroup().setMinLength(Double.parseDouble(fieldPopulationGroupMinLength.getText()))' enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='0.5'> + <JTextField id="fieldPopulationGroupMaxLength" text='getPopulationGroup().getMaxLength()' onKeyTyped='getPopulationGroup().setMaxLength(Double.parseDouble(fieldPopulationGroupMaxLength.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.populationGroup.comments" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='both' weightx='1.0' weighty='0.5'> + <JScrollPane> + <JTextArea id="fieldPopulationGroupComment" text='getPopulationGroup().getComment()' onKeyTyped='getPopulationGroup().setComment(fieldPopulationGroupComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='3' fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,84 +31,75 @@ */ --> -<!-- - name="isisfish.populationMigrationEmigration.title" ---> -<Table implements='InputContent'> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <Boolean id='changed' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl id='popInfo' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import org.codelutin.math.matrix.MatrixND; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; - import org.codelutin.math.matrix.gui.MatrixPanelListener; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.PopulationGroup; - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.entities.Zone; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl; +import org.codelutin.math.matrix.MatrixND; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import org.codelutin.math.matrix.gui.MatrixPanelListener; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; - protected Population pop; - protected PopulationSeasonInfo popInfo = null; - - public PopulationMigrationEmigrationUI (InputAction action){ - - setContextValue(action); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); + populationMigrationEmigrationTable.setMatrix(null); + } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } +}); public void init(PopulationSeasonInfo pi){ - popInfo = pi; + setPopInfo((PopulationSeasonInfoImpl)pi); } public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); - populationMigrationEmigrationTable.setMatrix(popInfo.getEmigrationMatrix()); - populationMigrationEmigrationTable.addMatrixListener(new MatrixPanelListener() { + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); - @Override - public void matrixChanged(MatrixPanelEvent arg0) { - popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix()); - } - }); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationMigrationEmigrationGroupChooser.setModel(model); - fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(model); - populationMigrationEmigrationTable.setMatrix(null); - } + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); + populationMigrationEmigrationTable.addMatrixListener(new MatrixPanelListener() { + + @Override + public void matrixChanged(MatrixPanelEvent arg0) { + popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix()); + } + }); } protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<PopulationGroup> values = pop.getPopulationGroup(); - for (PopulationGroup pg : values){ - model.addElement(pg); - } - fieldPopulationMigrationEmigrationGroupChooser.setModel(model); + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null); } protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Zone> values = pop.getPopulationZone(); - for (Zone z : values){ - model.addElement(z); - } - fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(model); + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null); } protected void add(){ getContextValue(InputAction.class).addEmigration( - popInfo, + getPopInfo(), (PopulationGroup) fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(), (Zone) fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(), Double.parseDouble(fieldPopulationMigrationEmigrationCoefficient.getText())); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); refresh(); } protected void remove(){ @@ -121,7 +112,6 @@ MatrixND mat = popInfo.getEmigrationMatrix().copy(); mat.setValue(group, departure, 0); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); popInfo.setEmigrationMatrix(mat); }catch(Exception eee){ @@ -132,46 +122,46 @@ } ]]> </script> - <row> - <cell> - <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationEmigrationGroupChooser" enabled='{isActif()}'/> - </cell> - <cell> - <JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.populationMigrationEmigration.departureZone" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='0.5'> - <JPanel/> - </cell> - </row> - <row columns='4'> - <cell fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> - </cell> - </row> - <row columns='4'> - <cell fill='both' weightx='1.0' weighty='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationEmigrationTable' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='4' fill='horizontal' weightx='1.0'> - <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> -</Table> - - \ No newline at end of file + <Table id='body'> + <row> + <cell> + <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationEmigrationGroupChooser" enabled='{isActif()}'/> + </cell> + <cell> + <JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.populationMigrationEmigration.departureZone" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='0.5'> + <JPanel/> + </cell> + </row> + <row columns='4'> + <cell fill='horizontal' weightx='1.0'> + <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + </cell> + </row> + <row columns='4'> + <cell fill='both' weightx='1.0' weighty='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationEmigrationTable' matrix='{getPopInfo().getEmigrationMatrix()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='4' fill='horizontal' weightx='1.0'> + <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,78 +30,56 @@ * by : $Author: sletellier $ */ --> -<Table name="isisfish.populationMigrationEquation.title" implements='InputContent'> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <Boolean id='changed' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl id='popInfo' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.Formule; - protected Population pop = null; - protected PopulationSeasonInfo popInfo = null; - init(); - public PopulationMigrationEquationUI (InputAction action){ - - setContextValue(action); - } - public void init(PopulationSeasonInfo pi){ - this.popInfo = pi; - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - migrationEquation.init(_("isisfish.common.migration"), (Formule)popInfo.getMigrationEquation(), "Migration", fr.ifremer.isisfish.equation.MigrationEquation.class); - emigrationEquation.init(_("isisfish.common.emigration"), (Formule)popInfo.getEmigrationEquation(), "Emigration", fr.ifremer.isisfish.equation.EmigrationEquation.class); - immigrationEquation.init(_("isisfish.common.immigration"), (Formule)popInfo.getImmigrationEquation(), "Immigration", fr.ifremer.isisfish.equation.ImmigrationEquation.class); - } - else{ - migrationEquation.init(_("isisfish.common.migration"), null, "Migration", fr.ifremer.isisfish.equation.MigrationEquation.class); - emigrationEquation.init(_("isisfish.common.emigration"), null, "Emigration", fr.ifremer.isisfish.equation.EmigrationEquation.class); - immigrationEquation.init(_("isisfish.common.immigration"), null, "Immigration", fr.ifremer.isisfish.equation.ImmigrationEquation.class); - } - migrationEquation.refresh(); - 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()); - } - }); - } +setType("Population"); +setButtonTitle(""); +setNextPath(null); + +public void init(PopulationSeasonInfo pi){ + setPopInfo((PopulationSeasonInfoImpl)pi); +} +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + migrationEquation.init(_("isisfish.common.migration"), (Formule)getPopInfo().getMigrationEquation(), "Migration", fr.ifremer.isisfish.equation.MigrationEquation.class); + emigrationEquation.init(_("isisfish.common.emigration"), (Formule)getPopInfo().getEmigrationEquation(), "Emigration", fr.ifremer.isisfish.equation.EmigrationEquation.class); + immigrationEquation.init(_("isisfish.common.immigration"), (Formule)getPopInfo().getImmigrationEquation(), "Immigration", fr.ifremer.isisfish.equation.ImmigrationEquation.class); + migrationEquation.refresh(); + emigrationEquation.refresh(); + immigrationEquation.refresh(); +} ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='migrationEquation' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='emigrationEquation' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='0.3'> - <PopulationOneEquationUI id='immigrationEquation' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='migrationEquation' constructorParams='this'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='emigrationEquation' constructorParams='this'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='0.3'> + <PopulationOneEquationUI id='immigrationEquation' constructorParams='this'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -33,82 +33,74 @@ <!-- Fixme : ContextDataSource name="isisfish.populationMigrationImmigration.title" --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.PopulationGroup; - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.entities.Zone; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; - import org.codelutin.math.matrix.MatrixND; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; - import org.codelutin.math.matrix.gui.MatrixPanelListener; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixND; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import org.codelutin.math.matrix.gui.MatrixPanelListener; - protected PopulationSeasonInfo popInfo = null; - protected Population pop = null; - public PopulationMigrationImmigrationUI (InputAction action){ - - setContextValue(action); - } +protected PopulationSeasonInfo popInfo = null; - public void init(PopulationSeasonInfo pi){ - this.popInfo = pi; - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); - populationMigrationImmigrationTable.setMatrix(popInfo.getMigrationMatrix()); - populationMigrationImmigrationTable.addMatrixListener(new MatrixPanelListener() { - - @Override - public void matrixChanged(MatrixPanelEvent arg0) { - popInfo.setImmigrationMatrix(populationMigrationImmigrationTable.getMatrix()); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); - } - }); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(model); - fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(model); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); populationMigrationImmigrationTable.setMatrix(null); } - } - protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<PopulationGroup> values = pop.getPopulationGroup(); - for (PopulationGroup pg : values){ - model.addElement(pg); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(model); } - protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Zone> values = pop.getPopulationZone(); - for (Zone z : values){ - model.addElement(z); +}); + +public void init(PopulationSeasonInfo pi){ + this.popInfo = pi; +} +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); + populationMigrationImmigrationTable.setMatrix(popInfo.getMigrationMatrix()); + populationMigrationImmigrationTable.addMatrixListener(new MatrixPanelListener() { + + @Override + public void matrixChanged(MatrixPanelEvent arg0) { + popInfo.setImmigrationMatrix(populationMigrationImmigrationTable.getMatrix()); } - fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(model); - } - protected void add(){ - getContextValue(InputAction.class).addImmigration(popInfo, - (PopulationGroup) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), - Double.parseDouble(fieldPopulationMigrationImmigrationCoefficient.getText())); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); - refresh(); - } - protected void remove(){ + }); +} +protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationImmigrationArrivalZoneChooser,getBean().getPopulationGroup(), null); +} +protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationImmigrationArrivalZoneChooser,getBean().getPopulationZone(), null); +} +protected void add(){ + getContextValue(InputAction.class).addImmigration(popInfo, + (PopulationGroup) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), + (Zone) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), + Double.parseDouble(fieldPopulationMigrationImmigrationCoefficient.getText())); + refresh(); +} +protected void remove(){ int row = populationMigrationImmigrationTable.getTable().getSelectedRow(); Object group = populationMigrationImmigrationTable.getTable().getValueAt(row, 0); Object departure = populationMigrationImmigrationTable.getTable().getValueAt(row, 1); @@ -117,49 +109,50 @@ MatrixND mat = popInfo.getImmigrationMatrix().copy(); mat.setValue(group, departure, arrival, 0); popInfo.setImmigrationMatrix(mat); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); refresh(); - } +} ]]> </script> - <row> - <cell> - <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationImmigrationGroupChooser" enabled='{isActif()}'/> - </cell> - <cell> - <JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.populationMigrationImmigration.arrivalZone" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser" enabled='{isActif()}'/> - </cell> - <cell columns='2' fill='horizontal' weightx='0.5'> - <JPanel/> - </cell> - </row> - <row columns='4'> - <cell fill='horizontal' weightx='1.0'> - <JButton id="buttonPopulationMigrationImmigrationAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> - </cell> - </row> - <row columns='4'> - <cell fill='both' weightx='1.0' weighty='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationImmigrationTable' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='4' fill='horizontal' weightx='1.0'> - <JButton id="buttonPopulationImmigrationMigrationRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell> + <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationImmigrationGroupChooser" enabled='{isActif()}'/> + </cell> + <cell> + <JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.populationMigrationImmigration.arrivalZone" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser" enabled='{isActif()}'/> + </cell> + <cell columns='2' fill='horizontal' weightx='0.5'> + <JPanel/> + </cell> + </row> + <row columns='4'> + <cell fill='horizontal' weightx='1.0'> + <JButton id="buttonPopulationMigrationImmigrationAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + </cell> + </row> + <row columns='4'> + <cell fill='both' weightx='1.0' weighty='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationImmigrationTable' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='4' fill='horizontal' weightx='1.0'> + <JButton id="buttonPopulationImmigrationMigrationRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,150 +31,137 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.PopulationGroup; - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.entities.Zone; - import org.codelutin.math.matrix.MatrixND; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; - import org.codelutin.math.matrix.gui.MatrixPanelListener; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import org.codelutin.math.matrix.MatrixND; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import org.codelutin.math.matrix.gui.MatrixPanelListener; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; - protected PopulationSeasonInfo popInfo = null; - protected Population pop = null; - protected PopulationSeasonInfo pi; - public PopulationMigrationMigrationUI (InputAction action){ - - setContextValue(action); - } - public void init(PopulationSeasonInfo pi){ - this.pi = pi; - } - public void refresh(){ - popInfo = pi; - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); - setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); - populationMigrationMigrationTable.setMatrix(popInfo.getMigrationMatrix()); - populationMigrationMigrationTable.addMatrixListener(new MatrixPanelListener() { +protected PopulationSeasonInfo popInfo = null; +protected PopulationSeasonInfo pi; - @Override - public void matrixChanged(MatrixPanelEvent arg0) { - popInfo.setMigrationMatrix(populationMigrationMigrationTable.getMatrix()); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); - } - }); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationMigrationMigrationGroupChooser.setModel(model); - fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(model); - fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(model); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); populationMigrationMigrationTable.setMatrix(null); } - } - protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<PopulationGroup> values = pop.getPopulationGroup(); - for (PopulationGroup pg : values){ - model.addElement(pg); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationMigrationMigrationGroupChooser.setModel(model); } - protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Zone> values = pop.getPopulationZone(); - for (Zone z : values){ - model.addElement(z); +}); +public void init(PopulationSeasonInfo pi){ + this.pi = pi; +} +public void refresh(){ + popInfo = pi; + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); + setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); + populationMigrationMigrationTable.setMatrix(popInfo.getMigrationMatrix()); + populationMigrationMigrationTable.addMatrixListener(new MatrixPanelListener() { + + @Override + public void matrixChanged(MatrixPanelEvent arg0) { + popInfo.setMigrationMatrix(populationMigrationMigrationTable.getMatrix()); } - fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(model); - } - protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Zone> values = pop.getPopulationZone(); - for (Zone z : values){ - model.addElement(z); - } - fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(model); - } - protected void add(){ - getContextValue(InputAction.class).addMigration(popInfo, - (PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(), - Double.parseDouble(fieldPopulationMigrationMigrationCoefficient.getText())); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); - refresh(); - } - protected void remove(){ - int row = populationMigrationMigrationTable.getTable().getSelectedRow(); - Object group = populationMigrationMigrationTable.getTable().getValueAt(row, 0); - Object departure = populationMigrationMigrationTable.getTable().getValueAt(row, 1); - Object arrival = populationMigrationMigrationTable.getTable().getValueAt(row, 2); + }); +} +protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationMigrationGroupChooser,getBean().getPopulationGroup(), null); +} +protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationMigrationGroupChooser,getBean().getPopulationZone(), null); +} +protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationMigrationMigrationGroupChooser,getBean().getPopulationZone(), null); +} +protected void add(){ + getAction().addMigration(popInfo, + (PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(), + (Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(), + (Zone) fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(), + Double.parseDouble(fieldPopulationMigrationMigrationCoefficient.getText())); + refresh(); +} +protected void remove(){ + int row = populationMigrationMigrationTable.getTable().getSelectedRow(); + Object group = populationMigrationMigrationTable.getTable().getValueAt(row, 0); + Object departure = populationMigrationMigrationTable.getTable().getValueAt(row, 1); + Object arrival = populationMigrationMigrationTable.getTable().getValueAt(row, 2); - MatrixND mat = popInfo.getMigrationMatrix().copy(); - mat.setValue(group, departure, arrival, 0); - popInfo.setMigrationMatrix(mat); - getParentContainer(PopulationMigrationUI.class).valueChanged(true); - refresh(); - } + MatrixND mat = popInfo.getMigrationMatrix().copy(); + mat.setValue(group, departure, arrival, 0); + popInfo.setMigrationMatrix(mat); + refresh(); +} ]]> </script> - <row> - <cell> - <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActif()}'/> - </cell> - <cell> - <JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.populationMigrationMigration.departureZone" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActif()}'/> - </cell> - <cell> - <JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActif()}'/> - </cell> - </row> - <row columns='4'> - <cell fill='horizontal' weightx='1.0'> - <JButton id="buttonPopulationMigrationMigrationAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> - </cell> - </row> - <row columns='4'> - <cell fill='both' weightx='1.0' weighty='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationMigrationTable' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='4' fill='horizontal' weightx='1.0'> - <JButton id="buttonPopulationMigrationMigrationRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> -</Table> - \ No newline at end of file + <Table id='body'> + <row> + <cell> + <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActif()}'/> + </cell> + <cell> + <JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.populationMigrationMigration.departureZone" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActif()}'/> + </cell> + <cell> + <JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActif()}'/> + </cell> + </row> + <row columns='4'> + <cell fill='horizontal' weightx='1.0'> + <JButton id="buttonPopulationMigrationMigrationAdd" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + </cell> + </row> + <row columns='4'> + <cell fill='both' weightx='1.0' weighty='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='populationMigrationMigrationTable' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='4' fill='horizontal' weightx='1.0'> + <JButton id="buttonPopulationMigrationMigrationRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + </cell> + </row> + </Table> + </fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,183 +31,131 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Population; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; - init(); - protected Population pop; -// protected PopulationSeasonInfo populationSeasonInfoSelected = null; - public PopulationMigrationUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setFieldPopulationMigrationSeasonChooserModel(); - PopulationSeasonInfo selected = getPopulationSeasonInfo(); - if (selected != null){ - fieldUseEquationMigration.setSelected(selected.getUseEquationMigration()); - useEquationChanged(); - populationMigrationEquationUI.init(selected); - populationMigrationMigrationUI.init(selected); - populationMigrationImmigrationUI.init(selected); - populationMigrationEmigrationUI.init(selected); - populationMigrationEquationUI.refresh(); - populationMigrationMigrationUI.refresh(); - populationMigrationImmigrationUI.refresh(); - populationMigrationEmigrationUI.refresh(); - } - fieldPopulationMigrationComment.setText(pop.getMigrationComment()); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationMigrationSeasonChooser.setModel(model); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); 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()){ - model.addElement(new GenericCell(psi.getFirstMonth() + " - " + psi.getLastMonth(), psi, PopulationSeasonInfo.class)); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationMigrationSeasonChooser.setModel(model); } - protected PopulationSeasonInfo getPopulationSeasonInfo(){ - PopulationSeasonInfo result = null; - Object selected = fieldPopulationMigrationSeasonChooser.getSelectedItem(); - if (selected != null){ - GenericCell cell = (GenericCell)selected; - if (cell.getValue() != null){ - result = (PopulationSeasonInfo)cell.getValue(); - } - } - return result; +}); +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + setFieldPopulationMigrationSeasonChooserModel(); + PopulationSeasonInfo selected = getPopulationSeasonInfo(); + if (selected != null){ + fieldUseEquationMigration.setSelected(selected.getUseEquationMigration()); + useEquationChanged(); + populationMigrationEquationUI.init(selected); + populationMigrationMigrationUI.init(selected); + populationMigrationImmigrationUI.init(selected); + populationMigrationEmigrationUI.init(selected); + populationMigrationEquationUI.refresh(); + populationMigrationMigrationUI.refresh(); + populationMigrationImmigrationUI.refresh(); + populationMigrationEmigrationUI.refresh(); } - protected void seasonChooserChanged(){ -// populationSeasonInfoSelected = getPopulationSeasonInfo(); - valueChanged(true); - refresh(); +} +protected void setFieldPopulationMigrationSeasonChooserModel(){ + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (PopulationSeasonInfo psi : getBean().getPopulationSeasonInfo()){ + model.addElement(new GenericCell(psi.getFirstMonth() + " - " + psi.getLastMonth(), psi, PopulationSeasonInfo.class)); } - protected void useEquationChanged(){ - if (fieldUseEquationMigration.isSelected()){ - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation"); + fieldPopulationMigrationSeasonChooser.setModel(model); +} +protected PopulationSeasonInfo getPopulationSeasonInfo(){ + PopulationSeasonInfo result = null; + Object selected = fieldPopulationMigrationSeasonChooser.getSelectedItem(); + if (selected != null){ + GenericCell cell = (GenericCell)selected; + if (cell.getValue() != null){ + result = (PopulationSeasonInfo)cell.getValue(); } - else{ - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix"); - } - valueChanged(true); } - protected void commentChanged(){ - pop.setMigrationComment(fieldPopulationMigrationComment.getText()); - valueChanged(true); + return result; +} +protected void useEquationChanged(){ + if (fieldUseEquationMigration.isSelected()){ + ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation"); } - 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(); + else{ + ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix"); } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - public void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +} ]]> </script> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationMigration.selectSeason" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldPopulationMigrationSeasonChooser" onActionPerformed='seasonChooserChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' anchor='west'> - <JCheckBox id="fieldUseEquationMigration" selected='true' text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='0.7'> - <JPanel id="hidablePanel" layout='{new CardLayout()}'> - <PopulationMigrationEquationUI id='populationMigrationEquationUI' constraints='"fieldUseEquation"' constructorParams='getContextValue(InputAction.class)'/> - <JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"'> - <tab title='{_("isisfish.metier.title")}'><PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><PopulationMigrationImmigrationUI id="populationMigrationImmigrationUI" constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><PopulationMigrationEmigrationUI id="populationMigrationEmigrationUI" constructorParams='getContextValue(InputAction.class)'/></tab> - </JTabbedPane> - </JPanel> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationMigration.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.3'> - <JScrollPane> - <JTextArea id="fieldPopulationMigrationComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationMigration.selectSeason" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldPopulationMigrationSeasonChooser" onActionPerformed='refresh()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' anchor='west'> + <JCheckBox id="fieldUseEquationMigration" selected='true' text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='0.7'> + <JPanel id="hidablePanel" layout='{new CardLayout()}'> + <PopulationMigrationEquationUI id='populationMigrationEquationUI' constraints='"fieldUseEquation"' constructorParams='this'/> + <JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"'> + <tab title='{_("isisfish.metier.title")}'><PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='this'/></tab> + <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><PopulationMigrationImmigrationUI id="populationMigrationImmigrationUI" constructorParams='this'/></tab> + <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><PopulationMigrationEmigrationUI id="populationMigrationEmigrationUI" constructorParams='this'/></tab> + </JTabbedPane> + </JPanel> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationMigration.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.3'> + <JScrollPane> + <JTextArea id="fieldPopulationMigrationComment" text='getBean().getMigrationComment()' onKeyTyped='getBean().setMigrationComment(fieldPopulationMigrationComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationOneEquationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationOneEquationUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationOneEquationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,146 +31,166 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.Equation; +import java.util.logging.Level; +import java.util.logging.Logger; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.Equation; - import java.util.logging.Level; - import java.util.logging.Logger; - - protected Population pop = null; - protected Class clazz = null; - protected String nameEquation = null; - protected String lblText; - protected Formule f; - protected String name; - protected Class c; +protected Class clazz = null; +protected String nameEquation = null; +protected String lblText; +protected Formule f; +protected String name; +protected Class c; - public PopulationOneEquationUI (InputAction action){ - setContextValue(action); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); +// fieldPopulationMonthGapBetweenReproRecrutement.setText(""); +// fieldPopulationRecruitmentComment.setText(""); + } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } - public void init(String lblText, Formule f, String name, Class c){ - this.lblText = lblText; - this.f = f; - this.name = name; - this.c = c; +}); + +public void init(String lblText, Formule f, String name, Class c){ + this.lblText = lblText; + this.f = f; + this.name = name; + this.c = c; +} +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + lbl.setText(lblText); + clazz = c; + try { + editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); + } catch (IOException ex) { + Logger.getLogger(PopulationOneEquationUI.class.getName()).log(Level.SEVERE, null, ex); } - public void refresh(){ - lbl.setText(lblText); - clazz = c; - try { - editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); - } catch (IOException ex) { - Logger.getLogger(PopulationOneEquationUI.class.getName()).log(Level.SEVERE, null, ex); + setComboModel(f, name); +} +protected void setComboModel(Formule f, String name){ + DefaultComboBoxModel model = new DefaultComboBoxModel(); + GenericCell cellSelected = null; + for (Formule formule : getAction().getFormules(getBean().getTopiaContext(),name)){ + GenericCell cell = new GenericCell(formule.getName(), formule, Formule.class); + model.addElement(cell); + if (formule.equals(f)){ + cellSelected = cell; } - setComboModel(f, name); } - protected void setComboModel(Formule f, String name){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - GenericCell cellSelected = null; - for (Formule formule : getContextValue(InputAction.class).getFormules(name)){ - GenericCell cell = new GenericCell(formule.getName(), formule, Formule.class); - model.addElement(cell); - if (formule.equals(f)){ - cellSelected = cell; - } - } - combo.setModel(model); - if (cellSelected != null){ - combo.setSelectedItem(cellSelected); - comboChanged(); - } - } - protected void comboChanged(){ + combo.setModel(model); + if (cellSelected != null){ + combo.setSelectedItem(cellSelected); Equation selected = getEquation(); if (selected != null){ editor.setText(selected.getContent()); } - valueChanged(true); } - protected Equation getEquation(){ - Equation result = null; - Object selected = combo.getSelectedItem(); - if (selected != null){ - GenericCell cell = (GenericCell) selected; - if (cell.getValue() != null){ - result = (Equation)cell.getValue(); - } - } - return result; +} +protected void comboChanged(){ + Equation selected = getEquation(); + if (selected != null){ + editor.setText(selected.getContent()); } - protected void valueChanged(boolean b){ - changed = b; - if (getParentContainer(PopulationEquationUI.class) != null){ - getParentContainer(PopulationEquationUI.class).valueChanged(b); + valueChanged(true); +} +protected Equation getEquation(){ + Equation result = null; + Object selected = combo.getSelectedItem(); + if (selected != null){ + GenericCell cell = (GenericCell) selected; + if (cell.getValue() != null){ + result = (Equation)cell.getValue(); } - else{ - getParentContainer(PopulationMigrationUI.class).valueChanged(b); - } } - protected void saveModel(){ - Equation e = getEquation(); - if (e != null){ - getContextValue(InputAction.class).saveAsModel(e.getCategory(), e.getLanguage(), e.getContent()); - } - else{ - getContextValue(InputAction.class).saveAsModel(name, "Java", editor.getText()); - setComboModel(f, name); - } + return result; +} +protected void valueChanged(boolean b){ + changed = b; + if (getParentContainer(PopulationEquationUI.class) != null){ +// getParentContainer(PopulationEquationUI.class).valueChanged(b); + } + else{ +// getParentContainer(PopulationMigrationUI.class).valueChanged(b); + } +} +protected void saveModel(){ + Equation e = getEquation(); + if (e != null){ + getContextValue(InputAction.class).saveAsModel(e.getCategory(), e.getLanguage(), e.getContent()); + } + else{ + getContextValue(InputAction.class).saveAsModel(name, "Java", editor.getText()); + setComboModel(f, name); + } + refresh(); // setInfoText(_("isisfish.message.saveModel.finished")); +} +protected void openEditor(){ + Equation e = getEquation(); + if (e != null){ + getContextValue(InputAction.class).openEditor(e.getCategory(), e.getName(), clazz, e.getContent(), editor); } - protected void openEditor(){ - Equation e = getEquation(); - if (e != null){ - getContextValue(InputAction.class).openEditor(e.getCategory(), e.getName(), clazz, e.getContent(), editor); - } - else{ - getContextValue(InputAction.class).openEditor(name,"new",c, editor.getText(), editor); - } + else{ + getContextValue(InputAction.class).openEditor(name,"new",c, editor.getText(), editor); } +} ]]> </script> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel id='lbl'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="combo" onActionPerformed='comboChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" onKeyTyped='valueChanged(true)' onFocusLost='valueChanged(true)' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel id='lbl'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="combo" onActionPerformed='comboChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" onKeyTyped='valueChanged(true)' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,230 +30,155 @@ * by : $Author: sletellier $ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.Equation; - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import java.util.logging.Level; - import java.util.logging.Logger; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import java.util.logging.Level; +import java.util.logging.Logger; - protected Population pop = null; - public PopulationRecruitmentUI (InputAction action){ - - setContextValue(action); - } - public void refresh(){ - jaxx.runtime.Util.assignment(pop = getContextValue(InputAction.class).getPopulation(), "pop", fr.ifremer.isisfish.ui.input.PopulationRecruitmentUI.this); - try { - editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); - } catch (IOException ex) { - Logger.getLogger(PopulationRecruitmentUI.class.getName()).log(Level.SEVERE, null, ex); - } - if (pop != null){ - setFieldPopulationReproductionEquationModel(); - fieldPopulationMonthGapBetweenReproRecrutement.setText(pop.getMonthGapBetweenReproRecrutement() + ""); - fieldPopulationRecruitmentComment.setText(pop.getRecruitmentComment()); - valueChanged(false); - } - else{ +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldPopulationMonthGapBetweenReproRecrutement.setText(""); fieldPopulationRecruitmentComment.setText(""); - valueChanged(false); - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationReproductionEquation.setModel(model); } - } - protected void setFieldPopulationReproductionEquationModel() { - DefaultComboBoxModel model = new DefaultComboBoxModel(); - Equation selected = pop.getReproductionEquation(); - GenericCell cellSelected = null; - java.util.List<Formule> formules = getContextValue(InputAction.class).getFormules("Reproduction"); - for (Formule f : formules){ - GenericCell cell = new GenericCell(f.getName(), f, Formule.class); - model.addElement(cell); - if(f.equals((Formule)selected)){ - cellSelected = cell; - } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationReproductionEquation.setModel(model); - if (cellSelected != null){ - fieldPopulationReproductionEquation.setSelectedItem(cellSelected); - } } - protected void equationChanged(){ - Equation e = getEquation(); - if (e != null){ - editor.setText(e.getContent()); - valueChanged(true); - } +}); + +public void refresh() { + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + setFieldPopulationReproductionEquationModel(); + try { + editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); + } catch (IOException ex) { + Logger.getLogger(PopulationRecruitmentUI.class.getName()).log(Level.SEVERE, null, ex); } - protected Equation getEquation(){ - Equation result = null; - Object o = fieldPopulationReproductionEquation.getSelectedItem(); - if (o != null){ - GenericCell c = (GenericCell)o; - if (c.getValue() != null){ - result = (Equation)c.getValue(); - } - } - return result; +} +protected void setFieldPopulationReproductionEquationModel() { + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationReproductionEquation,getAction().getFormules(getBean().getTopiaContext(), "Reproduction"), getBean().getReproductionEquation()); +} +protected void equationChanged(){ + Formule e = (Formule)fieldPopulationReproductionEquation.getSelectedItem(); + if (e != null){ + editor.setText(e.getContent()); } - protected void saveModel(){ - Equation e = getEquation(); - if (e != null){ - getContextValue(InputAction.class).saveAsModel(e.getCategory(), e.getLanguage(), e.getContent()); - } - else{ - getContextValue(InputAction.class).saveAsModel("Reproduction", "Java", editor.getText()); - setFieldPopulationReproductionEquationModel(); - setInfoText(_("isisfish.message.saveModel.finished")); - } - } - protected void openEditor(){ - Equation e = getEquation(); - if (e != null){ - getContextValue(InputAction.class).openEditor(e.getCategory(), e.getName(), fr.ifremer.isisfish.equation.PopulationGrowth.class, e.getContent(), editor); - } - else{ - getContextValue(InputAction.class).openEditor("Reproduction","new", fr.ifremer.isisfish.equation.PopulationGrowth.class, editor.getText(), editor); - } - } - protected void monthGapChanged(){ - pop.setMonthGapBetweenReproRecrutement(Integer.parseInt(fieldPopulationMonthGapBetweenReproRecrutement.getText())); - valueChanged(true); - } - protected void commentChanged(){ - pop.setRecruitmentComment(fieldPopulationRecruitmentComment.getText()); - valueChanged(true); - } - protected void create(){ - getContextValue(InputAction.class).createRecruitmentDistribution(); - refresh(); - } - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +} +protected void saveModel(){ + getAction().saveAsModel("PopulationReproductionEquation", "Java", editor.getText()); + setFieldPopulationReproductionEquationModel(); + setInfoText(_("isisfish.message.saveModel.finished")); +} +protected void openEditor(){ + getAction().openEditor("PopulationReproductionEquation","new", fr.ifremer.isisfish.equation.PopulationGrowth.class, editor.getText(), editor); +} ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationRecruitment.reproductionEquation" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldPopulationReproductionEquation" onActionPerformed='equationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='0.5'> - <JScrollPane> - <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="Month Gap BetweenRepro Recruitment" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationMonthGapBetweenReproRecrutement" onKeyTyped='valueChanged(true)' onFocusLost='monthGapChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationRecruitment.recruitmentDistribution" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0'> - <JTable/> - </cell> - </row> - <row> - <cell> - <JPanel/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JButton id="create" text="isisfish.common.newMatrix" onActionPerformed='create()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationRecruitment.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.5'> - <JScrollPane> - <JTextArea id="fieldPopulationRecruitmentComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - </Table> - </cell> - </row> + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationRecruitment.reproductionEquation" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldPopulationReproductionEquation" onActionPerformed='equationChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='0.5'> + <JScrollPane> + <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="Month Gap BetweenRepro Recruitment" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldPopulationMonthGapBetweenReproRecrutement" text='getBean().getMonthGapBetweenReproRecrutement()' onKeyTyped='getBean().setMonthGapBetweenReproRecrutement(Integer.parseInt(fieldPopulationMonthGapBetweenReproRecrutement.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationRecruitment.recruitmentDistribution" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0'> + <JTable/> + </cell> + </row> + <row> + <cell> + <JPanel/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id="create" text="isisfish.common.newMatrix" onActionPerformed='getAction().createRecruitmentDistribution(getBean())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationRecruitment.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.5'> + <JScrollPane> + <JTextArea id="fieldPopulationRecruitmentComment" text='getBean().getRecruitmentComment()' onKeyTyped='getBean().setRecruitmentComment(fieldPopulationRecruitmentComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> </Table> - - \ No newline at end of file +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,251 +31,170 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> + <fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl id='populationSeasonInfo' javaBean='null'/> <script><![CDATA[ +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl; +import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.ui.widget.Interval; +import fr.ifremer.isisfish.ui.widget.IntervalPanel; - import fr.ifremer.isisfish.entities.PopulationSeasonInfo; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.types.Month; - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.widget.Interval; - import fr.ifremer.isisfish.ui.widget.IntervalPanel; - - protected Population pop = null; - protected IntervalPanel ip = new IntervalPanel(); - fieldPopulationSeasonInterval.add(ip, BorderLayout.CENTER); - public PopulationSeasonsUI (InputAction action){ - - setContextValue(action); +protected IntervalPanel ip = new IntervalPanel(); +fieldPopulationSeasonInterval.add(ip, BorderLayout.CENTER); +ip.addPropertyChangeListener("first", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Month first = getPopulationSeasonInfo().getFirstMonth(); + first.setMonthNumber(ip.getModel().getFirst()); + getPopulationSeasonInfo().setFirstMonth(first); } - public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setFieldPopulationSeasonInfoChooserModel(); - fieldPopulationSeasonComment.setText(pop.getSeasonsComment()); - // Model instanciation - Interval interval = new Interval(); - interval.setMin(0); - interval.setMax(11); - interval.setFirst(0); - interval.setLast(2); - ip.setModel(interval); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldPopulationSeasonInfoChooser.setModel(model); +}); + + ip.addPropertyChangeListener("last", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Month last = getPopulationSeasonInfo().getLastMonth(); + last.setMonthNumber(ip.getModel().getLast()); + getPopulationSeasonInfo().setLastMonth(last); + } +}); + +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldPopulationSeasonComment.setText(""); - // Model instanciation - Interval interval = new Interval(); - interval.setMin(0); - interval.setMax(11); - interval.setFirst(0); - interval.setLast(2); - ip.setModel(interval); } - } - protected void setFieldPopulationSeasonInfoChooserModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - if (pop.getPopulationSeasonInfo() != null){ - java.util.List<PopulationSeasonInfo> popSeasonInfo = pop.getPopulationSeasonInfo(); - for(PopulationSeasonInfo psi : popSeasonInfo){ - GenericCell cell = new GenericCell(psi.getFirstMonth().toString() + " - " + psi.getLastMonth().toString(),psi, PopulationSeasonInfo.class); - model.addElement(cell); - } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldPopulationSeasonInfoChooser.setModel(model); } - protected PopulationSeasonInfo getPopulationSeasonInfo(){ - PopulationSeasonInfo result = null; - Object selected = fieldPopulationSeasonInfoChooser.getSelectedItem(); - if (selected != null){ - GenericCell cellSelected = (GenericCell) selected; - if (cellSelected.getValue() != null){ - result = (PopulationSeasonInfo) cellSelected.getValue(); - } - } - return result; - } - protected void infoChooserChanged(){ - PopulationSeasonInfo selected = getPopulationSeasonInfo(); - if (selected != null){ - fieldPopulationSeasonGroupChange.setSelected(selected.getGroupChange()); - fieldPopulationSeasonReproductionDistribution.setMatrix(selected.getLengthChangeMatrix()); +}); +public void refresh(){ + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + jaxx.runtime.swing.Utils.fillComboBox(fieldPopulationSeasonInfoChooser,getBean().getPopulationSeasonInfo(), null); + // Model instanciation + Interval interval = new Interval(); + interval.setMin(0); + interval.setMax(11); + interval.setFirst(0); + interval.setLast(2); + ip.setModel(interval); + try { + log.debug("************** Interval ************"); + Month firstMonth = getPopulationSeasonInfo().getFirstMonth(); - - Interval interval = new Interval(); - interval.setMin(0); - interval.setMax(11); + if (firstMonth != null) { + interval.setFirst(firstMonth.getMonthNumber()); + log.debug(" first : " + interval.getFirst()); + } else { interval.setFirst(0); - interval.setLast(2); - ip.setModel(interval); - try { - log.debug("************** Interval ************"); - Month firstMonth = selected.getFirstMonth(); + } - if (firstMonth != null) { - interval.setFirst(firstMonth.getMonthNumber()); - log.debug(" first : " + interval.getFirst()); - } else { - interval.setFirst(0); - } - - Month lastMonth = selected.getLastMonth(); - if (lastMonth != null) { - interval.setLast(lastMonth.getMonthNumber()); - log.debug(" last : " + interval.getLast()); - } else { - interval.setLast(3); - } - } catch (Exception e) { - log.error("Unexpected origin.", e); - // Only trace the error and go on. - } - ip.setLabelRenderer(Month.MONTH); - ip.setModel(interval); + Month lastMonth = getPopulationSeasonInfo().getLastMonth(); + if (lastMonth != null) { + interval.setLast(lastMonth.getMonthNumber()); + log.debug(" last : " + interval.getLast()); + } else { + interval.setLast(3); } - valueChanged(true); + } catch (Exception e) { + log.error("Unexpected origin.", e); + // Only trace the error and go on. } - protected void groupChangedChanged(){ - PopulationSeasonInfo selected = getPopulationSeasonInfo(); - if (selected != null){ - selected.setGroupChange(fieldPopulationSeasonGroupChange.isSelected()); - valueChanged(true); - } - } - protected void commentChanged(){ - if (pop != null){ - pop.setSeasonsComment(fieldPopulationSeasonComment.getText()); - valueChanged(true); - } - } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Metier"); - - getParentContainer(InputUI.class).setTreeModel(); - - setInfoText(_("isisfish.message.creation.finished")); - } - 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(); - } - protected void cancel(){ - getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - TopiaEntity species = (TopiaEntity) getContextValue(InputAction.class).getSpecies(); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/" + species.getTopiaId() + "/$populations"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } + ip.setLabelRenderer(Month.MONTH); + ip.setModel(interval); +} ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationSeasons.selectSeason" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldPopulationSeasonInfoChooser" onActionPerformed='infoChooserChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.common.season" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JPanel id='fieldPopulationSeasonInterval' layout='{new BorderLayout()}' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JPanel/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" onActionPerformed='groupChangedChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationSeasons.distributionSpawning" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationSeasonReproductionDistribution' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.populationSeasons.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTextArea id="fieldPopulationSeasonComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> - - - - - - - - - - + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationSeasons.selectSeason" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldPopulationSeasonInfoChooser" onActionPerformed='setPopulationSeasonInfo((PopulationSeasonInfoImpl)fieldPopulationSeasonInfoChooser.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.common.season" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JPanel id='fieldPopulationSeasonInterval' layout='{new BorderLayout()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JPanel/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().getGroupChange()}' + onActionPerformed='getPopulationSeasonInfo().setGroupChange(fieldPopulationSeasonGroupChange.isSelected())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationSeasons.distributionSpawning" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationSeasonReproductionDistribution' matrix='{getPopulationSeasonInfo().getLengthChangeMatrix()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.populationSeasons.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTextArea id="fieldPopulationSeasonComment" text='getBean().getSeasonsComment()' onKeyTyped='getBean().setSeasonsComment(fieldPopulationSeasonComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,105 +35,75 @@ <!-- + Population +--> -<JPanel layout='{new BorderLayout()}' implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> <script><![CDATA[ - import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; - init(); - public PopulationUI (InputAction action){ - setContextValue(action); - } - public void refresh(){ - populationBasicsUI.refresh(); - populationGroupUI.refresh(); - populationEquationUI.refresh(); - populationZoneUI.refresh(); - populationSeasonsUI.refresh(); - populationCapturabilityUI.refresh(); - populationRecruitementUI.refresh(); - 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; - for (String path : paths){ - if (!path.matches("^\\$.+$")){ - if (path.matches("^fr\\.ifremer\\.isisfish\\.entities\\.Species\\#.+$")){ - topiaId = path; - } - } - } - if (topiaId != null){ - getContextValue(InputAction.class).setSpecies(topiaId); - } - } - protected void goToGear(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$gears"); - } +setType("Population"); +setButtonTitle("isisfish.input.continueGears"); +setNextPath("$root/$gears"); + +public void refresh(){ + populationBasicsUI.refresh(); + populationGroupUI.refresh(); + populationEquationUI.refresh(); + populationZoneUI.refresh(); + populationSeasonsUI.refresh(); + populationCapturabilityUI.refresh(); + populationRecruitementUI.refresh(); + populationMigrationUI.refresh(); +// setSpecies(); +} +// protected void setSpecies(){ +// String[] paths = getContextValue(InputAction.class).getPath().split("/"); +// String topiaId = null; +// for (String path : paths){ +// if (!path.matches("^\\$.+$")){ +// if (path.matches("^fr\\.ifremer\\.isisfish\\.entities\\.Species\\#.+$")){ +// topiaId = path; +// } +// } +// } +// if (topiaId != null){ +// getContextValue(InputAction.class).setSpecies(topiaId); +// } +// } ]]> </script> - <JTabbedPane id="PopulationTab" name="Populations" constraints='BorderLayout.CENTER'> - <tab title='{_("isisfish.populationBasics.title")}'> - <PopulationBasicsUI id='populationBasicsUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationGroup.title")}'> - <PopulationGroupUI id='populationGroupUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationEquation.title")}'> - <PopulationEquationUI id='populationEquationUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationZones.title")}'> - <PopulationZonesUI id='populationZoneUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationSeasons.title")}'> - <PopulationSeasonsUI id='populationSeasonsUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationCapturability.title")}'> - <PopulationCapturabilityUI id='populationCapturabilityUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationRecruitment.title")}'> - <PopulationRecruitmentUI id='populationRecruitementUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - <tab title='{_("isisfish.populationMigration.title")}'> - <PopulationMigrationUI id='populationMigrationUI' constructorParams='getContextValue(InputAction.class)'/> - </tab> - </JTabbedPane> - <JButton text="isisfish.input.continueGears" constraints='BorderLayout.SOUTH' onActionPerformed='goToGear()'/> -</JPanel> \ No newline at end of file + <JPanel id='body' layout='{new BorderLayout()}'> + <JTabbedPane id="populationTab" name="Populations" constraints='BorderLayout.CENTER'> + <tab title='{_("isisfish.populationBasics.title")}'> + <PopulationBasicsUI id='populationBasicsUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationGroup.title")}'> + <PopulationGroupUI id='populationGroupUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationEquation.title")}'> + <PopulationEquationUI id='populationEquationUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationZones.title")}'> + <PopulationZonesUI id='populationZoneUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationSeasons.title")}'> + <PopulationSeasonsUI id='populationSeasonsUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationCapturability.title")}'> + <PopulationCapturabilityUI id='populationCapturabilityUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationRecruitment.title")}'> + <PopulationRecruitmentUI id='populationRecruitementUI' constructorParams='this'/> + </tab> + <tab title='{_("isisfish.populationMigration.title")}'> + <PopulationMigrationUI id='populationMigrationUI' constructorParams='this'/> + </tab> + </JTabbedPane> + <!--JButton text="isisfish.input.continueGears" constraints='BorderLayout.SOUTH' onActionPerformed='goToGear()'/--> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,75 +31,73 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import jaxx.runtime.swing.JAXXList; - import fr.ifremer.isisfish.entities.Zone; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.entities.Population; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.math.matrix.gui.MatrixPanelEvent; - import org.codelutin.math.matrix.gui.MatrixPanelListener; +import jaxx.runtime.swing.JAXXList; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationImpl; +import org.codelutin.topia.persistence.TopiaEntity; +import fr.ifremer.isisfish.ui.WelcomePanelUI; +import org.codelutin.math.matrix.gui.MatrixPanelEvent; +import org.codelutin.math.matrix.gui.MatrixPanelListener; - protected Population pop = null; - public PopulationZonesUI (InputAction action){ - - setContextValue(action); +setType("Population"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } +}); public void refresh(){ - pop = getContextValue(InputAction.class).getPopulation(); - if (pop != null){ - setPopulationZonesPresenceModel(); - setFieldPopulationZonesReproductionModel(); - setFieldPopulationZonesRecruitmentModel(); - setFieldPopulationMappingZoneReproZoneRecru(); - fieldPopulationMappingZoneReproZoneRecru.addMatrixListener(new MatrixPanelListener() { + Population population = (Population)getVerifier().getEntity(Population.class); + setBean((PopulationImpl) population); + setPopulationZonesPresenceModel(); + setFieldPopulationZonesReproductionModel(); + setFieldPopulationZonesRecruitmentModel(); + setFieldPopulationMappingZoneReproZoneRecru(); + fieldPopulationMappingZoneReproZoneRecru.addMatrixListener(new MatrixPanelListener() { - @Override - public void matrixChanged(MatrixPanelEvent arg0) { - fieldPopulationMappingZoneReproZoneRecruChanged(); - } - }); - valueChanged(false); - } - else{ - DefaultListModel model = new DefaultListModel(); - fieldPopulationZonesRecruitment.setModel(model); - populationZonesPresence.setModel(model); - fieldPopulationZonesReproduction.setModel(model); - fieldPopulationMappingZoneReproZoneRecru.setMatrix(null); - valueChanged(false); - } + @Override + public void matrixChanged(MatrixPanelEvent arg0) { + fieldPopulationMappingZoneReproZoneRecruChanged(); + } + }); } protected void fieldPopulationMappingZoneReproZoneRecruChanged(){ - pop.setMappingZoneReproZoneRecru(fieldPopulationMappingZoneReproZoneRecru.getMatrix()); - valueChanged(true); + getBean().setMappingZoneReproZoneRecru(fieldPopulationMappingZoneReproZoneRecru.getMatrix()); } protected void setFieldPopulationMappingZoneReproZoneRecru(){ - if (pop.getMappingZoneReproZoneRecru() != null){ - fieldPopulationMappingZoneReproZoneRecru.setMatrix(pop.getMappingZoneReproZoneRecru().copy()); + if (getBean().getMappingZoneReproZoneRecru() != null){ + fieldPopulationMappingZoneReproZoneRecru.setMatrix(getBean().getMappingZoneReproZoneRecru().copy()); } } protected void setPopulationZonesPresenceModel(){ - setModel(pop.getPopulationZone(), populationZonesPresence); + setModel(getBean().getPopulationZone(), populationZonesPresence); } protected void setFieldPopulationZonesReproductionModel(){ - setModel(pop.getReproductionZone(), fieldPopulationZonesReproduction); + setModel(getBean().getReproductionZone(), fieldPopulationZonesReproduction); } protected void setFieldPopulationZonesRecruitmentModel(){ - setModel(pop.getRecruitmentZone(), fieldPopulationZonesRecruitment); + setModel(getBean().getRecruitmentZone(), fieldPopulationZonesRecruitment); } protected void setModel(java.util.List<Zone> selected, JAXXList componant){ DefaultListModel model = new DefaultListModel(); - java.util.List<Zone> zones = getContextValue(InputAction.class).getFisheryRegion().getZone(); + java.util.List<Zone> zones = getRegion().getZone(); java.util.List<GenericCell> selectedZones = new ArrayList<GenericCell>(); if (zones != null){ for (Zone z : zones){ @@ -128,22 +126,13 @@ } } protected void presenceChanged(){ - if (pop != null){ - pop.setPopulationZone(getSelectedValue(populationZonesPresence)); - valueChanged(true); - } + getBean().setPopulationZone(getSelectedValue(populationZonesPresence)); } protected void reproductionChanged(){ - if (pop != null){ - pop.setReproductionZone(getSelectedValue(fieldPopulationZonesReproduction)); - valueChanged(true); - } + getBean().setReproductionZone(getSelectedValue(fieldPopulationZonesReproduction)); } protected void recruitementChanged(){ - if (pop != null){ - pop.setRecruitmentZone(getSelectedValue(fieldPopulationZonesRecruitment)); - valueChanged(true); - } + getBean().setRecruitmentZone(getSelectedValue(fieldPopulationZonesRecruitment)); } protected java.util.List<Zone> getSelectedValue(JAXXList componant){ Object[] selected = componant.getSelectedValues(); @@ -158,88 +147,62 @@ } return selectedZone; } - 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(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(PopulationUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } ]]> </script> - <row> - <cell fill='horizontal' weightx='0.3'> - <JLabel text="isisfish.populationZones.selectPopulationAreas" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.3'> - <JLabel text="isisfish.populationZones.selectSpawningAreas" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.3'> - <JLabel text="isisfish.populationZones.selectRecruitmentAreas" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weightx='0.3' weighty='0.5'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="populationZonesPresence" onMouseClicked='presenceChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - <cell fill='both' weightx='0.3' weighty='0.5'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="fieldPopulationZonesReproduction" onMouseClicked='reproductionChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - <cell fill='both' weightx='0.3' weighty='0.5'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="fieldPopulationZonesRecruitment" onMouseClicked='recruitementChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='3' anchor='west'> - <JLabel text="isisfish.populationZones.betweenSpawningRecruitmentAreas" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='3' fill='both' weightx='1.0' weighty='0.5'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationMappingZoneReproZoneRecru' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='3' fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> - - - - - \ No newline at end of file + <Table id='body'> + <row> + <cell fill='horizontal' weightx='0.3'> + <JLabel text="isisfish.populationZones.selectPopulationAreas" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.3'> + <JLabel text="isisfish.populationZones.selectSpawningAreas" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.3'> + <JLabel text="isisfish.populationZones.selectRecruitmentAreas" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weightx='0.3' weighty='0.5'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JList id="populationZonesPresence" onMouseClicked='presenceChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + <cell fill='both' weightx='0.3' weighty='0.5'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JList id="fieldPopulationZonesReproduction" onMouseClicked='reproductionChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + <cell fill='both' weightx='0.3' weighty='0.5'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JList id="fieldPopulationZonesRecruitment" onMouseClicked='recruitementChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='3' anchor='west'> + <JLabel text="isisfish.populationZones.betweenSpawningRecruitmentAreas" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='3' fill='both' weightx='1.0' weighty='0.5'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationMappingZoneReproZoneRecru' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='3' fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,17 +35,16 @@ <!-- + Port +--> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.PortImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ import fr.ifremer.isisfish.entities.Species; import fr.ifremer.isisfish.entities.Port; + import fr.ifremer.isisfish.entities.PortImpl; import fr.ifremer.isisfish.entities.Cell; import fr.ifremer.isisfish.map.IsisMapBean; import fr.ifremer.isisfish.map.OpenMapToolPanel; @@ -57,32 +56,29 @@ import org.codelutin.topia.TopiaException; protected OMToolSet toolSet = new OMToolSet(); - protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); protected OpenMapEvents mapListener = null; - public PortUI (InputAction action){ - - setContextValue(action); - } + public void refresh() { - Port port = getContextValue(InputAction.class).getPort(); - if (port != null){ - fieldPortName.setText(port.getName()); + Port port = (Port)getVerifier().getEntity(Port.class); + setBean((PortImpl) port); + if (getBean() != null){ + fieldPortName.setText(getBean().getName()); DefaultListModel portCellModel = new DefaultListModel(); - java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); + java.util.List<Cell> cells = getRegion().getCell(); for (Cell c : cells){ portCellModel.addElement(c); } portCell.setModel(portCellModel); - portCell.setSelectedValue(port.getCell()); + portCell.setSelectedValue(getBean().getCell()); - fieldPortComment.setText(getContextValue(InputAction.class).getPort().getComment()); + fieldPortComment.setText(getBean().getComment()); } else{ fieldPortName.setText(""); DefaultListModel portCellModel = new DefaultListModel(); - java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); + java.util.List<Cell> cells = getRegion().getCell(); for (Cell c : cells){ portCellModel.addElement(c); } @@ -92,13 +88,12 @@ } - portMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); + portMap.setFisheryRegion(getRegion()); if(mapListener == null){ portMap.setSelectionMode(CellSelectionLayer.SINGLE_SELECTION); portMap.setActiveMouseMode(new SelectMouseMode()); toolSet.setupListeners(portMap); toolMap.add((Component)toolSet); - map.add(toolMap, BorderLayout.NORTH); setMapListener(); } refreshMap(); @@ -115,139 +110,91 @@ @Override public boolean onMouseClicked() { for (Cell c : portMap.getSelectedCells()){ - Port port = getContextValue(InputAction.class).getPort(); - if (port != null){ - port.setCell(c); + if (getBean() != null){ + getBean().setCell(c); } } - valueChanged(true); refresh(); return true; } }; } } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Port"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$ports/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$ports/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$ports"); - valueChanged(false); - refresh(); - } - protected void goToSpecies(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$species"); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - changed=b; - save.setEnabled(b); - cancel.setEnabled(b); - } protected void nameChanged(){ - getContextValue(InputAction.class).getPort().setName(fieldPortName.getText()); - valueChanged(true); + getBean().setName(fieldPortName.getText()); } protected void portCellChanged(){ - getContextValue(InputAction.class).getPort().setCell((Cell)portCell.getSelectedValue()); - valueChanged(true); + getBean().setCell((Cell)portCell.getSelectedValue()); } protected void commentChanged(){ - getContextValue(InputAction.class).getPort().setComment(fieldPortComment.getText()); - valueChanged(true); + getBean().setComment(fieldPortComment.getText()); } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JSplitPane id="PortTab" name="Ports" - oneTouchExpandable="true" dividerLocation="270" orientation="horizontal"> - <Table> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' > - <JLabel text="isisfish.port.name" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' > - <JTextField id="fieldPortName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' > - <JLabel text="isisfish.port.cell" enabled='{isActif()}'/> - - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> - <JScrollPane> - <JList id="portCell" selectionMode="0" onMouseClicked='portCellChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel text="isisfish.port.comments" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.3' weightx='1.0' > - <JScrollPane> - <JTextArea id="fieldPortComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - <JPanel id='map' layout='{new BorderLayout()}'> - <fr.ifremer.isisfish.map.IsisMapBean id='portMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' constraints='BorderLayout.CENTER'/> - </JPanel> - </JSplitPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueSpecies" onActionPerformed='goToSpecies()'/> - </cell> - </row> -</Table> - \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JSplitPane id="PortTab" name="Ports" + oneTouchExpandable="true" dividerLocation="270" orientation="horizontal"> + <Table> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' > + <JLabel text="isisfish.port.name" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' > + <JTextField id="fieldPortName" onKeyTyped='nameChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' > + <JLabel text="isisfish.port.cell" enabled='{isActif()}'/> + + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> + <JScrollPane> + <JList id="portCell" selectionMode="0" onMouseClicked='portCellChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel text="isisfish.port.comments" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.3' weightx='1.0' > + <JScrollPane> + <JTextArea id="fieldPortComment" onKeyTyped='commentChanged()' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='remove' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + <JPanel id='map' layout='{new BorderLayout()}'> + <fr.ifremer.isisfish.map.OpenMapToolPanel id='toolMap' javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' constraints='BorderLayout.NORTH'/> + <fr.ifremer.isisfish.map.IsisMapBean id='portMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' constraints='BorderLayout.CENTER'/> + </JPanel> + </JSplitPane> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -30,13 +30,11 @@ * by : $Author: sletellier $ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.GearImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script> <![CDATA[ @@ -48,20 +46,24 @@ import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; import javax.swing.table.DefaultTableModel; import fr.ifremer.isisfish.entities.Selectivity; + import fr.ifremer.isisfish.entities.GearImpl; import fr.ifremer.isisfish.entities.Equation; import java.util.logging.Level; import java.util.logging.Logger; + import org.codelutin.topia.TopiaContext; import org.codelutin.topia.persistence.TopiaEntity; import fr.ifremer.isisfish.ui.widget.editor.GenericCell; + import fr.ifremer.isisfish.entities.Metier; + import fr.ifremer.isisfish.entities.MetierImpl; - public SelectivityUI (InputAction action){ - - setContextValue(action); - } public void refresh(){ + InputAction action = getAction(); + setBean(null); + Gear gear = (Gear)getVerifier().getEntity(Gear.class); + setBean((GearImpl) gear); fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); fieldSelectivityEquation.setModel(getSelectivityEquationModel()); - if (getContextValue(InputAction.class).getGear() != null){ + if (getBean() != null){ setSelectivityTableModel(); } else{ @@ -85,7 +87,7 @@ return result; } }; - Collection<Selectivity> selectivity = getContextValue(InputAction.class).getGear().getPopulationSelectivity(); + Collection<Selectivity> selectivity = getBean().getPopulationSelectivity(); java.util.List<Population> populations = new ArrayList<Population>(); java.util.List<Equation> equations = new ArrayList<Equation>(); if (selectivity != null){ @@ -102,7 +104,7 @@ selectivityTable.getColumnModel().getColumn(1).setCellEditor(cellEditor); } protected DefaultComboBoxModel getSelectivityPopulationModel(){ - java.util.List<Species> species = getContextValue(InputAction.class).getFisheryRegion().getSpecies(); + java.util.List<Species> species = getRegion().getSpecies(); DefaultComboBoxModel selectivityPopulationModel = new DefaultComboBoxModel(); if (species != null){ selectivityPopulationModel.addElement(new GenericCell(" ", null, null)); @@ -117,7 +119,7 @@ return selectivityPopulationModel; } protected DefaultComboBoxModel getSelectivityEquationModel(){ - java.util.List<Formule> formules = fr.ifremer.isisfish.datastore.FormuleStorage.getFormules(getContextValue(InputAction.class).getIsisContext(), "Selectivity"); + java.util.List<Formule> formules = fr.ifremer.isisfish.datastore.FormuleStorage.getFormules(getContextValue(TopiaContext.class), "Selectivity"); DefaultComboBoxModel selectivityEquationModel = new DefaultComboBoxModel(); if (formules != null){ selectivityEquationModel.addElement(new GenericCell(" ", null, null)); @@ -129,42 +131,21 @@ return selectivityEquationModel; } protected void saveAsModel(){ - getContextValue(InputAction.class).saveAsModel("Selectivity", "Java", fieldSelectivityScript.getText()); - refresh(); + getAction().saveAsModel("SelectivityEquation", "Java", fieldSelectivityScript.getText()); + fieldSelectivityEquation.setModel(getSelectivityEquationModel()); setInfoText(_("isisfish.message.saveModel.finished")); } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } protected void openEditor(){ - getContextValue(InputAction.class).openEditor("Selectivity", "new", fr.ifremer.isisfish.equation.SelectivityEquation.class, fieldSelectivityScript.getText(), fieldSelectivityScript); + getAction().openEditor("SelectivityEquation", "new", fr.ifremer.isisfish.equation.SelectivityEquation.class, fieldSelectivityScript.getText(), fieldSelectivityScript); } protected void add(){ - getContextValue(InputAction.class).addSelectivity((Population) ((GenericCell) fieldSelectivityPopulation.getSelectedItem()).getValue(), fieldSelectivityScript.getText()); - valueChanged(true); + getAction().addSelectivity((Population) ((GenericCell) fieldSelectivityPopulation.getSelectedItem()).getValue(), fieldSelectivityScript.getText(), getBean()); refresh(); } protected void remove(){ - getContextValue(InputAction.class).removeSelectivity((Selectivity) getContextValue(InputAction.class).getGear().getPopulationSelectivity((Population) selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0))); + getAction().removeSelectivity(getBean(), (Selectivity) getBean().getPopulationSelectivity((Population) selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0))); refresh(); } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$gears/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void valueChanged(boolean b){ - getParentContainer(GearUI.class).setChanged(b); - } protected void equationChanged(){ GenericCell g = (GenericCell)fieldSelectivityEquation.getSelectedItem(); if (g.getValue() != null){ @@ -180,83 +161,85 @@ } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSelectivityPopulation" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.selectivity.equation" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSelectivityEquation" onActionPerformed='equationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal'> - <JButton id='saveModel' text="isisfish.common.saveModel" onActionPerformed='saveAsModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton id='openEditor' text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <org.codelutin.widget.editor.Editor id='fieldSelectivityScript' askIfNotSaved="false" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonAddSelectivity" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTable id="selectivityTable" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonSelectivityRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <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='{isChanged()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSelectivityPopulation" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.selectivity.equation" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSelectivityEquation" onActionPerformed='equationChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <Table> + <row> + <cell fill='horizontal'> + <JButton id='saveModel' text="isisfish.common.saveModel" onActionPerformed='saveAsModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton id='openEditor' text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <org.codelutin.widget.editor.Editor id='fieldSelectivityScript' askIfNotSaved="false" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="buttonAddSelectivity" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTable id="selectivityTable" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="buttonSelectivityRemove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsTabsUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,189 +31,58 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.SetOfVesselsImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import org.codelutin.topia.TopiaException; - import fr.ifremer.isisfish.entities.Port; - import fr.ifremer.isisfish.entities.Equation; - import fr.ifremer.isisfish.entities.VesselType; - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import java.util.logging.Level; - import java.util.logging.Logger; +import org.codelutin.topia.TopiaException; +import fr.ifremer.isisfish.entities.Port; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.VesselType; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.SetOfVessels; +import fr.ifremer.isisfish.entities.SetOfVesselsImpl; +import java.util.logging.Level; +import java.util.logging.Logger; - public SetOfVesselsTabsUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - fr.ifremer.isisfish.entities.SetOfVessels setOfVessels = getContextValue(InputAction.class).getSetOfVessels(); - if (setOfVessels != null){ - fieldSetOfVesselsName.setText(setOfVessels.getName()); - setFieldSetOfVesselsPortModel(setOfVessels); - setFieldSetOfVesselsVesselTypeModel(setOfVessels); - fieldSetOfVesselsNumberOfVessels.setText(setOfVessels.getNumberOfVessels() + ""); - fieldSetOfVesselsFixedCosts.setText(setOfVessels.getFixedCosts() + ""); - setFieldSetOfVesselsTechnicalEfficiencyModel(setOfVessels); - fieldSetOfVesselsComment.setText(setOfVessels.getComment()); - } - else{ +setType("SetOfVessels"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); fieldSetOfVesselsName.setText(""); - setFieldSetOfVesselsPortModel(null); - setFieldSetOfVesselsVesselTypeModel(null); fieldSetOfVesselsNumberOfVessels.setText(""); fieldSetOfVesselsFixedCosts.setText(""); - setFieldSetOfVesselsTechnicalEfficiencyModel(null); fieldSetOfVesselsComment.setText(""); } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } + } +}); + public void refresh() { + SetOfVessels setOfVessels = (SetOfVessels)getVerifier().getEntity(SetOfVessels.class); + setBean((SetOfVesselsImpl) setOfVessels); + jaxx.runtime.swing.Utils.fillComboBox(fieldSetOfVesselsPort,getRegion().getPort(), getBean().getPort()); + jaxx.runtime.swing.Utils.fillComboBox(fieldSetOfVesselsVesselType,getRegion().getVesselType(), getBean().getVesselType()); + jaxx.runtime.swing.Utils.fillComboBox(fieldSetOfVesselsTechnicalEfficiency,getAction().getFormules(getBean().getTopiaContext(),"TechnicalEfficiency"), getBean().getTechnicalEfficiencyEquation()); try { editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); } catch (IOException ex) { Logger.getLogger(SelectivityUI.class.getName()).log(Level.SEVERE, null, ex); } } - protected void setFieldSetOfVesselsPortModel(fr.ifremer.isisfish.entities.SetOfVessels setOfVessels){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Port> ports = getContextValue(InputAction.class).getFisheryRegion().getPort(); - GenericCell selectedCell = null; - for (Port p : ports){ - GenericCell cell = new GenericCell(p.getName(), p, Port.class); - model.addElement(cell); - if (setOfVessels != null){ - if (setOfVessels.getPort() != null){ - if (p.getName().equals(setOfVessels.getPort().getName())){ - selectedCell = cell; - } - } - } - } - fieldSetOfVesselsPort.setModel(model); - if (selectedCell != null){ - fieldSetOfVesselsPort.setSelectedItem(selectedCell); - } - } - protected void setFieldSetOfVesselsVesselTypeModel(fr.ifremer.isisfish.entities.SetOfVessels setOfVessels){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<VesselType> vesselTypes = getContextValue(InputAction.class).getFisheryRegion().getVesselType(); - GenericCell selectedCell = null; - for (VesselType v : vesselTypes){ - GenericCell cell = new GenericCell(v.getName(), v, VesselType.class); - model.addElement(cell); - if (setOfVessels != null){ - if (setOfVessels.getVesselType() != null){ - if (v.getName().equals(setOfVessels.getVesselType().getName())){ - selectedCell = cell; - } - } - } - } - fieldSetOfVesselsVesselType.setModel(model); - if (selectedCell != null){ - fieldSetOfVesselsVesselType.setSelectedItem(selectedCell); - } - } - protected void setFieldSetOfVesselsTechnicalEfficiencyModel(fr.ifremer.isisfish.entities.SetOfVessels setOfVessels){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<Formule> formule = getContextValue(InputAction.class).getFormules("TechnicalEfficiency"); - String formuleSelectedName = null; - GenericCell selectedCell = null; - for (Formule f : formule){ - GenericCell cell = new GenericCell(f.getName(), f, Formule.class); - model.addElement(cell); - if(setOfVessels != null){ - if (setOfVessels.getTechnicalEfficiencyEquation() != null){ - if (f.getName().equals(formuleSelectedName)){ - selectedCell = cell; - } - } - } - } - fieldSetOfVesselsTechnicalEfficiency.setModel(model); - if(selectedCell != null){ - fieldSetOfVesselsTechnicalEfficiency.setSelectedItem(selectedCell); - } - } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("SetOfVessels"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$setOfVessels/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$setOfVessels"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(SetOfVesselsUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } - protected void nameChanged(){ - getContextValue(InputAction.class).getSetOfVessels().setName(fieldSetOfVesselsName.getText()); - } - protected void portChanged(){ - Object value = fieldSetOfVesselsPort.getSelectedItem(); - if (value != null){ - GenericCell cell = (GenericCell) value; - if (cell.getValue() != null){ - getContextValue(InputAction.class).getSetOfVessels().setPort((Port)cell.getValue()); - } - } - } - protected void vesselTypeChanged(){ - Object value = fieldSetOfVesselsVesselType.getSelectedItem(); - if (value != null){ - GenericCell cell = (GenericCell) value; - if (cell.getValue() != null){ - getContextValue(InputAction.class).getSetOfVessels().setVesselType((VesselType)cell.getValue()); - } - } - } - protected void numberOfVesselsChanged(){ - getContextValue(InputAction.class).getSetOfVessels().setNumberOfVessels(Integer.parseInt(fieldSetOfVesselsNumberOfVessels.getText())); - } - protected void fixedCostsChanged(){ - getContextValue(InputAction.class).getSetOfVessels().setFixedCosts(Double.parseDouble(fieldSetOfVesselsFixedCosts.getText())); - } protected void technicalEfficiencyChanged(){ - GenericCell g = (GenericCell)fieldSetOfVesselsTechnicalEfficiency.getSelectedItem(); - if (g != null){ - if (g.getValue() != null){ - editor.setText(((Formule)g.getValue()).getContent()); - fr.ifremer.isisfish.entities.SetOfVessels setOfVessels = getContextValue(InputAction.class).getSetOfVessels(); - setOfVessels.setTechnicalEfficiencyEquation((Equation)g.getValue()); - } + if (fieldSetOfVesselsTechnicalEfficiency.getSelectedItem() != null){ + editor.setText(((Formule)fieldSetOfVesselsTechnicalEfficiency.getSelectedItem()).getContent()); + getBean().setTechnicalEfficiencyEquation((Equation)fieldSetOfVesselsTechnicalEfficiency.getSelectedItem()); } else{ try { @@ -223,130 +92,127 @@ } } } - protected void commentChanged(){ - getContextValue(InputAction.class).getSetOfVessels().setComment(fieldSetOfVesselsComment.getText()); - } protected void saveAsModel(){ -// GenericCell g = (GenericCell)fieldSetOfVesselsTechnicalEfficiency.getSelectedItem(); -// getContextValue(InputAction.class).saveEquationAsModel((Equation)g.getValue()); - getContextValue(InputAction.class).saveAsModel("SetOfVessels", "Java", editor.getText()); + getContextValue(InputAction.class).saveAsModel("SoVTechnicalEfficiencyEquation", "Java", editor.getText()); setInfoText(_("isisfish.message.saveModel.finished")); } protected void openEditor(){ - getContextValue(InputAction.class).openEditor("SetOfVessels","new",fr.ifremer.isisfish.equation.SoVTechnicalEfficiencyEquation.class, editor.getText(), editor); + getContextValue(InputAction.class).openEditor("SoVTechnicalEfficiencyEquation","new",fr.ifremer.isisfish.equation.SoVTechnicalEfficiencyEquation.class, editor.getText(), editor); } ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldSetOfVesselsName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.common.port" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSetOfVesselsPort" onActionPerformed='portChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.vesselType" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSetOfVesselsVesselType" onActionPerformed='vesselTypeChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.numberOfVessels" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldSetOfVesselsNumberOfVessels" onKeyTyped='valueChanged(true)' onFocusLost='numberOfVesselsChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.fixedCosts" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldSetOfVesselsFixedCosts" onKeyTyped='valueChanged(true)' onFocusLost='fixedCostsChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.technicalEfficiency" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSetOfVesselsTechnicalEfficiency" onActionPerformed='technicalEfficiencyChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='0.7'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveAsModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='0.7'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - <row> - <cell anchor='east'> - <JLabel text="isisfish.setOfVessels.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.3'> - <JScrollPane> - <JTextArea id="fieldSetOfVesselsComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='1.0'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldSetOfVesselsName" text='getBean().getName()' onKeyTyped='getBean().setName(fieldSetOfVesselsName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.common.port" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSetOfVesselsPort" onActionPerformed='getBean().setPort((Port)fieldSetOfVesselsPort.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.vesselType" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSetOfVesselsVesselType" onActionPerformed='getBean().setVesselType((VesselType)fieldSetOfVesselsVesselType.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.numberOfVessels" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldSetOfVesselsNumberOfVessels" text='getBean().getNumberOfVessels()' onKeyTyped='getBean().setNumberOfVessels(Integer.parseInt(fieldSetOfVesselsNumberOfVessels.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.fixedCosts" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldSetOfVesselsFixedCosts" text='getBean().getFixedCosts()' onKeyTyped='getBean().setFixedCosts(Double.parseDouble(fieldSetOfVesselsFixedCosts.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.technicalEfficiency" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSetOfVesselsTechnicalEfficiency" onActionPerformed='technicalEfficiencyChanged()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='0.7'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveAsModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='0.7'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text="isisfish.setOfVessels.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.3'> + <JScrollPane> + <JTextArea id="fieldSetOfVesselsComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldSetOfVesselsComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SetOfVesselsUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,47 +35,22 @@ <!-- + SetOfVessels +--> -<JPanel implements='InputContent' layout='{new BorderLayout()}'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Strategy; - init(); - public SetOfVesselsUI (InputAction action){ - - setContextValue(action); - } - 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"); - } + +setType("SetOfVessels"); +setButtonTitle("isisfish.input.continueStrategies"); +setNextPath("$root/$strategies"); +public void refresh() { + setOfVesselsTabsUI.refresh(); + effortDescriptionUI.refresh(); +} ]]></script> - <JTabbedPane id="SetOfVesselsTab" name="SetOfVessels" constraints='BorderLayout.CENTER'> - <tab title='{_("isisfish.setOfVessels.title")}'><SetOfVesselsTabsUI id='setOfVesselsTabsUI' constructorParams='getContextValue(InputAction.class)'/></tab> - <tab title='{_("isisfish.effortDescription.title")}'><EffortDescriptionUI id='effortDescriptionUI' constructorParams='getContextValue(InputAction.class)'/></tab> - </JTabbedPane> - <JButton text="isisfish.input.continueStrategies" constraints='BorderLayout.SOUTH' onActionPerformed='goToStrategies()'/> -</JPanel> + <JPanel id='body' layout='{new BorderLayout()}'> + <JTabbedPane id="SetOfVesselsTab" name="SetOfVessels" constraints='BorderLayout.CENTER'> + <tab title='{_("isisfish.setOfVessels.title")}'><SetOfVesselsTabsUI id='setOfVesselsTabsUI' constructorParams='this'/></tab> + <tab title='{_("isisfish.effortDescription.title")}'><EffortDescriptionUI id='effortDescriptionUI' constructorParams='this'/></tab> + </JTabbedPane> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,195 +35,122 @@ <!-- + Species +--> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.SpeciesImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Population; - import fr.ifremer.isisfish.entities.Species; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import org.codelutin.topia.TopiaException; - - public SpeciesUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - Species s = getContextValue(InputAction.class).getSpecies(); - if (s != null){ - fieldSpeciesName.setText(s.getName()); - fieldSpeciesScientificName.setText(s.getScientificName()); - fieldSpeciesCodeRubbin.setText(s.getCodeRubbin()); - fieldSpeciesCEE.setText(s.getCodeCEE() + ""); - fieldSpeciesDynamicAge.setSelected(s.getAgeGroupType()); - fieldSpeciesDynamicLength.setSelected(!s.getAgeGroupType()); - fieldSpeciesComment.setText(s.getComment()); - goToPopulation.setEnabled(true); - } - else{ +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.entities.SpeciesImpl; + +setType("Species"); +setButtonTitle("isisfish.input.continuePopulations"); +setNextPath("$root/$species/" + getBean().getTopiaId() + "/$population"); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldSpeciesName.setText(""); fieldSpeciesScientificName.setText(""); fieldSpeciesCodeRubbin.setText(""); fieldSpeciesCEE.setText(""); fieldSpeciesComment.setText(""); - goToPopulation.setEnabled(false); } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Species"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$species/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species"); - refresh(); - } - protected void goToPopulation(){ - Species s = getContextValue(InputAction.class).getSpecies(); - getParentContainer(InputUI.class).setTreeSelection("$root/$species/"+ s.getTopiaId() +"/$populations"); - } - protected void valueChanged(boolean b){ - changed=b; - save.setEnabled(b); - cancel.setEnabled(b); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void commentChanged(){ - getContextValue(InputAction.class).getSpecies().setComment(fieldSpeciesComment.getText()); - valueChanged(true); - } - protected void dynamicAgeChanged(){ - getContextValue(InputAction.class).getSpecies().setAgeGroupType(fieldSpeciesDynamicAge.isSelected()); - valueChanged(true); - } - protected void CEEChanged(){ - getContextValue(InputAction.class).getSpecies().setCodeCEE(Integer.parseInt(fieldSpeciesCEE.getText())); - valueChanged(true); - } - protected void codeChanged(){ - getContextValue(InputAction.class).getSpecies().setCodeRubbin(fieldSpeciesCodeRubbin.getText()); - valueChanged(true); - } - protected void scientificNameChanged(){ - getContextValue(InputAction.class).getSpecies().setScientificName(fieldSpeciesScientificName.getText()); - valueChanged(true); - } - protected void nameChanged(){ - getContextValue(InputAction.class).getSpecies().setName(fieldSpeciesName.getText()); - valueChanged(true); - } +}); +public void refresh() { + Species species = (Species)getVerifier().getEntity(Species.class); + setBean((SpeciesImpl) species); +} ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell> - <JLabel text="isisfish.species.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.species.scientificName" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesScientificName" onKeyTyped='valueChanged(true)' onFocusLost='scientificNameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.species.rubbinCode" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesCodeRubbin" onKeyTyped='valueChanged(true)' onFocusLost='codeChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.species.cee" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesCEE" onKeyTyped='valueChanged(true)' onFocusLost='CEEChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.species.structured" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" buttonGroup="structuredGroup" onItemStateChanged='dynamicAgeChanged()' enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" buttonGroup="structuredGroup" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.species.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' columns='2' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTextArea id="fieldSpeciesComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id='goToPopulation' text="isisfish.input.continuePopulations" enabled='false' onActionPerformed='goToPopulation()'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell> + <JLabel text="isisfish.species.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' columns='2' weightx='1.0'> + <JTextField id="fieldSpeciesName" text='getBean().getName()' onKeyTyped='getBean().setName(fieldSpeciesName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.species.scientificName" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' columns='2' weightx='1.0'> + <JTextField id="fieldSpeciesScientificName" text='getBean().getScientificName()' onKeyTyped='getBean().setScientificName(fieldSpeciesScientificName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.species.rubbinCode" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' columns='2' weightx='1.0'> + <JTextField id="fieldSpeciesCodeRubbin" text='getBean().getCodeRubbin()' onKeyTyped='getBean().setCodeRubbin(fieldSpeciesCodeRubbin.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.species.cee" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' columns='2' weightx='1.0'> + <JTextField id="fieldSpeciesCEE" text='getBean().getCodeCEE()' onKeyTyped='getBean().setCodeCEE(Integer.parseInt(fieldSpeciesCEE.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.species.structured" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().getAgeGroupType()}' buttonGroup="structuredGroup" onItemStateChanged='getBean().setAgeGroupType(fieldSpeciesDynamicAge.isSelected())' enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().getAgeGroupType()}' buttonGroup="structuredGroup" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.species.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' columns='2' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTextArea id="fieldSpeciesComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldSpeciesComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyMonthInfoUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,167 +31,101 @@ */ --> -<JPanel layout='{new BorderLayout()}' implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.StrategyMonthInfo; - import fr.ifremer.isisfish.types.Month; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; +import fr.ifremer.isisfish.types.Month; - init(); - public StrategyMonthInfoUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - strategyJanuary.init(Month.JANUARY); - strategyFebuary.init(Month.FEBRUARY); - strategyMarch.init(Month.MARCH); - strategyApril.init(Month.APRIL); - strategyMay.init(Month.MAY); - strategyJune.init(Month.JUNE); - strategyJuly.init(Month.JULY); - strategyAugust.init(Month.AUGUST); - strategySeptember.init(Month.SEPTEMBER); - strategyOctober.init(Month.OCTOBER); - strategyNovember.init(Month.NOVEMBER); - strategyDecember.init(Month.DECEMBER); - strategyJanuary.refresh(); - strategyFebuary.refresh(); - strategyMarch.refresh(); - strategyApril.refresh(); - strategyMay.refresh(); - strategyJune.refresh(); - strategyJuly.refresh(); - strategyAugust.refresh(); - strategySeptember.refresh(); - strategyOctober.refresh(); - 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(); - 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(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - public void valueChanged(boolean b){ - getParentContainer(StrategyUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } +setType("Population"); +setButtonTitle(""); +setNextPath(null); +public void refresh() { + strategyJanuary.init(Month.JANUARY); + strategyFebuary.init(Month.FEBRUARY); + strategyMarch.init(Month.MARCH); + strategyApril.init(Month.APRIL); + strategyMay.init(Month.MAY); + strategyJune.init(Month.JUNE); + strategyJuly.init(Month.JULY); + strategyAugust.init(Month.AUGUST); + strategySeptember.init(Month.SEPTEMBER); + strategyOctober.init(Month.OCTOBER); + strategyNovember.init(Month.NOVEMBER); + strategyDecember.init(Month.DECEMBER); + strategyJanuary.refresh(); + strategyFebuary.refresh(); + strategyMarch.refresh(); + strategyApril.refresh(); + strategyMay.refresh(); + strategyJune.refresh(); + strategyJuly.refresh(); + strategyAugust.refresh(); + strategySeptember.refresh(); + strategyOctober.refresh(); + strategyNovember.refresh(); + strategyDecember.refresh(); +} ]]></script> - <Table constraints='BorderLayout.CENTER'> - <row> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyJanuary' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyFebuary' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyMarch' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyApril' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyMay' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyJune' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyJuly' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyAugust' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - <row> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategySeptember' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyOctober' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyNovember' constructorParams='getContextValue(InputAction.class)'/> - </cell> - <cell fill='both' weightx='0.25' weighty='0.3'> - <StrategyOneMonthInfoUI id='strategyDecember' constructorParams='getContextValue(InputAction.class)'/> - </cell> - </row> - </Table> + <JPanel id='body'> + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyJanuary' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyFebuary' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyMarch' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyApril' constructorParams='this'/> + </cell> + </row> + <row> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyMay' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyJune' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyJuly' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyAugust' constructorParams='this'/> + </cell> + </row> + <row> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategySeptember' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyOctober' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyNovember' constructorParams='this'/> + </cell> + <cell fill='both' weightx='0.25' weighty='0.3'> + <StrategyOneMonthInfoUI id='strategyDecember' constructorParams='this'/> + </cell> + </row> + </Table> - <!-- - | - | Button action - | - +--> - <Table constraints='BorderLayout.SOUTH'> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='save' enabled='{isChanged()}' text="isisfish.common.save" onActionPerformed='save()'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' enabled='{isChanged()}' text="isisfish.common.cancel" onActionPerformed='cancel()'/> - </cell> - </row> - </Table> -</JPanel> \ No newline at end of file + <!-- + | + | Button action + | + +--> + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + </Table> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,136 +31,94 @@ */ --> -<Table implements='InputContent'> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <Boolean id='changed' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.StrategyImpl id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.StrategyMonthInfoImpl id='strategyMonthInfo' javaBean='null'/> + <script><![CDATA[ - import fr.ifremer.isisfish.entities.StrategyMonthInfo; - import fr.ifremer.isisfish.entities.Strategy; - import fr.ifremer.isisfish.types.Month; - import fr.ifremer.isisfish.entities.TripType; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import fr.ifremer.isisfish.entities.StrategyMonthInfo; +import fr.ifremer.isisfish.entities.StrategyMonthInfoImpl; +import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.entities.StrategyImpl; +import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - protected StrategyMonthInfo strategyMonthInfo = null; - Month month = null; - PropertyChangeListener listener = null; - - public StrategyOneMonthInfoUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - Strategy strategy = getContextValue(InputAction.class).getStrategy(); - if (strategy != null && month != null){ - strategyMonthInfo = strategy.getStrategyMonthInfo(month); - setFieldStrategyMonthInfoTripTypeModel(); - numberOfTrips.setText(strategyMonthInfo.getNumberOfTrips() + ""); - fieldStrategyMonthInfoMinInactivityDays.setText(strategyMonthInfo.getMinInactivityDays() + ""); - setFieldStrategyMonthInfoProportionModel(); - valueChanged(false); - } - else{ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - fieldStrategyMonthInfoTripType.setModel(model); +Month month = null; +PropertyChangeListener listener = null; + +setType("Strategy"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); numberOfTrips.setText(""); fieldStrategyMonthInfoMinInactivityDays.setText(""); fieldStrategyMonthInfoProportion.setMatrix(null); - valueChanged(false); } - } - public void init(Month m){ - month = m; - } - protected void setFieldStrategyMonthInfoTripTypeModel(){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - TripType selected = strategyMonthInfo.getTripType(); - GenericCell cellSelected = null; - for (TripType t : getContextValue(InputAction.class).getFisheryRegion().getTripType()){ - GenericCell g = new GenericCell(t.getName(),t,TripType.class); - model.addElement(g); - if (selected != null){ - if (t.getName().equals(selected.getName())){ - cellSelected = g; - } - } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - fieldStrategyMonthInfoTripType.setModel(model); - if (cellSelected != null){ - fieldStrategyMonthInfoTripType.setSelectedItem(cellSelected); - } } - protected void setFieldStrategyMonthInfoProportionModel(){ - if (strategyMonthInfo != null){ - fieldStrategyMonthInfoProportion.setMatrix(strategyMonthInfo.getProportionMetier()); - if (listener == null){ - strategyMonthInfo.addPropertyChangeListener(getListener()); - } +}); +fieldStrategyMonthInfoProportion.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (fieldStrategyMonthInfoProportion.getMatrix() != null){ + getStrategyMonthInfo().setProportionMetier(fieldStrategyMonthInfoProportion.getMatrix()); } } - protected PropertyChangeListener getListener(){ - listener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (fieldStrategyMonthInfoProportion.getMatrix() != null){ - strategyMonthInfo.setProportionMetier(fieldStrategyMonthInfoProportion.getMatrix()); - valueChanged(true); - } - } - }; - return listener; - } - protected void tripTypeChanged(){ - Object selected = fieldStrategyMonthInfoTripType.getSelectedItem(); - if (selected != null){ - TripType tripTypeSelected = (TripType)((GenericCell)selected).getValue(); - strategyMonthInfo.setTripType(tripTypeSelected); - valueChanged(true); - } - } - protected void minInactivityDayChanged(){ - strategyMonthInfo.setMinInactivityDays(Double.parseDouble(fieldStrategyMonthInfoMinInactivityDays.getText())); - valueChanged(true); - refresh(); - } - protected void valueChanged(boolean b){ - getParentContainer(StrategyMonthInfoUI.class).valueChanged(b); - } +}); +public void refresh() { + Strategy strategy = (Strategy)getVerifier().getEntity(Strategy.class); + setBean((StrategyImpl) strategy); + setStrategyMonthInfo((StrategyMonthInfoImpl)getBean().getStrategyMonthInfo(month)); + jaxx.runtime.swing.Utils.fillComboBox(fieldStrategyMonthInfoTripType,getRegion().getTripType(), getStrategyMonthInfo().getTripType()); +} +public void init(Month m){ + month = m; +} ]]></script> - <row> - <cell columns='2' fill='horizontal' weightx='1.0' anchor='west'> - <JLabel id='StrategieMonth' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JComboBox id="fieldStrategyMonthInfoTripType" onActionPerformed='tripTypeChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5' anchor='west'> - <JLabel text="isisfish.strategyMonthInfo.numberOfTrips" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5' anchor='west'> - <JLabel id='numberOfTrips' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5' anchor='west'> - <JLabel text="isisfish.strategyMonthInfo.minInactivityDays" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldStrategyMonthInfoMinInactivityDays" onKeyTyped='valueChanged(true)' onFocusLost='minInactivityDayChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <org.codelutin.math.matrix.gui.MatrixPanelEditor id="fieldStrategyMonthInfoProportion" enabled='{isActif()}'/> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell columns='2' fill='horizontal' weightx='1.0' anchor='west'> + <JLabel id='StrategieMonth' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JComboBox id="fieldStrategyMonthInfoTripType" onActionPerformed='getStrategyMonthInfo().setTripType((TripType)fieldStrategyMonthInfoTripType.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5' anchor='west'> + <JLabel text="isisfish.strategyMonthInfo.numberOfTrips" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5' anchor='west'> + <JLabel id='numberOfTrips' text='getStrategyMonthInfo().getNumberOfTrips()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5' anchor='west'> + <JLabel text="isisfish.strategyMonthInfo.minInactivityDays" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JTextField id="fieldStrategyMonthInfoMinInactivityDays" text='getStrategyMonthInfo().getMinInactivityDays()' onKeyTyped='getStrategyMonthInfo().setMinInactivityDays(Double.parseDouble(fieldStrategyMonthInfoMinInactivityDays.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <org.codelutin.math.matrix.gui.MatrixPanelEditor id="fieldStrategyMonthInfoProportion" matrix='{getStrategyMonthInfo().getProportionMetier()}' enabled='{isActif()}'/> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,250 +31,168 @@ */ --> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.StrategyImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Equation; - import fr.ifremer.isisfish.entities.Formule; - import fr.ifremer.isisfish.entities.SetOfVessels; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import java.util.logging.Level; - import java.util.logging.Logger; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.StrategyImpl; +import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.entities.Formule; +import fr.ifremer.isisfish.entities.SetOfVessels; +import org.codelutin.topia.persistence.TopiaEntity; +import fr.ifremer.isisfish.ui.WelcomePanelUI; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import java.util.logging.Level; +import java.util.logging.Logger; - public StrategyTabUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - fr.ifremer.isisfish.entities.Strategy strategy = getContextValue(InputAction.class).getStrategy(); - if (strategy != null){ - fieldStrategyName.setText(strategy.getName()); - setSetOfVesselsModel(strategy); - fieldStrategyProportionSetOfVessels.setText(strategy.getProportionSetOfVessels() + ""); - setInactivityModel(); - fieldUseEquationInactivity.setSelected(strategy.getInactivityEquationUsed()); - fieldStrategyComment.setText(strategy.getComment()); - } - else{ - fieldStrategyName.setText(""); - fieldStrategySetOfVessels.setModel(new DefaultComboBoxModel()); +setType("Strategy"); +setButtonTitle(""); +setNextPath(null); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text");fieldPopulationBasicsName.setText(""); + fieldStrategyName.setText(""); fieldStrategyProportionSetOfVessels.setText("0.0"); - fieldStrategyInactivity.setModel(new DefaultComboBoxModel()); fieldStrategyComment.setText(""); } - valueChanged(false); - try { - editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); - } catch (IOException ex) { - Logger.getLogger(StrategyTabUI.class.getName()).log(Level.SEVERE, null, ex); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } } - protected void setInactivityModel(){ - java.util.List<Formule> formules = getContextValue(InputAction.class).getFormules("Inactivity"); - DefaultComboBoxModel model = new DefaultComboBoxModel(); - for (Formule f : formules){ - model.addElement(new GenericCell(f.getName(),f,Formule.class)); - } - fieldStrategyInactivity.setModel(model); +}); +public void refresh() { + Strategy strategy = (Strategy)getVerifier().getEntity(Strategy.class); + setBean((StrategyImpl) strategy); + setSetOfVesselsModel(); + setInactivityModel(); + try { + editor.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); + } catch (IOException ex) { + Logger.getLogger(StrategyTabUI.class.getName()).log(Level.SEVERE, null, ex); } - protected void setSetOfVesselsModel(fr.ifremer.isisfish.entities.Strategy s){ - DefaultComboBoxModel model = new DefaultComboBoxModel(); - java.util.List<SetOfVessels> value = getContextValue(InputAction.class).getFisheryRegion().getSetOfVessels(); - SetOfVessels selected = s.getSetOfVessels(); - GenericCell selectedCell = null; - for (SetOfVessels sov : value){ - GenericCell cell = new GenericCell(sov.getName(), sov, SetOfVessels.class); - model.addElement(cell); - if (selected != null){ - if (sov.getName().equals(selected.getName())){ - selectedCell = cell; - } - } - } - fieldStrategySetOfVessels.setModel(model); - if (selectedCell != null){ - fieldStrategySetOfVessels.setSelectedItem(selectedCell); - } - } - protected void nameChanged(){ - getContextValue(InputAction.class).getStrategy().setName(fieldStrategyName.getText()); - } - protected void setOfVesselsChanged(){ - Object o = fieldStrategySetOfVessels.getSelectedItem(); - if (o != null){ - getContextValue(InputAction.class).getStrategy().setSetOfVessels((SetOfVessels)((GenericCell)o).getValue()); - } - } - protected void proportionSetOfVesselsChanged(){ - getContextValue(InputAction.class).getStrategy().setProportionSetOfVessels(Double.parseDouble(fieldStrategyProportionSetOfVessels.getText())); - } - protected void useInactivityChanged(){ - getContextValue(InputAction.class).getStrategy().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected()); - } - protected void inactivityChanged(){ - Object o = fieldStrategyInactivity.getSelectedItem(); - if (o != null){ - editor.setText(((Formule)((GenericCell)o).getValue()).getContent()); - } - } - protected void commentChanged(){ - getContextValue(InputAction.class).getSetOfVessels().setName(fieldStrategyName.getText()); - } - protected void saveModel(){ +} +protected void setInactivityModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldStrategyInactivity,getAction().getFormules(getBean().getTopiaContext(), "Inactivity"), null); +} +protected void setSetOfVesselsModel(){ + jaxx.runtime.swing.Utils.fillComboBox(fieldStrategySetOfVessels,getRegion().getSetOfVessels(), getBean().getSetOfVessels()); +} +protected void saveModel(){ // GenericCell g = (GenericCell)fieldStrategyInactivity.getSelectedItem(); // getContextValue(InputAction.class).saveEquationAsModel((Equation)g.getValue()); - getContextValue(InputAction.class).saveAsModel("Strategy", "Java", editor.getText()); - refresh(); - setInfoText(_("isisfish.message.saveModel.finished")); - } - protected void openEditor(){ - getContextValue(InputAction.class).openEditor("Strategy","new",fr.ifremer.isisfish.equation.StrategyInactivityEquation.class, editor.getText(), editor); - } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Strategy"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - 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(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$strategies"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - getParentContainer(StrategyUI.class).setChanged(b); - save.setEnabled(b); - cancel.setEnabled(b); - } + getAction().saveAsModel("StrategyInactivityEquation", "Java", editor.getText()); + setInactivityModel(); + setInfoText(_("isisfish.message.saveModel.finished")); +} ]]></script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell anchor='west'> - <JLabel text="isisfish.strategy.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldStrategyName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='west'> - <JLabel text="isisfish.common.setOfVessels" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldStrategySetOfVessels" onActionPerformed='setOfVesselsChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='west'> - <JLabel text="isisfish.strategy.proportionSetOfVessels" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldStrategyProportionSetOfVessels" onKeyTyped='valueChanged(true)' onFocusLost='proportionSetOfVesselsChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JPanel/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldUseEquationInactivity" text="isisfish.strategy.inactivityEquationUsed" onActionPerformed='useInactivityChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='west'> - <JLabel text="isisfish.strategy.inactivity" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldStrategyInactivity" onActionPerformed='inactivityChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='0.7'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell fill='both' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> - </cell> - <cell fill='both' weightx='1.0' weighty='0.7'> - <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell anchor='west'> - <JLabel text="isisfish.strategy.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='0.3'> - <JScrollPane> - <JTextArea id="fieldStrategyComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell anchor='west'> + <JLabel text="isisfish.strategy.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldStrategyName" text='getBean().getName()' onKeyTyped='getBean().setName(fieldStrategyName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='west'> + <JLabel text="isisfish.common.setOfVessels" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldStrategySetOfVessels" onActionPerformed='getBean().setSetOfVessels((SetOfVessels)fieldStrategySetOfVessels.getSelectedItem())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='west'> + <JLabel text="isisfish.strategy.proportionSetOfVessels" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldStrategyProportionSetOfVessels" text='getBean().getProportionSetOfVessels()' onKeyTyped='getBean().setProportionSetOfVessels(Double.parseDouble(fieldStrategyProportionSetOfVessels.getText()))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JPanel/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().getInactivityEquationUsed()}' text="isisfish.strategy.inactivityEquationUsed" onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='west'> + <JLabel text="isisfish.strategy.inactivity" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldStrategyInactivity" onActionPerformed='editor.setText(((Formule)fieldStrategyInactivity.getSelectedItem()).getContent())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='0.7'> + <Table> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JButton text="isisfish.common.openEditor" onActionPerformed='getAction().openEditor("StrategyInactivityEquation","new",fr.ifremer.isisfish.equation.StrategyInactivityEquation.class, editor.getText(), editor)' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='both' weighty='1.0'> + <JPanel/> + </cell> + </row> + </Table> + </cell> + <cell fill='both' weightx='1.0' weighty='0.7'> + <org.codelutin.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell anchor='west'> + <JLabel text="isisfish.strategy.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='0.3'> + <JScrollPane> + <JTextArea id="fieldStrategyComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -34,39 +34,17 @@ <!-- + Strategy +--> -<JTabbedPane id="StrategyTab" name="Strategy" implements='InputContent'> - - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> - - <Boolean id='changed' javaBean='false'/> - +<fr.ifremer.isisfish.ui.input.InputContentUI> <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> -</JTabbedPane> + <JPanel id='body' layout='{new BorderLayout()}'> + <JTabbedPane id="StrategyTab" name="Strategy" constraints='BorderLayout.CENTER'> + <tab title='{_("isisfish.strategy.title")}'><StrategyTabUI id='strategyTabUI' constructorParams='this'/></tab> + <tab title='{_("isisfish.strategyMonthInfo.title")}'><StrategyMonthInfoUI id='strategyMonthInfoUI' constructorParams='this'/></tab> + </JTabbedPane> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/TripTypeUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -33,162 +33,104 @@ <!-- + TripType +--> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.TripTypeImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.entities.TripType; - import fr.ifremer.isisfish.entities.VesselType; - import fr.ifremer.isisfish.types.TimeUnit; +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.entities.TripTypeImpl; +import fr.ifremer.isisfish.types.TimeUnit; - public TripTypeUI (InputAction action){ - - setContextValue(action); - } - public void refresh() { - if (getContextValue(InputAction.class).getTripType() != null){ - fieldTripTypeName.setText(getContextValue(InputAction.class).getTripType().getName()); - fieldTripTypeDuration.setText("" + getContextValue(InputAction.class).getTripType().getTripDuration().getHour()); - fieldTripTypeMinTimeBetweenTrip.setText("" + getContextValue(InputAction.class).getTripType().getMinTimeBetweenTrip().getHour()); - fieldTripTypeComment.setText(getContextValue(InputAction.class).getTripType().getComment()); - } - else{ +setType("TripType"); +setButtonTitle("isisfish.input.continueZones"); +setNextPath("$root/$zones"); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldTripTypeName.setText(""); fieldTripTypeDuration.setText(""); fieldTripTypeMinTimeBetweenTrip.setText(""); fieldTripTypeComment.setText(""); } + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - changed=b; - save.setEnabled(b); - cancel.setEnabled(b); - } - protected void nameChanged(){ - getContextValue(InputAction.class).getTripType().setName(fieldTripTypeName.getText()); - valueChanged(true); - } - protected void typeDurationChanged(){ - getContextValue(InputAction.class).getTripType().setTripDuration(new TimeUnit(Double.parseDouble(fieldTripTypeDuration.getText()) * 3600)); - valueChanged(true); - } - protected void minTimeChanged(){ - getContextValue(InputAction.class).getTripType().setMinTimeBetweenTrip(new TimeUnit(Double.parseDouble(fieldTripTypeMinTimeBetweenTrip.getText()) * 3600)); - valueChanged(true); - } - protected void commentChanged(){ - getContextValue(InputAction.class).getTripType().setComment(fieldTripTypeComment.getText()); - valueChanged(true); - } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("TripType"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); - } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$tripTypes/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$tripTypes"); - valueChanged(false); - refresh(); - } - protected void goToVesselTypes(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$vesselTypes"); - } +}); +public void refresh() { + TripType tripType = (TripType)getVerifier().getEntity(TripType.class); + setBean((TripTypeImpl) tripType); +} ]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <Table> - <row> - <cell> - <JLabel text="isisfish.tripType.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldTripTypeName" onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.tripType.duration" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldTripTypeDuration" onKeyTyped='valueChanged(true)' onFocusLost='typeDurationChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.tripType.minTime" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldTripTypeMinTimeBetweenTrip" onKeyTyped='valueChanged(true)' onFocusLost='minTimeChanged()' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.tripType.comments" enabled='{isActif()}'/> - </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTextArea id="fieldTripTypeComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> - </JScrollPane> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <Table> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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()}'/> - </cell> - </row> - <row> - <cell columns ='2' fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueVesselTypes" onActionPerformed='goToVesselTypes()'/> - </cell> - </row> - </Table> - </cell> - </row> -</Table> + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <Table> + <row> + <cell> + <JLabel text="isisfish.tripType.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldTripTypeName" text='getBean().getName()' onKeyTyped='getBean().setName(fieldTripTypeName.getText())' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.tripType.duration" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldTripTypeDuration" text='getBean().getTripDuration().getHour()' onKeyTyped='getBean().setTripDuration(new TimeUnit(Double.parseDouble(fieldTripTypeDuration.getText()) * 3600))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.tripType.minTime" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldTripTypeMinTimeBetweenTrip" text='getBean().getMinTimeBetweenTrip().getHour()' onKeyTyped='getBean().setMinTimeBetweenTrip(new TimeUnit(Double.parseDouble(fieldTripTypeMinTimeBetweenTrip.getText()) * 3600))' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.tripType.comments" enabled='{isActif()}'/> + </cell> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTextArea id="fieldTripTypeComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldTripTypeComment.getText())' enabled='{isActif()}'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <Table> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -31,39 +31,26 @@ */ --> -<JPanel layout='{new BorderLayout()}' implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.VesselTypeImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.VesselType; - import fr.ifremer.isisfish.entities.TripType; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import fr.ifremer.isisfish.ui.widget.editor.GenericCell; - import org.codelutin.topia.persistence.TopiaEntity; - import fr.ifremer.isisfish.types.TimeUnit; - - public VesselTypeUI (InputAction action){ - setContextValue(action); - } - public void refresh() { - VesselType vesselType = getContextValue(InputAction.class).getVesselType(); - setVesselTypeTripTypeModel(); - if (vesselType != null){ - fieldVesselTypeName.setText(vesselType.getName()); - fieldVesselTypeLength.setText("" + vesselType.getLength()); - fieldVesselTypeSpeed.setText("" + vesselType.getSpeed()); - fieldVesselTypeMaxTripDuration.setText("" + vesselType.getMaxTripDuration().getHour()); - fieldVesselTypeActivityRange.setText("" + vesselType.getActivityRange()); - fieldVesselTypeMinCrewSize.setText("" + vesselType.getMinCrewSize()); - fieldVesselTypeSpeed.setText("" + vesselType.getSpeed()); - fieldVesselTypeUnitFuelCostOfTravel.setText("" + vesselType.getUnitFuelCostOfTravel()); - fieldVesselTypeComment.setText(vesselType.getComment()); - } - else { +import fr.ifremer.isisfish.entities.VesselType; +import fr.ifremer.isisfish.entities.VesselTypeImpl; +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.ui.widget.editor.GenericCell; +import fr.ifremer.isisfish.types.TimeUnit; + +setType("VesselType"); +setButtonTitle("isisfish.input.continueZones"); +setNextPath("$root/$zones"); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldVesselTypeName.setText(""); fieldVesselTypeLength.setText(""); fieldVesselTypeSpeed.setText(""); @@ -73,100 +60,28 @@ fieldVesselTypeSpeed.setText(""); fieldVesselTypeUnitFuelCostOfTravel.setText(""); fieldVesselTypeComment.setText(""); - } - } - protected void setVesselTypeTripTypeModel(){ - java.util.List<TripType> tripTypes = getContextValue(InputAction.class).getFisheryRegion().getTripType(); - DefaultListModel model = new DefaultListModel(); - for (TripType t : tripTypes){ - model.addElement(new GenericCell(t.getName(), t, TripType.class)); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - vesselTypeTripType.setModel(model); } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("VesselType"); - - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$vesselTypes/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); +}); +public void refresh() { + VesselType vesselType = (VesselType)getVerifier().getEntity(VesselType.class); + setBean((VesselTypeImpl) vesselType); + jaxx.runtime.swing.Utils.fillList(vesselTypeTripType, getRegion().getTripType(), getBean().getTripType()); +} +protected void tripTypeChanged(){ + Object[] values = vesselTypeTripType.getSelectedValues(); + Collection<TripType> tripTypes = new LinkedList<TripType>(); + for (Object o : values){ + tripTypes.add((TripType)((GenericCell)o).getValue()); } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$vesselTypes/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); - } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); - } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$vesselTypes"); - valueChanged(false); - refresh(); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void valueChanged(boolean b){ - changed = b; - save.setEnabled(b); - cancel.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(); - Collection<TripType> tripTypes = new LinkedList<TripType>(); - for (Object o : values){ - 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); - } + getBean().setTripType(tripTypes); +} ]]></script> - <Table constraints='BorderLayout.CENTER'> + <Table id='body' constraints='BorderLayout.CENTER'> <row> <cell fill='both' weightx='1.0' weighty='1.0'> <Table> @@ -175,7 +90,7 @@ <JLabel text="isisfish.vesselType.name" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeName" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='nameChanged()'/> + <JTextField id="fieldVesselTypeName" text='getBean().getName()' enabled='{isActif()}' onKeyTyped='getBean().setName(fieldVesselTypeName.getText())'/> </cell> </row> <row> @@ -183,7 +98,7 @@ <JLabel text="isisfish.vesselType.length" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeLength" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='lenghtChanged()'/> + <JTextField id="fieldVesselTypeLength" text='getBean().getLength()' enabled='{isActif()}' onKeyTyped='getBean().setLength(Integer.parseInt(fieldVesselTypeLength.getText()))'/> </cell> </row> <row> @@ -191,7 +106,7 @@ <JLabel text="isisfish.vesselType.speed" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeSpeed" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='speedChanged()'/> + <JTextField id="fieldVesselTypeSpeed" text='getBean().getSpeed()' enabled='{isActif()}' onKeyTyped='getBean().setSpeed(Double.parseDouble(fieldVesselTypeSpeed.getText()))'/> </cell> </row> <row> @@ -199,7 +114,7 @@ <JLabel text="isisfish.vesselType.maxDuration" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeMaxTripDuration" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='tripDurationChanged()'/> + <JTextField id="fieldVesselTypeMaxTripDuration" text='getBean().getMaxTripDuration().getHour()' enabled='{isActif()}' onKeyTyped='getBean().setMaxTripDuration(new TimeUnit(Double.parseDouble(fieldVesselTypeMaxTripDuration.getText())))'/> </cell> </row> <row> @@ -207,7 +122,7 @@ <JLabel text="isisfish.vesselType.activityRange" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeActivityRange" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='activityRangeChanged()'/> + <JTextField id="fieldVesselTypeActivityRange" text='getBean().getActivityRange()' enabled='{isActif()}' onKeyTyped='getBean().setActivityRange(Double.parseDouble(fieldVesselTypeActivityRange.getText()))'/> </cell> </row> <row> @@ -215,7 +130,7 @@ <JLabel text="isisfish.vesselType.miniCrew" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeMinCrewSize" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='minCrewChanged()'/> + <JTextField id="fieldVesselTypeMinCrewSize" text='getBean().getMinCrewSize()' enabled='{isActif()}' onKeyTyped='getBean().setMinCrewSize(Integer.parseInt(fieldVesselTypeMinCrewSize.getText()))'/> </cell> </row> <row> @@ -223,7 +138,7 @@ <JLabel text="isisfish.vesselType.fuelCost" enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldVesselTypeUnitFuelCostOfTravel" onKeyTyped='valueChanged(true)' onFocusLost='unitFuelCostChanged()' enabled='{isActif()}'/> + <JTextField id="fieldVesselTypeUnitFuelCostOfTravel" text='getBean().getUnitFuelCostOfTravel()' onKeyTyped='getBean().setUnitFuelCostOfTravel(Double.parseDouble(fieldVesselTypeUnitFuelCostOfTravel.getText()))' enabled='{isActif()}'/> </cell> </row> <row> @@ -242,7 +157,7 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.3'> <JScrollPane> - <JTextArea id="fieldVesselTypeComment" onKeyTyped='valueChanged(true)' onFocusLost='commentChanged()' enabled='{isActif()}'/> + <JTextArea id="fieldVesselTypeComment" text='getBean().getComment()' onKeyTyped='getBean().setComment(fieldVesselTypeComment.getText())' enabled='{isActif()}'/> </JScrollPane> </cell> </row> @@ -254,24 +169,22 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='{isChanged()}'/> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='{isChanged()}'/> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + <JButton id='delete' javaBean='getVerifier().getDeleteButton()'/> </cell> </row> </Table> </cell> </row> </Table> - <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueSetOfVessels" onActionPerformed='goToSetOfVessels()'/> -</JPanel> - +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/WizardGroupCreationUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/WizardGroupCreationUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/WizardGroupCreationUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -236,8 +236,8 @@ try { // remove all old group - Population pop = getContextValue(InputAction.class).getPopulation(); - TopiaContext isisContext = getContextValue(InputAction.class).getIsisContext(); + Population pop = (Population)getContextValue(InputSaveVerifier.class).getEntity(Population.class); + TopiaContext isisContext = pop.getTopiaContext(); pop.clearPopulationGroup(); PopulationGroupDAO dao = IsisFishDAOHelper.getPopulationGroupDAO(isisContext); 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 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -35,232 +35,154 @@ <!-- + Zone +--> -<Table implements='InputContent'> +<fr.ifremer.isisfish.ui.input.InputContentUI> - <!-- ui state when the activite is active --> - <Boolean id='actif' javaBean='false'/> + <!-- bean property --> + <fr.ifremer.isisfish.entities.ZoneImpl id='bean' javaBean='null'/> - <Boolean id='changed' javaBean='false'/> - <script><![CDATA[ - import fr.ifremer.isisfish.entities.Cell; - import fr.ifremer.isisfish.entities.Zone; - import fr.ifremer.isisfish.entities.Port; - import fr.ifremer.isisfish.map.IsisMapBean; - import fr.ifremer.isisfish.map.OpenMapToolPanel; - import fr.ifremer.isisfish.map.CellSelectionLayer; - import com.bbn.openmap.event.SelectMouseMode; - import com.bbn.openmap.event.MapMouseListener; - import com.bbn.openmap.gui.OMToolSet; - import fr.ifremer.isisfish.ui.WelcomePanelUI; - import org.codelutin.topia.persistence.TopiaEntity; - import org.codelutin.topia.TopiaException; - import java.util.logging.Level; - import java.util.logging.Logger; +import fr.ifremer.isisfish.entities.Cell; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.entities.ZoneImpl; +import fr.ifremer.isisfish.map.CellSelectionLayer; +import com.bbn.openmap.event.SelectMouseMode; +import com.bbn.openmap.event.MapMouseListener; +import com.bbn.openmap.gui.OMToolSet; - protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); - protected OMToolSet toolSet = new OMToolSet(); - protected MapMouseListener mapListener = null; +protected OMToolSet toolSet = new OMToolSet(); +protected MapMouseListener mapListener = null; - public ZoneUI (InputAction action){ - setContextValue(action); - } - public void refresh() { - 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){ - zoneCellsModel.addElement(c); - } - zoneCells.setModel(zoneCellsModel); - zoneCells.getSelectionModel().setValueIsAdjusting(true); - java.util.List<Cell> cellsSelected = z.getCell(); - if (cellsSelected != null){ - int[] indexs = new int[cellsSelected.size()]; - int i = 0; - for (Cell c : cellsSelected){ - indexs[i] = zoneCellsModel.indexOf(c); - if (log.isDebugEnabled()) { - log.debug("refresh " + c + " " + i); - } - i++; - } - zoneCells.setSelectedIndices(indexs); - } - zoneCells.getSelectionModel().setValueIsAdjusting(false); - fieldZoneName.setText(z.getName()); - fieldZoneComment.setText(getContextValue(InputAction.class).getZone().getComment()); - } - else{ - DefaultListModel zoneCellsModel = new DefaultListModel(); - java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); - for (Cell c : cells){ - zoneCellsModel.addElement(c); - } - zoneCells.setModel(zoneCellsModel); +setType("Zone"); +setButtonTitle("isisfish.input.continuePorts"); +setNextPath("$root/$ports"); +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(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldZoneName.setText(""); fieldZoneComment.setText(""); } - zoneMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); - if (mapListener == null){ - zoneMap.setActiveMouseMode(new SelectMouseMode(false)); - zoneMap.setSelectionMode(CellSelectionLayer.MULT_SELECTION); - toolSet.setupListeners(zoneMap); - toolMap.add((Component)toolSet); - map.add(toolMap, BorderLayout.NORTH); - setMapListener(); + if (evt.getNewValue() != null) { + // add binding on getBean() + //jaxx.runtime.Util.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } - refreshMap(); } - protected void setMapListener(){ - if (mapListener == null){ - mapListener = new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { - @Override - public boolean onMouseClicked() { - java.util.List<Cell> selectedCell = zoneMap.getSelectedCells(); - if (!getContextValue(InputAction.class).isNull()){ - getContextValue(InputAction.class).getZone().setCell(selectedCell); - valueChanged(true); - refresh(); - return true; - } - return false; - } - }; - zoneMap.addMapMouseListener(mapListener); - } - } - protected void refreshMap(){ - if (getContextValue(InputAction.class).getZone() != null){ - zoneMap.setSelectedCells(getContextValue(InputAction.class).getZone().getCell()); - } - } - protected void create(){ - TopiaEntity topia = getContextValue(InputAction.class).create("Zone"); +}); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$zones/"+topia.getTopiaId()); - - setInfoText(_("isisfish.message.creation.finished")); +public void refresh() { + Zone zone = (Zone)getVerifier().getEntity(Zone.class); + setBean((ZoneImpl) zone); + jaxx.runtime.swing.Utils.fillList(zoneCells, getRegion().getCell(), getBean().getCell()); + zoneMap.setFisheryRegion(getRegion()); + if (mapListener == null){ + zoneMap.setActiveMouseMode(new SelectMouseMode(false)); + zoneMap.setSelectionMode(CellSelectionLayer.MULT_SELECTION); + toolSet.setupListeners(zoneMap); + toolMap.add((Component)toolSet); + setMapListener(); } - protected void save(){ - TopiaEntity topia = getContextValue(InputAction.class).save(); - valueChanged(false); - getParentContainer(InputUI.class).repaintNode("$root/$zones/" + topia.getTopiaId()); - setInfoText(_("isisfish.message.save.finished")); - refresh(); + refreshMap(); +} +protected void setMapListener(){ + if (mapListener == null){ + mapListener = new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { + @Override + public boolean onMouseClicked() { + java.util.List<Cell> selectedCell = zoneMap.getSelectedCells(); + getBean().setCell(selectedCell); + return true; + } + }; + zoneMap.addMapMouseListener(mapListener); } - protected void cancel(){ - TopiaEntity topia = getContextValue(InputAction.class).cancel(); - valueChanged(false); - refresh(); - setInfoText(_("isisfish.message.cancel.finished")); +} +protected void refreshMap(){ + zoneMap.setSelectedCells(getBean().getCell()); +} +protected void zoneCellsChange(){ + java.util.List<Cell> cells = new ArrayList<Cell>(); + for (Object o : zoneCells.getSelectedValues()){ + cells.add((Cell) o); } - protected void remove(){ - setInfoText(getContextValue(InputAction.class).remove()); - getParentContainer(InputUI.class).setTreeModel(); - getParentContainer(InputUI.class).setTreeSelection("$root/$zones"); - valueChanged(false); - refresh(); - } - protected void goToPort(){ - getParentContainer(InputUI.class).setTreeSelection("$root/$ports"); - } - protected void setInfoText(String txt){ - WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); - root.setInfoText(txt); - } - protected void commentChange(){ - getContextValue(InputAction.class).getZone().setComment(fieldZoneComment.getText()); - valueChanged(true); - } - protected void zoneCellsChange(){ - java.util.List<Cell> cells = new ArrayList<Cell>(); - for (Object o : zoneCells.getSelectedValues()){ - cells.add((Cell) o); - } - getContextValue(InputAction.class).getZone().setCell(cells); - valueChanged(true); - refreshMap(); - } - protected void nameChange(){ - getContextValue(InputAction.class).getZone().setName(fieldZoneName.getText()); - } - protected void valueChanged(boolean b){ - changed = b; - save.setEnabled(b); - cancel.setEnabled(b); - } - ]]> + getBean().setCell(cells); + refreshMap(); +} +]]> </script> - <row> - <cell fill='both' weightx='1.0' weighty='1.0'> - <JSplitPane id="ZoneTab" name="Zones" - oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> - <Table> - <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)' onFocusLost='nameChange()'/> -<!-- onFocusLost='nameChange()' --> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel enabled='{isActif()}' text="isisfish.zone.cells"/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> - <JScrollPane> - <JList id="zoneCells" enabled='{isActif()}' onMouseClicked='zoneCellsChange()'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel enabled='{isActif()}' text="isisfish.zone.comments"/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.3' weightx='1.0'> - <JScrollPane> - <JTextArea id="fieldZoneComment" enabled='{isActif()}' onKeyTyped='valueChanged(true)' onFocusLost='commentChange()'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <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='{isChanged()}' onActionPerformed='cancel()'/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='remove' text="isisfish.common.remove" enabled='{isActif()}' onActionPerformed='remove()'/> - </cell> - </row> - </Table> - <JPanel id='map' layout='{new BorderLayout()}'> - <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()'/> - </JPanel> - </JSplitPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continuePorts" onActionPerformed='goToPort()'/> - </cell> - </row> -</Table> - \ No newline at end of file + <Table id='body'> + <row> + <cell fill='both' weightx='1.0' weighty='1.0'> + <JSplitPane id="ZoneTab" name="Zones" + oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> + <Table> + <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" + text='{jaxx.runtime.Util.getStringValue(getBean().getName())}' + enabled='{isActif()}' + onKeyTyped='getBean().setName(fieldZoneName.getText())'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel enabled='{isActif()}' text="isisfish.zone.cells"/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> + <JScrollPane> + <JList id="zoneCells" enabled='{isActif()}' onMouseClicked='zoneCellsChange()'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel enabled='{isActif()}' text="isisfish.zone.comments"/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.3' weightx='1.0'> + <JScrollPane> + <JTextArea id="fieldZoneComment" + text='{jaxx.runtime.Util.getStringValue(getBean().getComment())}' + enabled='{isActif()}' + onKeyTyped='getBean().setComment(fieldZoneComment.getText())'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' javaBean='getVerifier().getSaveButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' javaBean='getVerifier().getCancelButton()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' javaBean='getVerifier().getNewButton()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='remove' javaBean='getVerifier().getDeleteButton()'/> + </cell> + </row> + </Table> + <JPanel id='map' layout='{new BorderLayout()}'> + <fr.ifremer.isisfish.map.OpenMapToolPanel id='toolMap' + javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' + constraints='BorderLayout.NORTH'/> + <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' + javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' + constraints='BorderLayout.CENTER'/> + </JPanel> + </JSplitPane> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -322,7 +322,7 @@ <JScrollPane> <javax.swing.JTree id="tree" name="tree" rootVisible="false" model='{getTreeModel()}'/> </JScrollPane> - <JSplitPane oneTouchExpandable="true" dividerLocation="250" orientation="VERTICAL"> + <JSplitPane oneTouchExpandable="true" resizeWeight="0.75" orientation="VERTICAL"> <org.codelutin.widget.editor.Editor id='editor'/> <JScrollPane> <JTextArea id="actionLogArea" editable="false"/> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2009-01-02 17:19:42 UTC (rev 1723) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2009-01-02 17:22:04 UTC (rev 1724) @@ -34,6 +34,7 @@ <Table> <script><![CDATA[ import jaxx.runtime.swing.Item; + import fr.ifremer.isisfish.ui.WelcomePanelUI; refresh(); public ExportUI (SimulAction action){ @@ -66,6 +67,14 @@ getContextValue(SimulAction.class).getSimulationParameter().setExportNames(exportNames); } } + protected void saveExport(){ + getContextValue(SimulAction.class).saveExport(); + setInfoText(_("isisfish.export.saved")); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } ]]> </script> <row> @@ -86,7 +95,7 @@ <JButton text="isisfish.common.ellipsis" onActionPerformed='getContextValue(SimulAction.class).updateDirectory()'/> </cell> <cell> - <JButton text="isisfish.common.saveNextSimulation" onActionPerformed='getContextValue(SimulAction.class).saveExport()'/> + <JButton text="isisfish.common.saveNextSimulation" onActionPerformed='saveExport()'/> </cell> </row> </Table>