Author: echatellier Date: 2017-03-17 15:33:31 +0100 (Fri, 17 Mar 2017) New Revision: 4408 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4408 Log: fixes #8734: Affichage des mailles s?\195?\169lectionn?\195?\169es Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/AskNewSpatialHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewUI.jaxx Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/AskNewSpatialHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/AskNewSpatialHandler.java 2017-03-17 14:32:17 UTC (rev 4407) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/AskNewSpatialHandler.java 2017-03-17 14:33:31 UTC (rev 4408) @@ -27,13 +27,16 @@ import fr.ifremer.isisfish.entities.Port; import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.util.CellPointcomparator; +import org.nuiton.topia.persistence.TopiaId; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; /** * Handler for new fishery region resolution dialog. @@ -98,6 +101,7 @@ // n'existe pas on la cree Cell cell = new CellImpl(); + cell.setTopiaId(TopiaId.create(Cell.class)); cell.setName("La" + lati + "Lo" + longi); cell.setLatitude(lati); cell.setLongitude(longi); @@ -135,7 +139,7 @@ Rectangle2D.Float intersect = new Rectangle2D.Float(); for (Zone zone : zones) { - List<Cell> zoneNewCells = new ArrayList<>(); + Set<Cell> zoneNewCells = new HashSet<>(); for (Cell newCell : newCells) { Rectangle2D.Float newCellRect = new Rectangle2D.Float(newCell.getLatitude(), newCell.getLongitude(), newFisheryRegion.getCellLengthLatitude(), newFisheryRegion.getCellLengthLongitude()); @@ -148,7 +152,7 @@ } } } - zonesAndNewCells.put(zone, zoneNewCells); + zonesAndNewCells.put(zone, new ArrayList<>(zoneNewCells)); } return zonesAndNewCells; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewHandler.java 2017-03-17 14:32:17 UTC (rev 4407) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewHandler.java 2017-03-17 14:33:31 UTC (rev 4408) @@ -21,8 +21,6 @@ */ package fr.ifremer.isisfish.ui.input.spatial; -import static org.nuiton.i18n.I18n.t; - import com.bbn.openmap.event.SelectMouseMode; import fr.ifremer.isisfish.IsisFishDAOHelper; import fr.ifremer.isisfish.entities.Cell; @@ -37,12 +35,16 @@ import fr.ifremer.isisfish.ui.input.InputUI; import fr.ifremer.isisfish.ui.models.common.GenericComboModel; import jaxx.runtime.JAXXUtil; +import org.apache.commons.lang3.StringUtils; import javax.swing.JOptionPane; import java.awt.event.MouseEvent; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.nuiton.i18n.I18n.t; + /** * Handler fro preview spatial change UI. */ @@ -108,8 +110,9 @@ new OpenMapEvents(inputUI.newZoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { @Override public boolean mouseClicked(MouseEvent e) { - Zone selectedValue = (Zone)inputUI.currentZones.getSelectedItem(); + Zone selectedValue = (Zone) inputUI.currentZones.getSelectedItem(); zoneMap.put(selectedValue, inputUI.newZoneMap.getSelectedCells()); + updateZoneCellDetails(); return false; } }; @@ -116,11 +119,12 @@ new OpenMapEvents(inputUI.newPortMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) { @Override public boolean mouseClicked(MouseEvent e) { - Port selectedValue = (Port)inputUI.currentPorts.getSelectedItem(); + Port selectedValue = (Port) inputUI.currentPorts.getSelectedItem(); List<Cell> selectedCells = inputUI.newPortMap.getSelectedCells(); if (!selectedCells.isEmpty()) { portMap.put(selectedValue, selectedCells.get(0)); } + updatePortCellDetails(); return false; } }; @@ -151,19 +155,55 @@ List<Cell> newCells = zoneMap.get(selectedValue); inputUI.newZoneMap.setSelectedCells(newCells); + updateZoneCellDetails(); } + protected void updateZoneCellDetails() { + Zone selectedValue = (Zone) inputUI.currentZones.getSelectedItem(); + if (selectedValue != null) { + List<Cell> currentCells = selectedValue.getCell(); + inputUI.currentZoneCells.setText(cellToString(currentCells)); + + List<Cell> newCells = zoneMap.get(selectedValue); + inputUI.newZoneCells.setText(cellToString(newCells)); + } + } + + protected String cellToString(List<Cell> cells) { + List<String> strings = new ArrayList<>(); + for (Cell cell : cells) { + strings.add(cell.getName()); + } + return StringUtils.join(strings, ", "); + } + /** * Action when a port is selected in combo. */ public void currentPortChanged() { - Port selectedValue = (Port)inputUI.currentPorts.getSelectedItem(); + Port selectedValue = (Port) inputUI.currentPorts.getSelectedItem(); inputUI.currentPortMap.setSelectedCells(selectedValue.getCell()); Cell newPort = portMap.get(selectedValue); inputUI.newPortMap.setSelectedCells(newPort); + updatePortCellDetails(); } + protected void updatePortCellDetails() { + Port selectedValue = (Port) inputUI.currentPorts.getSelectedItem(); + if (selectedValue != null) { + Cell cell = selectedValue.getCell(); + if (cell != null) { + inputUI.currentPortCell.setText(cell.getName()); + } + + Cell newPort = portMap.get(selectedValue); + if (newPort != null) { + inputUI.newPortCell.setText(newPort.getName()); + } + } + } + /** * Ask fro user to perform database change and commit. */ @@ -217,11 +257,11 @@ // update current zones for (Map.Entry<Zone, List<Cell>> zoneListEntry : zoneMap.entrySet()) { - Zone zone = zoneListEntry.getKey(); - List<Cell> newCell = zoneListEntry.getValue(); + Zone zone = zoneListEntry.getKey(); + List<Cell> newCell = zoneListEntry.getValue(); - zone.clearCell(); - zone.addAllCell(newCell); + zone.clearCell(); + zone.addAllCell(newCell); } // update current ports Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewUI.jaxx 2017-03-17 14:32:17 UTC (rev 4407) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/spatial/ChangeSpatialPreviewUI.jaxx 2017-03-17 14:33:31 UTC (rev 4408) @@ -42,7 +42,9 @@ javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" decorator='boxed' constraints='BorderLayout.CENTER'/> - <JLabel id="currentZoneCells" constraints='BorderLayout.SOUTH' text="" /> + <JScrollPane constraints='BorderLayout.SOUTH'> + <JTextArea id="currentZoneCells" editable="false" rows="3" /> + </JScrollPane> </JPanel> <JPanel layout='{new BorderLayout()}'> <fr.ifremer.isisfish.map.IsisMapBean id='newZoneMap' @@ -49,7 +51,9 @@ javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" decorator='boxed' constraints='BorderLayout.CENTER'/> - <JLabel id="newZoneCells" constraints='BorderLayout.SOUTH' text="" /> + <JScrollPane constraints='BorderLayout.SOUTH'> + <JTextArea id="newZoneCells" editable="false" rows="3" /> + </JScrollPane> </JPanel> </JSplitPane> </JPanel> @@ -67,7 +71,9 @@ javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" decorator='boxed' constraints='BorderLayout.CENTER'/> - <JLabel id="currentPortCell" constraints='BorderLayout.SOUTH' text="" /> + <JScrollPane constraints='BorderLayout.SOUTH'> + <JTextArea id="currentPortCell" editable="false" /> + </JScrollPane> </JPanel> <JPanel layout='{new BorderLayout()}'> <fr.ifremer.isisfish.map.IsisMapBean id='newPortMap' @@ -74,7 +80,9 @@ javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" decorator='boxed' constraints='BorderLayout.CENTER'/> - <JLabel id="newPortCell" constraints='BorderLayout.SOUTH' text="" /> + <JScrollPane constraints='BorderLayout.SOUTH'> + <JTextArea id="newPortCell" editable="false" /> + </JScrollPane> </JPanel> </JSplitPane> </JPanel>