Author: chatellier Date: 2009-06-04 15:20:47 +0000 (Thu, 04 Jun 2009) New Revision: 2321 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx Log: Make cancel refresh work 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-06-04 14:58:55 UTC (rev 2320) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2009-06-04 15:20:47 UTC (rev 2321) @@ -1,7 +1,6 @@ <!-- /* *##% - * Copyright (C) 2005 - * Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin + * Copyright (C) 2005 - 2009 Ifremer, Code Lutin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -17,43 +16,20 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *##%*/ - -/* * - * IsisFish.java - * - * Created: 1 aout 2005 18:37:25 CEST - * - * @author Benjamin POUSSIN <poussin at codelutin.com> - * @version $Revision: 1312 $ - * - * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $ - * by : $Author: sletellier $ - */ --> - - - <!-- - + Port - +--> <fr.ifremer.isisfish.ui.input.InputContentUI> <!-- bean property --> <fr.ifremer.isisfish.entities.PortImpl id='bean' javaBean='null'/> <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; import com.bbn.openmap.gui.OMToolSet; -import fr.ifremer.isisfish.ui.WelcomePanelUI; import fr.ifremer.isisfish.map.CellSelectionLayer; import com.bbn.openmap.event.SelectMouseMode; -import org.codelutin.topia.persistence.TopiaEntity; -import org.codelutin.topia.TopiaException; protected OMToolSet toolSet = new OMToolSet(); protected OpenMapEvents mapListener = null; @@ -68,54 +44,55 @@ setMapListener(); setButtonTitle(_("isisfish.input.continueSpecies")); setNextPath("$root/$species"); + addPropertyChangeListener("bean", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getOldValue() != null || evt.getNewValue() == null) { - // remove previous binding on getBean() - //jaxx.runtime.SwingUtil.removeDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldPortName.setText(""); fieldPortComment.setText(""); } if (evt.getNewValue() != null) { - // add binding on getBean() - //jaxx.runtime.SwingUtil.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } }); + public void refresh() { getVerifier().setSaveButton(save); getVerifier().setCancelButton(cancel); getVerifier().setNewButton(create, "Port"); getVerifier().setDeleteButton(remove); Port port = getVerifier().getEntity(Port.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + setBean(null); setBean((PortImpl) port); + fillList(); } -protected void fillList(){ - if (getBean() != null){ +protected void fillList() { + if (getBean() != null) { portChanged = false; portCell.fillList(getRegion().getCell(), getBean().getCell()); portCell.setSelectedValue(getBean().getCell()); portChanged = true; } } -protected void setMapListener(){ - if (mapListener == null){ +protected void setMapListener() { + if (mapListener == null) { mapListener = new OpenMapEvents(portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) { - @Override public boolean onMouseClicked() { - for (Cell c : portMap.getSelectedCells()){ - if (getBean() != null){ - if (getBean().getCell() != null){ + for (Cell c : portMap.getSelectedCells()) { + if (getBean() != null) { + if (getBean().getCell() != null) { if (getBean().getCell().getTopiaId().equals(c.getTopiaId())){ getBean().setCell(c); - return true; } } - else{ + else { getBean().setCell(c); - return true; } } } @@ -124,16 +101,16 @@ }; } } -protected void portChanged(){ - if (portChanged){ + +protected void portChanged() { + if (portChanged) { getBean().setCell((Cell)portCell.getSelectedValue()); } } - ]]> - </script> + ]]></script> <Table id='body'> <row> - <cell fill='both' weightx='1.0' weighty='1.0'> + <cell fill='both' weightx='1.0' weighty='1.0'> <JSplitPane id="PortTab" name="Ports" oneTouchExpandable="true" dividerLocation="270" orientation="horizontal"> <Table> @@ -144,7 +121,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0' > - <JTextField id="fieldPortName" text='{getBean().getName()}' onKeyReleased='getBean().setName(fieldPortName.getText())' enabled='{isActif()}' decorator='boxed'/> + <JTextField id="fieldPortName" text='{getBean().getName()}' onKeyReleased='getBean().setName(fieldPortName.getText())' enabled='{isActif()}' decorator='boxed' /> </cell> </row> <row> @@ -156,7 +133,7 @@ <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane> - <JList id="portCell" selectedValue='{getBean().getCell()}' selectionMode="0" onMouseClicked='portChanged()' enabled='{isActif()}' decorator='boxed'/> + <JList id="portCell" selectedValue='{getBean().getCell()}' selectionMode="0" onMouseClicked='portChanged()' enabled='{isActif()}' decorator='boxed' /> </JScrollPane> </cell> </row> @@ -174,10 +151,10 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id='save' decorator='boxed'/> + <JButton id='save' decorator='boxed'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' decorator='boxed'/> + <JButton id='cancel' decorator='boxed'/> </cell> </row> <row> @@ -190,7 +167,7 @@ </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' decorator='boxed'/> + <fr.ifremer.isisfish.map.OpenMapToolPanel id='toolMap' javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' constraints='BorderLayout.NORTH' decorator='boxed'/> <fr.ifremer.isisfish.map.IsisMapBean id='portMap' selectedCells='{getBean().getCell()}' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' constraints='BorderLayout.CENTER' selectionMode="1" decorator='boxed'/> </JPanel> </JSplitPane>
participants (1)
-
chatellier@users.labs.libre-entreprise.org