Author: chatellier Date: 2009-06-04 14:50:05 +0000 (Thu, 04 Jun 2009) New Revision: 2318 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx Log: Make refresh work 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-06-04 09:34:22 UTC (rev 2317) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2009-06-04 14:50:05 UTC (rev 2318) @@ -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,24 +16,7 @@ * 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 $ - */ --> - - - <!-- - + Cell - +--> <fr.ifremer.isisfish.ui.input.InputContentUI> <!-- bean property --> @@ -56,6 +38,7 @@ cellMap.addMapMouseListener(getMapListener()); toolSet.setupListeners(cellMap); toolMap.add((Component)toolSet); + addPropertyChangeListener("bean", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getOldValue() != null || evt.getNewValue() == null) { @@ -73,24 +56,30 @@ } } }); + public void refresh() { getVerifier().setSaveButton(save); getVerifier().setCancelButton(cancel); Cell cell = getVerifier().getEntity(Cell.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + setBean(null); setBean((CellImpl) cell); + cellChanged = false; - jaxx.runtime.SwingUtil.fillComboBox(fieldCell,getRegion().getCell(), getBean()); + jaxx.runtime.SwingUtil.fillComboBox(fieldCell, getRegion().getCell(), getBean()); cellChanged = true; } -protected OpenMapEvents getMapListener(){ + +protected OpenMapEvents getMapListener() { if (mapListener == null){ mapListener = new OpenMapEvents(cellMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) { - @Override public boolean onMouseClicked() { - for (Cell c : cellMap.getSelectedCells()){ - if (getBean() != null){ - if (!c.getTopiaId().equals(getBean().getTopiaId())){ + for (Cell c : cellMap.getSelectedCells()) { + if (getBean() != null) { + if (!c.getTopiaId().equals(getBean().getTopiaId())) { jaxx.runtime.SwingUtil.fillComboBox(fieldCell,getRegion().getCell(), c); return true; } @@ -104,7 +93,7 @@ } protected void fieldCellChanged() { - if (cellChanged){ + if (cellChanged) { Cell c = (Cell)fieldCell.getSelectedItem(); if (c==null) { return; @@ -118,73 +107,73 @@ } } ]]></script> - <JPanel id='body' layout='{new BorderLayout()}'> - <JSplitPane id="CellTab" name="Cells" constraints='BorderLayout.CENTER' - oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> - <Table> - <row> - <cell fill='horizontal' columns='2' weightx='1.0'> - <JComboBox id="fieldCell" onActionPerformed='fieldCellChanged()' model='{new DefaultComboBoxModel()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.cell.name" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellName" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getName())}' decorator='boxed' + <JPanel id='body' layout='{new BorderLayout()}'> + <JSplitPane id="CellTab" name="Cells" constraints='BorderLayout.CENTER' + oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> + <Table> + <row> + <cell fill='horizontal' columns='2' weightx='1.0'> + <JComboBox id="fieldCell" onActionPerformed='fieldCellChanged()' model='{new DefaultComboBoxModel()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.cell.name" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldCellName" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getName())}' decorator='boxed' onKeyReleased='getBean().setName(fieldCellName.getText())' enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.cell.latitude" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLatitude" text='{getBean().getLatitude()}' editable="false" enabled='{isActif()}' decorator='boxed'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.cell.longitude" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLongitude" text='{getBean().getLongitude()}' editable="false" enabled='{isActif()}' decorator='boxed'/> - </cell> - </row> - <row> - <cell> - <JLabel text="isisfish.cell.land" enabled='{isActif()}'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActif()}' selected='{getBean().getLand()}' decorator='boxed'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal'> - <JLabel text="isisfish.cell.comments" enabled='{isActif()}'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='1.0' weightx='1.0'> - <JScrollPane> - <JTextArea id="fieldCellComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldCellComment.getText())' enabled='{isActif()}' decorator='boxed'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='save' text='isisfish.common.save' decorator='boxed'/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' text='isisfish.common.cancel' decorator='boxed'/> - </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' decorator='boxed'/> - <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="1" selectedCells='{getBean()}' fisheryRegion='{getRegion()}' constraints='BorderLayout.CENTER' decorator='boxed'/> - </JPanel> - </JSplitPane> - </JPanel> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.cell.latitude" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldCellLatitude" text='{getBean().getLatitude()}' editable="false" enabled='{isActif()}' decorator='boxed'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.cell.longitude" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextField id="fieldCellLongitude" text='{getBean().getLongitude()}' editable="false" enabled='{isActif()}' decorator='boxed'/> + </cell> + </row> + <row> + <cell> + <JLabel text="isisfish.cell.land" enabled='{isActif()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActif()}' selected='{getBean().getLand()}' decorator='boxed'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal'> + <JLabel text="isisfish.cell.comments" enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='1.0' weightx='1.0'> + <JScrollPane> + <JTextArea id="fieldCellComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldCellComment.getText())' enabled='{isActif()}' decorator='boxed'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' text='isisfish.common.save' decorator='boxed'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' text='isisfish.common.cancel' decorator='boxed'/> + </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' decorator='boxed'/> + <fr.ifremer.isisfish.map.IsisMapBean id='cellMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="1" selectedCells='{getBean()}' fisheryRegion='{getRegion()}' constraints='BorderLayout.CENTER' decorator='boxed'/> + </JPanel> + </JSplitPane> + </JPanel> </fr.ifremer.isisfish.ui.input.InputContentUI>