Author: sletellier Date: 2009-02-16 11:58:27 +0000 (Mon, 16 Feb 2009) New Revision: 1816 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx Log: Fix listSelected bug 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-02-16 08:45:16 UTC (rev 1815) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2009-02-16 11:58:27 UTC (rev 1816) @@ -48,17 +48,14 @@ import com.bbn.openmap.event.SelectMouseMode; import com.bbn.openmap.event.MapMouseListener; import com.bbn.openmap.gui.OMToolSet; +import jaxx.runtime.swing.Item; protected OMToolSet toolSet = new OMToolSet(); -protected MapMouseListener mapListener = null; -boolean cellChanged = true; -zoneMap = new fr.ifremer.isisfish.map.IsisMapBean(); -zoneMap.setFisheryRegion(getRegion()); -zoneMap.setActiveMouseMode(new SelectMouseMode(false)); -zoneMap.setSelectionMode(CellSelectionLayer.MULT_SELECTION); +protected OpenMapEvents mapListener = null; + toolSet.setupListeners(zoneMap); toolMap.add((Component)toolSet); -setMapListener(); +zoneMap.addMapMouseListener(getMapListener()); setButtonTitle(_("isisfish.input.continuePorts")); setNextPath("$root/$ports"); addPropertyChangeListener("bean", new PropertyChangeListener() { @@ -71,6 +68,7 @@ // jaxx.runtime.Util.removeDataBinding($InputContentUI0, "fieldZoneName.text", "fieldZoneComment.text"); fieldZoneName.setText(""); fieldZoneComment.setText(""); + zoneMap.setSelectedCells((Cell)null); } if (evt.getNewValue() != null) { // add binding on getBean() @@ -86,36 +84,39 @@ getVerifier().setDeleteButton(remove); Zone zone = getVerifier().getEntity(Zone.class); setBean((ZoneImpl) zone); - setZoneCells(); + if (getBean() != null){ + setZoneCells(); + } } protected void setZoneCells(){ if (getBean() != null){ - cellChanged = false; - zoneCells.fillList(getRegion().getCell(), getBean().getCell()); - cellChanged = true; + DefaultListModel model = new DefaultListModel(); + for (Cell c : getRegion().getCell()) + model.addElement(c); + zoneCells.setModel(model); + if (getBean().getCell() != null){ + zoneCells.setSelectedValues(getBean().getCell().toArray()); + } } } -protected void setMapListener(){ +protected OpenMapEvents getMapListener(){ if (mapListener == null){ mapListener = new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { @Override public boolean onMouseClicked() { - zoneCells.fillList(getRegion().getCell(), zoneMap.getSelectedCells()); - zoneCellsChange(); - return false; + getBean().setCell(zoneMap.getSelectedCells()); + return true; } }; - zoneMap.addMapMouseListener(mapListener); } + return mapListener; } protected void zoneCellsChange() { - if (cellChanged){ - java.util.List<Cell> cells = new ArrayList<Cell>(); - for (Object o : zoneCells.getSelectedValues()){ - cells.add((Cell) o); - } - getBean().setCell(cells); + java.util.List<Cell> cells = new ArrayList<Cell>(); + for (Object o : zoneCells.getSelectedValues()){ + cells.add((Cell) o); } + getBean().setCell(cells); } ]]> </script> @@ -146,7 +147,7 @@ <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane> - <JList id="zoneCells" enabled='{isActif()}' onMouseClicked='if ( isActif() ) { zoneCellsChange(); }'/> + <JList id="zoneCells" enabled='{isActif()}' selectedValues='{getBean().getCell().toArray()}' onMouseClicked='if ( isActif() ) { zoneCellsChange(); }'/> </JScrollPane> </cell> </row> @@ -187,6 +188,9 @@ javaBean='new fr.ifremer.isisfish.map.OpenMapToolPanel()' constraints='BorderLayout.NORTH'/> <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' + javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' + selectionMode="2" + fisheryRegion='{getRegion()}' selectedCells='{getBean().getCell()}' constraints='BorderLayout.CENTER'/> </JPanel>
participants (1)
-
sletellier@users.labs.libre-entreprise.org