Author: chatellier Date: 2011-04-29 09:19:09 +0000 (Fri, 29 Apr 2011) New Revision: 3295 Log: Fix port and zone edition Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2011-04-28 08:28:23 UTC (rev 3294) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2011-04-29 09:19:09 UTC (rev 3295) @@ -38,6 +38,7 @@ com.bbn.openmap.event.SelectMouseMode java.beans.PropertyChangeEvent java.beans.PropertyChangeListener + java.awt.event.MouseEvent </import> <BeanValidator id='validator' @@ -65,12 +66,12 @@ for (Cell c : portMap.getSelectedCells()) { if (getBean().getCell() != null) { if (!getBean().getCell().getTopiaId().equals(c.getTopiaId())){ - getBean().setCell(c); + portCell.setSelectedValue(c); return true; } } else { - getBean().setCell(c); + portCell.setSelectedValue(c); return true; } } @@ -89,7 +90,7 @@ fieldPortComment.setText(""); } if (evt.getNewValue() != null) { - fillList(); + fillCellList(); } } }); @@ -106,7 +107,7 @@ refreshRegionInMap(portMap); }*/ -protected void fillList() { +protected void fillCellList() { if (getBean() != null) { portChanged = false; portCell.fillList(getFisheryRegion().getCell(), getBean().getCell()); @@ -143,7 +144,8 @@ <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane id="spPortCell"> - <JAXXList id="portCell" selectedValue='{getBean().getCell()}' selectionMode="0" onMouseClicked='portChanged()' enabled='{isActive()}' decorator='boxed' /> + <JAXXList id="portCell" selectedValue='{getBean().getCell()}' selectionMode="0" + onValueChanged='portChanged()' enabled='{isActive()}' decorator='boxed' /> </JScrollPane> </cell> </row> @@ -193,7 +195,8 @@ constraints='BorderLayout.NORTH' decorator='boxed' enabled='{getBean() != null}' /> <fr.ifremer.isisfish.map.IsisMapBean id='portMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' constraints='BorderLayout.CENTER' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.SINGLE_SELECTION}" - decorator='boxed' enabled='{getBean() != null}' fisheryRegion='{getFisheryRegion()}' selectedCells='{getBean().getCell()}' /> + decorator='boxed' enabled='{getBean() != null}' fisheryRegion='{getFisheryRegion()}' + selectedCells='{getBean() == null ? null : bean.getCell()}' /> </JPanel> </JSplitPane> </JPanel> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2011-04-28 08:28:23 UTC (rev 3294) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2011-04-29 09:19:09 UTC (rev 3295) @@ -34,13 +34,13 @@ fr.ifremer.isisfish.entities.Zone fr.ifremer.isisfish.map.CellSelectionLayer fr.ifremer.isisfish.map.CopyMapToClipboardListener + fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel com.bbn.openmap.event.SelectMouseMode com.bbn.openmap.gui.Tool com.bbn.openmap.gui.OMToolSet java.beans.PropertyChangeEvent java.beans.PropertyChangeListener java.awt.event.MouseEvent - javax.swing.DefaultListModel java.util.ArrayList </import> @@ -69,10 +69,7 @@ boolean result = false; if (getBean() != null) { // impossible de desactiver la carte :( getBean().setCell(zoneMap.getSelectedCells()); - if (getBean().getCell() != null){ - zoneCells.setSelectedValues(getBean().getCell().toArray()); - result = true; - } + setZoneCells(); } return result; } @@ -83,36 +80,25 @@ if (evt.getNewValue() == null) { fieldZoneName.setText(""); fieldZoneComment.setText(""); - zoneMap.setSelectedCells((Cell)null); + zoneMap.setSelectedCells(); } if (evt.getNewValue() != null) { setZoneCells(); - zoneMap.setSelectedCells(getBean().getCell()); } } }); } -/*public void refresh() { - Zone zone = getSaveVerifier().getEntity(Zone.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(zone); - - // reload region in map - refreshRegionInMap(zoneMap); -}*/ - -protected void setZoneCells(){ - if (getBean() != null){ - DefaultListModel model = new DefaultListModel(); - for (Cell c : getFisheryRegion().getCell()) - model.addElement(c); +protected void setZoneCells() { + if (getBean() != null) { + List<Cell> cells = getFisheryRegion().getCell(); + TopiaEntityListModel model = new TopiaEntityListModel(cells); zoneCells.setModel(model); - if (getBean().getCell() != null){ - zoneCells.setSelectedValues(getBean().getCell().toArray()); + if (getBean().getCell() != null) { + for (Cell selectedCell : getBean().getCell()) { + int index = cells.indexOf(selectedCell); + zoneCells.addSelectionInterval(index, index); + } } } } @@ -129,11 +115,6 @@ getBean().setCell(cells); } } - else { - if (log.isDebugEnabled()) { - log.debug("Duplicated event skipped"); - } - } } ]]> </script> @@ -161,9 +142,8 @@ <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane id="spZoneCells"> - <!-- FIXME le binding genere un tas d'envenement multiples ! --> - <JAXXList id="zoneCells" enabled='{isActive()}' selectedValues='{getBean().getCell() == null ? null : getBean().getCell().toArray()}' - onValueChanged='zoneCellsChange(event)' decorator='boxed'/> + <JList id="zoneCells" enabled='{isActive()}' + onValueChanged='zoneCellsChange(event)' decorator='boxed'/> </JScrollPane> </cell> </row> @@ -219,8 +199,9 @@ <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" - fisheryRegion='{getFisheryRegion()}' selectedCells='{getBean().getCell()}' + fisheryRegion='{getFisheryRegion()}' selectedCells='{getBean()==null?null:bean.getCell()}' decorator='boxed' constraints='BorderLayout.CENTER'/> + <!-- FIXME echatellier 20110429 : binding --> </JPanel> </JSplitPane> </JPanel> Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java 2011-04-29 09:19:09 UTC (rev 3295) @@ -0,0 +1,91 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultListModel; + +import org.nuiton.topia.persistence.TopiaEntity; + +/** + * Model pour la liste des {@link TopiaEntity}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class TopiaEntityListModel extends DefaultListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Zones list */ + protected List<? extends TopiaEntity> entities; + + /** + * Constructor with entities list. + * + * @param entities entities list + */ + public TopiaEntityListModel(List<? extends TopiaEntity> entities) { + this.entities = entities; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return entities.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (entities != null) { + size = entities.size(); + } + return size; + } + + /** + * Return elements in model. + * + * @return elements in model + */ + public List<? extends TopiaEntity> getElements() { + return entities; + } +} Property changes on: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL