Author: chatellier Date: 2010-11-22 10:46:04 +0000 (Mon, 22 Nov 2010) New Revision: 243 Log: Selection years refactoring. (test are failing) Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java trunk/coser-ui/src/main/resources/icons/arrow_left.png trunk/coser-ui/src/main/resources/icons/arrow_right.png Removed: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2010-11-22 10:46:04 UTC (rev 243) @@ -49,16 +49,24 @@ protected String description; - protected int beginDate; + protected List<String> allYears; - protected int endDate; + protected List<String> selectedYears; - protected List<String> zones; + protected List<String> selectedStrata; - protected List<String> filterSpecyTypes; + /** L1 : liste des especes. */ + protected List<String> selectedSpecies; - protected List<String> species; + /** L2 : */ + protected List<String> selectedSpeciesOccDens; + /** L3 : */ + protected List<String> selectedSpeciesSizeAllYear; + + /** L4 : */ + protected List<String> selectedSpeciesMaturity; + protected String comment; public String getName() { @@ -79,46 +87,63 @@ this.description = description; } - public int getBeginDate() { - return beginDate; + public List<String> getAllYears() { + return allYears; } - public void setBeginDate(int beginDate) { - this.beginDate = beginDate; + public void setAllYears(List<String> allYears) { + this.allYears = allYears; } - public int getEndDate() { - return endDate; + public List<String> getSelectedYears() { + return selectedYears; } - public void setEndDate(int endDate) { - this.endDate = endDate; + public void setSelectedYears(List<String> selectedYears) { + this.selectedYears = selectedYears; } - public List<String> getZones() { - return zones; + public List<String> getSelectedStrata() { + return selectedStrata; } - public void setZones(List<String> zones) { - this.zones = zones; + public void setSelectedStrata(List<String> selectedStrata) { + this.selectedStrata = selectedStrata; } - public List<String> getFilterSpecyTypes() { - return filterSpecyTypes; + public List<String> getSelectedSpecies() { + return selectedSpecies; } - public void setFilterSpecyTypes(List<String> filterSpecyTypes) { - this.filterSpecyTypes = filterSpecyTypes; + public void setSelectedSpecies(List<String> selectedSpecies) { + this.selectedSpecies = selectedSpecies; } - public List<String> getSpecies() { - return species; + public List<String> getSelectedSpeciesOccDens() { + return selectedSpeciesOccDens; } - public void setSpecies(List<String> species) { - this.species = species; + public void setSelectedSpeciesOccDens(List<String> selectedSpeciesOccDens) { + this.selectedSpeciesOccDens = selectedSpeciesOccDens; } + public List<String> getSelectedSpeciesSizeAllYear() { + return selectedSpeciesSizeAllYear; + } + + public void setSelectedSpeciesSizeAllYear( + List<String> selectedSpeciesSizeAllYear) { + this.selectedSpeciesSizeAllYear = selectedSpeciesSizeAllYear; + } + + public List<String> getSelectedSpeciesMaturity() { + return selectedSpeciesMaturity; + } + + public void setSelectedSpeciesMaturity(List<String> selectedSpeciesMaturity) { + this.selectedSpeciesMaturity = selectedSpeciesMaturity; + } + public String getComment() { return comment; } @@ -131,17 +156,27 @@ public Properties toProperties() { Properties props = new Properties(); - props.setProperty("selection.begindate", String.valueOf(getBeginDate())); - props.setProperty("selection.enddate", String.valueOf(getEndDate())); - if (getSpecies() != null) { - props.setProperty("selection.species", StringUtils.join(getSpecies(),',')); + if (getAllYears() != null) { + props.setProperty("selection.allYears", StringUtils.join(getAllYears(),',')); } - if (getZones() != null) { - props.setProperty("selection.zones", StringUtils.join(getZones(),',')); + if (getSelectedYears() != null) { + props.setProperty("selection.selectedYears", StringUtils.join(getAllYears(),',')); } - if (getFilterSpecyTypes() != null) { - props.setProperty("selection.specy.types", StringUtils.join(getFilterSpecyTypes(),',')); + if (getSelectedStrata() != null) { + props.setProperty("selection.selectedStrata", StringUtils.join(getSelectedStrata(),',')); } + if (getSelectedSpecies() != null) { + props.setProperty("selection.selectedSpecies", StringUtils.join(getSelectedSpecies(),',')); + } + if (getSelectedSpeciesOccDens() != null) { + props.setProperty("selection.selectedSpeciesOccDens", StringUtils.join(getSelectedSpeciesOccDens(),',')); + } + if (getSelectedSpeciesSizeAllYear() != null) { + props.setProperty("selection.selectedSpeciesSizeAllYear", StringUtils.join(getSelectedSpeciesSizeAllYear(),',')); + } + if (getSelectedSpeciesMaturity() != null) { + props.setProperty("selection.selectedSpeciesMaturity", StringUtils.join(getSelectedSpeciesMaturity(),',')); + } if (description != null) { props.setProperty("selection.description", description); } @@ -152,21 +187,27 @@ } public void fromProperties(Properties props) { - if (props.containsKey("selection.begindate")) { - setBeginDate(Integer.parseInt(props.getProperty("selection.begindate"))); + if (props.containsKey("selection.allYears")) { + setAllYears(splitAsList(props.getProperty("selection.allYears"))); } - if (props.containsKey("selection.enddate")) { - setEndDate(Integer.parseInt(props.getProperty("selection.enddate"))); + if (props.containsKey("selection.selectedYears")) { + setSelectedYears(splitAsList(props.getProperty("selection.allYears"))); } - if (props.containsKey("selection.species")) { - setSpecies(splitAsList(props.getProperty("selection.species"))); + if (props.containsKey("selection.selectedStrata")) { + setSelectedStrata(splitAsList(props.getProperty("selection.selectedStrata"))); } - if (props.containsKey("selection.zones")) { - setZones(splitAsList(props.getProperty("selection.zones"))); + if (props.containsKey("selection.selectedSpecies")) { + setSelectedSpecies(splitAsList(props.getProperty("selection.selectedSpecies"))); } - if (props.containsKey("selection.specy.types")) { - setFilterSpecyTypes(splitAsList(props.getProperty("selection.specy.types"))); + if (props.containsKey("selection.selectedSpeciesOccDens")) { + setSelectedSpeciesOccDens(splitAsList(props.getProperty("selection.selectedSpeciesOccDens"))); } + if (props.containsKey("selection.selectedSpeciesSizeAllYear")) { + setSelectedSpeciesSizeAllYear(splitAsList(props.getProperty("selection.selectedSpeciesSizeAllYear"))); + } + if (props.containsKey("selection.selectedSpeciesMaturity")) { + setSelectedSpeciesMaturity(splitAsList(props.getProperty("selection.selectedSpeciesMaturity"))); + } if (props.containsKey("selection.description")) { setDescription(props.getProperty("selection.description")); } Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-22 10:46:04 UTC (rev 243) @@ -28,12 +28,11 @@ import static org.nuiton.i18n.I18n._; import java.text.NumberFormat; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.SortedSet; import java.util.TreeMap; -import java.util.TreeSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -52,7 +51,7 @@ import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Length; @@ -81,17 +80,18 @@ * le nombre dans les tailles pour toutes les especes. * * @param project project - * @param control control + * @param container data container + * @param speciesCollection utilisé pour n'avoir qu'une partie des especes (can be null) * @return chart */ - public Map<String, JFreeChart> getCompareCatchLengthGraph(Project project, Control control) { + public Map<String, JFreeChart> getCompareCatchLengthGraph(Project project, AbstractDataContainer container, Collection<String> speciesCollection) { int minYear = Integer.MAX_VALUE; int maxYear = Integer.MIN_VALUE; // look for data (data summed over catch) Map<String, Map<String, Double>> catchForSpeciesYears = new HashMap<String, Map<String, Double>>(); - Iterator<String[]> itCatchData = control.getCatch().iterator(); + Iterator<String[]> itCatchData = container.getCatch().iterator(); itCatchData.next(); // header while (itCatchData.hasNext()) { String[] tuple = itCatchData.next(); @@ -136,7 +136,7 @@ // look for data (data summed over length) Map<String, Map<String, Double>> lengthForSpeciesYears = new HashMap<String, Map<String, Double>>(); - Iterator<String[]> itLengthData = control.getLength().iterator(); + Iterator<String[]> itLengthData = container.getLength().iterator(); itLengthData.next(); // header while (itLengthData.hasNext()) { String[] tuple = itLengthData.next(); @@ -172,7 +172,14 @@ // generation des graphes pour chaques especes Map<String, JFreeChart> charts = new TreeMap<String, JFreeChart>(); for (Map.Entry<String, Map<String, Double>> catchEntries : catchForSpeciesYears.entrySet()) { + String species = catchEntries.getKey(); + + // filtage des especes + if (speciesCollection != null && !speciesCollection.contains(species)) { + continue; + } + Map<String, Double> catchNumbers = catchEntries.getValue(); Map<String, Double> lengthNumbers = lengthForSpeciesYears.get(species); Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-22 10:46:04 UTC (rev 243) @@ -34,8 +34,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -1150,30 +1150,55 @@ * Used in selection ui. * * @param selection selection - * @param beginYear begin year - * @param endYear end year + * @param years selected years * @return zones */ - public List<String> getProjectZone(Selection selection, Integer beginYear, Integer endYear) { + public List<String> filterDataYearsAndGetStrata(Selection selection, Collection<String> years) { List<String> result = new ArrayList<String>(); - - Iterator<String[]> itTuple = selection.getHaul().iterator(); - itTuple.next(); // skip header - while (itTuple.hasNext()) { - String[] tuple = itTuple.next(); - // Campagne;Annee;Trait;Mois;Strate;SurfaceBalayee;Lat;Long;ProfMoy - String annee = tuple[Haul.INDEX_YEAR]; - int intAnnee = Integer.parseInt(annee); - - if (intAnnee >= beginYear && intAnnee <= endYear) { - String strates = tuple[Haul.INDEX_STRATUM]; + + // manage haul + Iterator<String[]> itHaul = selection.getHaul().iterator(); + itHaul.next(); // skip header + while (itHaul.hasNext()) { + String[] tupleHaul = itHaul.next(); + String annee = tupleHaul[Haul.INDEX_YEAR]; + + if (!years.contains(annee)) { + itHaul.remove(); + } + else { + String strates = tupleHaul[Haul.INDEX_STRATUM]; if (!result.contains(strates)) { result.add(strates); } } } + + // manage catch + Iterator<String[]> itCatch = selection.getCatch().iterator(); + itCatch.next(); // skip header + while (itCatch.hasNext()) { + String[] tupleCatch = itCatch.next(); + String annee = tupleCatch[Catch.INDEX_YEAR]; + + if (!years.contains(annee)) { + itCatch.remove(); + } + } + // manage length + Iterator<String[]> itLength = selection.getLength().iterator(); + itLength.next(); // skip header + while (itLength.hasNext()) { + String[] tupleLength = itLength.next(); + String annee = tupleLength[Length.INDEX_YEAR]; + + if (!years.contains(annee)) { + itLength.remove(); + } + } + return result; } @@ -1213,29 +1238,19 @@ * @param selection selection to search into * @return year list */ - public List<Integer> getProjectYears(Selection selection) { + public List<String> getProjectYears(Selection selection) { - SortedSet<Integer> years = new TreeSet<Integer>(); + SortedSet<String> years = new TreeSet<String>(); Iterator<String[]> itTuple = selection.getHaul().iterator(); itTuple.next(); // header while (itTuple.hasNext()) { String[] tuple = itTuple.next(); String year = tuple[Haul.INDEX_YEAR]; - try { - Integer integerYear = Integer.valueOf(year); - years.add(integerYear); - } - catch (NumberFormatException ex) { - // can't happen after control - // data must be all ok - if (log.isWarnEnabled()) { - log.warn("Can't convert year '" + year + "' to integer, but data must be correct after control :("); - } - } + years.add(year); } - List<Integer> result = new ArrayList<Integer>(years); + List<String> result = new ArrayList<String>(years); return result; } @@ -1276,14 +1291,12 @@ * * @param project project * @param container data container - * @param zoneName zone name - * @param beginYear begin year - * @param endYear end year + * @param strataNames strata names * @param filterSpecyType filterSpecyType * @return species */ - public List<String> getProjectSpecies(Project project, AbstractDataContainer container, List<String> zoneName, - Integer beginYear, Integer endYear, List<String> filterSpecyType) { + public List<String> getProjectSpecies(Project project, AbstractDataContainer container, List<String> strataNames, + List<String> filterSpecyType) { // first get traits list Set<String> traits = new HashSet<String>(); @@ -1294,22 +1307,11 @@ // Campagne;Annee;Trait;Mois;Strate;SurfaceBalayee;Lat;Long;ProfMoy String annee = tuple[Haul.INDEX_YEAR]; - try { - int intAnnee = Integer.parseInt(annee); - - if (intAnnee >= beginYear && intAnnee <= endYear) { - String strataName = tuple[Haul.INDEX_STRATUM]; - if (zoneName.contains(strataName)) { - String traitsName = tuple[Haul.INDEX_HAUL]; - traits.add(traitsName); - } - } + String strataName = tuple[Haul.INDEX_STRATUM]; + if (strataNames.contains(strataName)) { + String traitsName = tuple[Haul.INDEX_HAUL]; + traits.add(traitsName); } - catch (NumberFormatException ex) { - if (log.isWarnEnabled()) { - log.warn("Can't parse year '" + annee + "' as int, can't happen with controled data"); - } - } } // second get species with trait list @@ -1320,23 +1322,13 @@ String[] tuple = itTuple.next(); // "Campagne","Annee","Trait","Espece","Nombre","Poids" - String annee = tuple[Catch.INDEX_YEAR]; - try { - int intAnnee = Integer.parseInt(annee); - - String haul = tuple[Catch.INDEX_HAUL]; - if (intAnnee >= beginYear && intAnnee <= endYear && traits.contains(haul)) { - String species = tuple[Catch.INDEX_SPECIES]; - if (!result.contains(species)) { - result.add(species); - } - } + String haul = tuple[Catch.INDEX_HAUL]; + if (traits.contains(haul)) { + String species = tuple[Catch.INDEX_SPECIES]; + if (!result.contains(species)) { + result.add(species); + } } - catch (NumberFormatException ex) { - if (log.isWarnEnabled()) { - log.warn("Can't parse year '" + annee + "' as int, can't happen with controled data"); - } - } } // third, filter specy list with specy types filter @@ -1376,6 +1368,16 @@ String specy = itSpecies.next(); Integer specyNumSys = map.get(specy); + if (specyNumSys == null) { + // ca ne peut pas arriver, ce cs est valider + // par un control + if (log.isWarnEnabled()) { + log.warn("Can't find specy " + specy + " in reftax"); + } + itSpecies.remove(); + continue; + } + // test si le numsys est dans les bornes d'un // des type d'espece demandé boolean foundInFilter = false; Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-22 10:46:04 UTC (rev 243) @@ -63,9 +63,14 @@ coser.config.validator.directory.description= lat\ attribute\ is\ not\ a\ valid\ double= lat\ must\ contains\ at\ least\ 3\ decimal= +lat\ must\ contains\ at\ least\ 3\ decimals= +lat\ must\ contains\ at\ least\ 3\ decimasl= length\ attribute\ is\ not\ a\ valid\ double= long\ attribute\ is\ not\ a\ valid\ double= long\ must\ contains\ at\ least\ 3\ decimal= +long\ must\ contains\ at\ least\ 3\ decimals= number\ attribute\ is\ not\ a\ valid\ double= sweptSurface\ attribute\ is\ not\ a\ valid\ double= +sweptSurface\ must\ contains\ at\ least\ 3\ decimal= +sweptSurface\ must\ contains\ at\ least\ 3\ decimals= year\ is\ not\ valid= Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-22 10:46:04 UTC (rev 243) @@ -63,9 +63,14 @@ coser.config.validator.directory.description=Emplacement des fichiers de validations lat\ attribute\ is\ not\ a\ valid\ double= lat\ must\ contains\ at\ least\ 3\ decimal= +lat\ must\ contains\ at\ least\ 3\ decimals= +lat\ must\ contains\ at\ least\ 3\ decimasl= length\ attribute\ is\ not\ a\ valid\ double= long\ attribute\ is\ not\ a\ valid\ double= long\ must\ contains\ at\ least\ 3\ decimal= +long\ must\ contains\ at\ least\ 3\ decimals= number\ attribute\ is\ not\ a\ valid\ double= sweptSurface\ attribute\ is\ not\ a\ valid\ double= +sweptSurface\ must\ contains\ at\ least\ 3\ decimal= +sweptSurface\ must\ contains\ at\ least\ 3\ decimals= year\ is\ not\ valid= Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-22 10:46:04 UTC (rev 243) @@ -62,7 +62,7 @@ @Test public void testCatchChart() throws CoserBusinessException { Project project = createTestProject(projectService); - Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl()); + Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl(), null); JFreeChart chart = charts.get("COSER_SPECIES1"); JDialog f = new JDialog(); f.setModal(true); Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-22 10:46:04 UTC (rev 243) @@ -193,10 +193,10 @@ Project project = createTestProject(projectService); Selection selection = projectService.initProjectSelection(project); - List<Integer> years = projectService.getProjectYears(selection); + List<String> years = projectService.getProjectYears(selection); Assert.assertEquals(2, years.size()); - Assert.assertEquals(Integer.valueOf(2010), years.get(0)); - Assert.assertEquals(Integer.valueOf(2011), years.get(1)); + Assert.assertEquals("2010", years.get(0)); + Assert.assertEquals("2011", years.get(1)); } /** @@ -209,14 +209,24 @@ Project project = createTestProject(projectService); Selection selection = projectService.initProjectSelection(project); - List<String> zones = projectService.getProjectZone(selection, 2010, 2011); - Assert.assertEquals(6, zones.size()); + List<String> years = new ArrayList<String>(); + years.add("2010"); + years.add("2011"); + List<String> strata = projectService.filterDataYearsAndGetStrata(selection, years); + Assert.assertEquals(6, strata.size()); + + List<String> years2 = new ArrayList<String>(); + years2.add("2009"); + strata = projectService.filterDataYearsAndGetStrata(selection, years2); + Assert.assertEquals(0, strata.size()); + + List<String> years3 = new ArrayList<String>(); + years3.add("2011"); + // doit recharger les données pour être correct + strata = projectService.filterDataYearsAndGetStrata(selection, years3); + Assert.assertEquals(3, strata.size()); - zones = projectService.getProjectZone(selection, 2011, 2011); - Assert.assertEquals(3, zones.size()); - zones = projectService.getProjectZone(selection, 2009, 2009); - Assert.assertEquals(0, zones.size()); } /** @@ -229,29 +239,29 @@ Project project = createTestProject(projectService); Selection selection = projectService.initProjectSelection(project); - List<String> allZones = new ArrayList<String>(); - allZones.add("STR1"); - allZones.add("STR2"); - allZones.add("STR3"); - allZones.add("STR4"); - allZones.add("STR5"); - allZones.add("STR6"); + List<String> allStrata = new ArrayList<String>(); + allStrata.add("STR1"); + allStrata.add("STR2"); + allStrata.add("STR3"); + allStrata.add("STR4"); + allStrata.add("STR5"); + allStrata.add("STR6"); - List<String> species = projectService.getProjectSpecies(project, selection, allZones, 2010, 2011, null); + List<String> species = projectService.getProjectSpecies(project, selection, allStrata, null); Assert.assertEquals(4, species.size()); - species = projectService.getProjectSpecies(project, selection, allZones, 2011, 2011, null); + species = projectService.getProjectSpecies(project, selection, allStrata, null); Assert.assertEquals(4, species.size()); - species = projectService.getProjectSpecies(project, selection, allZones, 2009, 2009, null); + species = projectService.getProjectSpecies(project, selection, allStrata, null); Assert.assertEquals(0, species.size()); - // test with no zones - species = projectService.getProjectSpecies(project, selection, new ArrayList<String>(), 2010, 2011, null); + // test with no strata + species = projectService.getProjectSpecies(project, selection, new ArrayList<String>(), null); Assert.assertEquals(0, species.size()); - // test with only one zone - species = projectService.getProjectSpecies(project, selection, Collections.singletonList("STR6"), 2010, 2011, null); + // test with only one stratum + species = projectService.getProjectSpecies(project, selection, Collections.singletonList("STR6"), null); Assert.assertEquals(4, species.size()); } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-22 10:46:04 UTC (rev 243) @@ -381,8 +381,11 @@ selectionView.setEnabledAt(2, false); // rsufi // fix, binding not working ? selectionView.getSelectionDetailsTab().getValidatorSelection().setBean(selection); - selectionView.setHandler(new SelectionHandler()); + SelectionHandler handler = new SelectionHandler(); + selectionView.setHandler(handler); + handler.initSelection(selectionView); + try { File file = new File("/home/chatellier/tmp/coser/zones.png"); selectionView.getSelectionDetailsTab().getZonesMap().setImage(file); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-22 10:46:04 UTC (rev 243) @@ -710,7 +710,7 @@ Project project = view.getContextValue(Project.class); ChartService chartService = view.getContextValue(ChartService.class); - Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl()); + Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl(), null); List<String> species = new ArrayList<String>(charts.keySet()); ControlGraphDialog dialog = new ControlGraphDialog(view); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-22 10:46:04 UTC (rev 243) @@ -30,7 +30,7 @@ void $afterCompleteSetup() { // modification (species -> selection model) - specyListModel.addListDataListener((CoserListSelectionModel)specyList.getSelectionModel()); + filteredSpecyListModel.addListDataListener((CoserListSelectionModel)filteredSpecyList.getSelectionModel()); } ]]></script> @@ -55,7 +55,7 @@ <cell anchor="west"> <JLabel text="coser.ui.selection.details.name" /> </cell> - <cell weightx="1" fill="horizontal" columns="3"> + <cell weightx="1" fill="horizontal"> <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}" enabled="{isCreationState()}"/> <javax.swing.text.Document javaBean="detailsSelectionNameField.getDocument()" @@ -67,7 +67,7 @@ <cell anchor="west"> <JLabel text="coser.ui.selection.details.description" /> </cell> - <cell weightx="1" fill="horizontal" columns="3"> + <cell weightx="1" fill="horizontal"> <JScrollPane> <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3" /> </JScrollPane> @@ -78,77 +78,127 @@ </row> <row> <cell anchor="west"> - <JLabel text="coser.ui.selection.details.beginDate" /> + <JLabel text="coser.ui.selection.details.dates" /> </cell> - <cell weightx="1" fill="horizontal"> - <YearComboBoxModel id="beginYearComboBoxModel" constructorParams="this" /> - <JComboBox id="beginYearComboBox" - model="{beginYearComboBoxModel}" - onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setBeginDate((Integer)beginYearComboBox.getSelectedItem())" /> + <cell weighty="1" weightx="1" fill="both"> + <JScrollPane> + <YearListModel id="datesListModel" /> + <JList id="datesList" model="{datesListModel}" + onValueChanged="validDatesButton.setEnabled(true)" + selectionModel="{new CoserListSelectionModel(datesList.getSelectionModel(), datesListModel)}" /> + <ListSelectionModel id="datesListSelectionModel" javaBean="datesList.getSelectionModel()" /> + </JScrollPane> </cell> - <cell anchor="west"> - <JLabel text="coser.ui.selection.details.endDate" /> + </row> + <row> + <cell anchor="east" columns="2"> + <JButton id="validDatesButton" text="coser.ui.selection.details.validDates" + onActionPerformed="getHandler().updateSelectionDateData(this);" /> </cell> - <cell weightx="1" fill="horizontal"> - <YearComboBoxModel id="endYearComboBoxModel" constructorParams="this" /> - <JComboBox id="endYearComboBox" - model="{endYearComboBoxModel}" - onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setEndDate((Integer)endYearComboBox.getSelectedItem())" /> - </cell> </row> <row> - <cell fill="horizontal" columns="3"> + <cell fill="horizontal"> <JLabel text="coser.ui.selection.details.strata" /> </cell> <cell anchor="east"> <JButton icon="map.png" toolTipText="coser.ui.selection.details.showMapTip" - onActionPerformed='getDetailDesisionPanelLayout().show(getDetailDesisionPanel(), "ZONEMAP");' /> + onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "ZONEMAP");' /> </cell> </row> <row> - <cell weighty="2" fill="both" columns="4"> + <cell weighty="2" fill="both" columns="2"> <JScrollPane> - <ZoneListModel id="zoneListModel" /> - <JList id="zoneList" model="{zoneListModel}" - enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}" - selectionModel="{new CoserListSelectionModel(zoneList.getSelectionModel(), zoneListModel)}" - onValueChanged="getHandler().zoneListChanged(this, event);"/> + <StrataListModel id="strataListModel" /> + <JList id="strataList" model="{strataListModel}" + selectionModel="{new CoserListSelectionModel(strataList.getSelectionModel(), strataListModel)}" + onValueChanged="validStrataButton.setEnabled(true)"/> </JScrollPane> </cell> </row> <row> - <cell weighty="2" fill="both" columns="4"> - <Table border='{BorderFactory.createTitledBorder(_("coser.ui.selection.details.species"))}'> + <cell anchor="east" columns="2"> + <JButton id="validStrataButton" text="coser.ui.selection.details.validStrata" + onActionPerformed="getHandler().strataListChanged(this)" /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.selection.details.type" /> + </cell> + <cell anchor="east"> + <JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpreciesTip" + onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "SPECIESDATA");getHandler().showSamplingEffort(this);' /> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" columns="2"> + <JScrollPane> + <SpecyTypesListModel id="typeSpecyModel" constructorParams="this" /> + <JList id="typeSpecyList" model="{typeSpecyModel}" + selectionModel="{new CoserListSelectionModel(typeSpecyList.getSelectionModel(), typeSpecyModel)}" + onValueChanged="validFilterButton.setEnabled(true)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor="east" columns="2"> + <JButton id="validFilterButton" text="coser.ui.selection.details.validFilter" + onActionPerformed="getHandler().updateSelectionSpecies(this)" /> + </cell> + </row> + <row> + <cell weighty="2" fill="both" columns="2"> + <Table> <row> + <cell fill="horizontal" columns="2"> + <JLabel text="coser.ui.selection.details.filteredSpecies" /> + </cell> <cell fill="horizontal"> - <JLabel text="coser.ui.selection.details.type" /> + <JLabel text="coser.ui.selection.details.selectedSpecies" /> </cell> - <cell anchor="east"> - <JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpreciesTip" - onActionPerformed='getDetailDesisionPanelLayout().show(getDetailDesisionPanel(), "SPECIESDATA");getHandler().showSamplingEffort(this);' /> - </cell> </row> <row> - <cell fill="both" weightx="1" weighty="1" columns="2"> + <cell weightx="1" weighty="1" fill="both"> <JScrollPane> - <SpecyTypesListModel id="typeSpecyModel" constructorParams="this" /> - <JList id="typeSpecyList" model="{typeSpecyModel}" - enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}" - selectionModel="{new CoserListSelectionModel(typeSpecyList.getSelectionModel(), typeSpecyModel)}" - onValueChanged="getHandler().typeSpecyListChanged(this, event)"/> + <SpecyListModel id="filteredSpecyListModel" /> + <JList id="filteredSpecyList" model="{filteredSpecyListModel}" + onMouseClicked="getHandler().showSpeciesContextMenu(this, event)" + selectionModel="{new CoserListSelectionModel(filteredSpecyList.getSelectionModel(), filteredSpecyListModel)}" /> + <ListSelectionModel id="filteredSpecyListSelectionModel" javaBean="filteredSpecyList.getSelectionModel()" /> </JScrollPane> </cell> - </row> - <row> - <cell weighty="2" fill="both" columns="2"> + <cell anchor="north"> + <Table> + <row> + <cell> + <JButton icon="arrow_right.png" + onActionPerformed="getHandler().addSelectedFilteredSpecies(this)" + enabled="{getFilteredSpecyList().getSelectedIndex() != -1}"/> + </cell> + </row> + <row> + <cell> + <JButton icon="arrow_left.png" + onActionPerformed="getHandler().removeSelectedSpecies(this)" + enabled="{getSelectedSpecyList().getSelectedIndex() != -1}"/> + </cell> + </row> + <row> + <cell> + <JButton icon="chart_curve.png" + onActionPerformed='getHandler().showSelectedSpeciesGraph(this, "SPECIESGRAPH")' + enabled="{getFilteredSpecyList().getSelectedIndex() != -1}" /> + </cell> + </row> + </Table> + </cell> + <cell weightx="1" weighty="1" fill="both"> <JScrollPane> - <SpecyListModel id="specyListModel" /> - <JList id="specyList" model="{specyListModel}" - enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}" + <SpecyListModel id="selectedSpecyListModel" /> + <JList id="selectedSpecyList" model="{selectedSpecyListModel}" onMouseClicked="getHandler().showSpeciesContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(specyList.getSelectionModel(), specyListModel)}" - onValueChanged="getHandler().specyListChanged(this, event)"/> - <ListSelectionModel id="specyListSelectionModel" javaBean="specyList.getSelectionModel()" /> + selectionModel="{new CoserListSelectionModel(selectedSpecyList.getSelectionModel(), selectedSpecyListModel)}" /> + <ListSelectionModel id="selectedSpecyListSelectionModel" javaBean="selectedSpecyList.getSelectionModel()" /> </JScrollPane> </cell> </row> @@ -156,32 +206,38 @@ </cell> </row> <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.selection.details.comment" /> + </cell> <cell weighty="1" fill="both" columns="4"> <JScrollPane> - <JXTextArea id="detailsComment" constructorParams='_("coser.ui.selection.details.comment")' rows="3" /> + <JTextArea id="detailsComment" rows="3" /> <javax.swing.text.Document javaBean="detailsComment.getDocument()" - onInsertUpdate='getSelection().setComment(detailsComment.getText())' - onRemoveUpdate='getSelection().setComment(detailsComment.getText())' /> + onInsertUpdate='getSelection().setComment(detailsComment.getText())' + onRemoveUpdate='getSelection().setComment(detailsComment.getText())' /> </JScrollPane> </cell> </row> <row> - <cell fill="horizontal" columns="4"> + <cell fill="horizontal" columns="1"> <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection" onActionPerformed="getHandler().saveSelection(this)" /> </cell> </row> </Table> </cell> - <cell weightx="4" weighty="1" fill="both" rows="2"> - <CardLayout id="detailDesisionPanelLayout" /> - <JPanel id="detailDesisionPanel" layout="{detailDesisionPanelLayout}"> + <cell weightx="3" weighty="1" fill="both"> + <CardLayout id="detailDecisionPanelLayout" /> + <JPanel id="detailDecisionPanel" layout="{detailDecisionPanelLayout}"> <JScrollPane id="zonesScrollPane" constraints='"ZONEMAP"'> <JXImageView id="zonesMap" /> </JScrollPane> <JScrollPane constraints='"SPECIESDATA"'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanelEditor" /> </JScrollPane> + <JScrollPane constraints='"SPECIESGRAPH"'> + <JPanel id="speciesGraphPanel" layout="{new GridBagLayout()}"/> + </JScrollPane> </JPanel> </cell> </row> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-22 10:46:04 UTC (rev 243) @@ -26,22 +26,30 @@ import static org.nuiton.i18n.I18n._; import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Set; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.event.ChangeEvent; -import javax.swing.event.ListSelectionEvent; import jaxx.runtime.JAXXUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; import org.nuiton.math.matrix.MatrixND; import org.nuiton.math.matrix.gui.MatrixTableModelND; @@ -49,6 +57,7 @@ import fr.ifremer.coser.CoserException; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.services.ChartService; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; import fr.ifremer.coser.ui.util.CoserListSelectionModel; @@ -69,6 +78,9 @@ /** * Appelé sur un changement d'onglet dans l'interface de sélection. * + * Les listes L1à4 n'ecoute pas directement les modification du premier + * onglet. Opération manuelle, calcul de matrice en plus. + * * @param view view * @param event change event */ @@ -89,7 +101,7 @@ // on met à jour la liste de "Toutes les especes" (L1) List<String> currentList = selectionListsView.getSelectionAllSpeciesListModel().getSpecies(); - List<String> selectionSpecyList = selection.getSpecies(); + List<String> selectionSpecyList = selection.getSelectedSpecies(); if (!selectionSpecyList.equals(currentList)) { // on calcul également les matrices de d'occurence, densité @@ -116,6 +128,25 @@ } /** + * Initialize certains donnés différement que le ferait le rechargement + * d'une selection. + * + * @param view view + */ + public void initSelection(SelectionView view) { + ProjectService projectService = view.getContextValue(ProjectService.class); + Selection selection = view.getContextValue(Selection.class); + + // initialize la liste de toutes les années + // c'est normalement la seule initialisation a faire + SelectionDetailsView detailView = view.getSelectionDetailsTab(); + List<String> allYears = projectService.getProjectYears(selection); + detailView.getDatesListModel().setYears(allYears); + // tout est selectionné par defaut + ((CoserListSelectionModel)detailView.getDatesList().getSelectionModel()).setSelectedObjects(allYears); + } + + /** * Recharge la selection en valorisant les différentes listes. * * Fait ici, car sinon, les evenements ne se déclenchent pas au même @@ -133,13 +164,17 @@ // fill details view SelectionDetailsView detailView = view.getSelectionDetailsTab(); - detailView.getBeginYearComboBox().setSelectedItem(selection.getBeginDate()); - detailView.getEndYearComboBox().setSelectedItem(selection.getEndDate()); - // "typeSpecies" before other, more performant - ((CoserListSelectionModel)detailView.getTypeSpecyList().getSelectionModel()).setSelectedObjects(selection.getFilterSpecyTypes()); - ((CoserListSelectionModel)detailView.getZoneList().getSelectionModel()).setSelectedObjects(selection.getZones()); - ((CoserListSelectionModel)detailView.getSpecyList().getSelectionModel()).setSelectedObjects(selection.getSpecies()); + detailView.getDatesListModel().setYears(selection.getAllYears()); + ((CoserListSelectionModel)detailView.getDatesList().getSelectionModel()).setSelectedObjects(selection.getSelectedYears()); + // fill strata data and selection + updateSelectionDateData(detailView); + ((CoserListSelectionModel)detailView.getStrataList().getSelectionModel()).setSelectedObjects(selection.getSelectedStrata()); + + // fill specy list and selection + strataListChanged(detailView); + detailView.getSelectedSpecyListModel().setSpecies(selection.getSelectedSpecies()); + if (log.isDebugEnabled()) { log.debug("Selection reloaded."); } @@ -149,82 +184,47 @@ * Rafraichit la liste des zones suite à la selection des dates. * * @param view view - * @param event event de la selection (combo) */ - public void updateSelectionDateData(SelectionDetailsView view, ActionEvent event) { - //Project project = view.getContextValue(Project.class); + public void updateSelectionDateData(SelectionDetailsView view) { Selection selection = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); + + // get selected zones as list + Object[] selectedDates = view.getDatesList().getSelectedValues(); + List<String> years = new ArrayList<String>(selectedDates.length); + for (Object selectedDate : selectedDates) { + years.add((String)selectedDate); + } + selection.setSelectedYears(years); - Integer beginYear = (Integer)view.getBeginYearComboBox().getSelectedItem(); - Integer endYear = (Integer)view.getEndYearComboBox().getSelectedItem(); - - // il est possible que l'evenement fasse suite a une seule des selections - if (beginYear != null && endYear != null) { - if (log.isDebugEnabled()) { - log.debug("Refreshing zones list"); - } - List<String> zones = projectService.getProjectZone(selection, beginYear, endYear); - view.getZoneListModel().setZones(zones); + if (log.isDebugEnabled()) { + log.debug("Refreshing zones list"); } + List<String> strata = projectService.filterDataYearsAndGetStrata(selection, years); + view.getStrataListModel().setStrata(strata); } /** * Appellé lorsque la selection de la liste des zones a changé. * * @param view view - * @param event event */ - public void zoneListChanged(SelectionDetailsView view, ListSelectionEvent event) { + public void strataListChanged(SelectionDetailsView view) { + if (log.isDebugEnabled()) { + log.debug("Zone list selection changed, updating species list"); + } - // reload is slow without it - if (!event.getValueIsAdjusting()) { + Selection selection = view.getContextValue(Selection.class); - if (log.isDebugEnabled()) { - log.debug("Zone list selection changed, updating species list"); - } - - Selection selection = view.getContextValue(Selection.class); - - // get selected zones as list - Object[] selectedZones = view.getZoneList().getSelectedValues(); - List<String> zones = new ArrayList<String>(selectedZones.length); - for (Object selectedZone : selectedZones) { - zones.add((String)selectedZone); - } - selection.setZones(zones); - - updateSelectionSpecies(view); + // get selected zones as list + Object[] selectedStrata = view.getStrataList().getSelectedValues(); + List<String> strata = new ArrayList<String>(selectedStrata.length); + for (Object selectedStratum : selectedStrata) { + strata.add((String)selectedStratum); } - } + selection.setSelectedStrata(strata); - /** - * Appelé lorsque la selection de la liste des types. - * - * @param view view - * @param event event - */ - public void typeSpecyListChanged(SelectionDetailsView view, ListSelectionEvent event) { - - // reload is slow without it - if (!event.getValueIsAdjusting()) { - - if (log.isDebugEnabled()) { - log.debug("Specy type selection changed, updating species list"); - } - - Selection selection = view.getContextValue(Selection.class); - - // get selected specy types - Object[] selectedSpecyTypes = view.getTypeSpecyList().getSelectedValues(); - List<String> specyTypes = new ArrayList<String>(); - for (Object selectedSpecyType : selectedSpecyTypes) { - specyTypes.add((String)selectedSpecyType); - } - selection.setFilterSpecyTypes(specyTypes); - - updateSelectionSpecies(view); - } + updateSelectionSpecies(view); } /** @@ -247,7 +247,7 @@ ProjectService projectService = view.getContextValue(ProjectService.class); // get selected zones as list - List<String> zones = selection.getZones(); + List<String> strata = selection.getSelectedStrata(); // get selected specy types Object[] selectedSpecyTypes = view.getTypeSpecyList().getSelectedValues(); @@ -255,47 +255,15 @@ for (Object selectedSpecyType : selectedSpecyTypes) { specyTypes.add((String)selectedSpecyType); } - - Integer beginYear = (Integer)view.getBeginYearComboBox().getSelectedItem(); - Integer endYear = (Integer)view.getEndYearComboBox().getSelectedItem(); - // il est possible que l'evenement fasse suite a une seule des selections - if (beginYear != null && endYear != null && zones != null) { - List<String> species = projectService.getProjectSpecies(project, selection, zones, beginYear, endYear, specyTypes); - view.getSpecyListModel().setSpecies(species); - } + List<String> species = projectService.getProjectSpecies(project, selection, strata, specyTypes); + view.getFilteredSpecyListModel().setSpecies(species); } /** - * Appelé lorsque la selection de la liste des especes change. + * Affiche un menu contextuel lors du clic (droit) sur la liste filtrées des especes. * * @param view view - * @param event event - */ - public void specyListChanged(SelectionDetailsView view, ListSelectionEvent event) { - - if (!event.getValueIsAdjusting()) { - - if (log.isDebugEnabled()) { - log.debug("Species selection changed, updating registered species"); - } - - Selection selection = view.getContextValue(Selection.class); - - // get selected species - Object[] selectedSpecies = view.getSpecyList().getSelectedValues(); - List<String> species= new ArrayList<String>(); - for (Object selectedSpecy : selectedSpecies) { - species.add((String)selectedSpecy); - } - selection.setSpecies(species); - } - } - - /** - * Affiche un menu contextuel lors du clic (droit) sur la liste des especes. - * - * @param view view * @param event mouse event */ public void showSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { @@ -306,7 +274,7 @@ JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.selection.speciesMenuLabel")); // affiche le menu contextuel si au moins 2 especes selectionnées - int[] selectedRows = view.getSpecyList().getSelectedIndices(); + int[] selectedRows = view.getFilteredSpecyList().getSelectedIndices(); if (selectedRows.length > 1) { // merge menu JMenuItem fusionMenu = new JMenuItem(_("coser.ui.selection.speciesMenuFusion")); @@ -317,7 +285,7 @@ speciesFusionDialog.setHandler(SelectionHandler.this); // pre fill new speci name with first selected specy name - String firstSelected = (String)view.getSpecyList().getSelectedValue(); + String firstSelected = (String)view.getFilteredSpecyList().getSelectedValue(); speciesFusionDialog.getNewSpeciesNameField().setText(firstSelected); speciesFusionDialog.setLocationRelativeTo(view); @@ -332,8 +300,8 @@ selectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - int size = view.getSpecyList().getModel().getSize(); - view.getSpecyList().getSelectionModel().addSelectionInterval(0, size - 1); + int size = view.getFilteredSpecyList().getModel().getSize(); + view.getFilteredSpecyList().getSelectionModel().addSelectionInterval(0, size - 1); } }); popupMenu.add(selectAllMenu); @@ -343,12 +311,12 @@ unselectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - view.getSpecyList().getSelectionModel().clearSelection(); + view.getFilteredSpecyList().getSelectionModel().clearSelection(); } }); popupMenu.add(unselectAllMenu); - popupMenu.show(view.getSpecyList(), event.getX(), event.getY()); + popupMenu.show(view.getFilteredSpecyList(), event.getX(), event.getY()); } } @@ -455,7 +423,7 @@ } else { SelectionDetailsView parent = view.getContextValue(SelectionDetailsView.class, JAXXUtil.PARENT); - Object[] selectedSpecies = parent.getSpecyList().getSelectedValues(); + Object[] selectedSpecies = parent.getFilteredSpecyList().getSelectedValues(); String[] specyNames = new String[selectedSpecies.length]; for (int i = 0 ; i < selectedSpecies.length ; ++i) { String selectedSpecy = (String)selectedSpecies[i]; @@ -487,4 +455,106 @@ view.getMatrixPanelEditor().getTable().setDefaultRenderer(String.class, new SamplingEffortRenderer((MatrixTableModelND)view.getMatrixPanelEditor().getTableModel())); } + + /** + * Ajout les especes filtrées selectionnées dans la liste des especes + * selectionnées. + * + * @param view view + */ + public void addSelectedFilteredSpecies(SelectionDetailsView view) { + + Selection selection = view.getContextValue(Selection.class); + + // get selected species + Object[] selectedFilteredSpecies = view.getFilteredSpecyList().getSelectedValues(); + Set<String> selectedSpecies = new HashSet<String>(); + if (view.getSelectedSpecyListModel().getSpecies() != null) { + selectedSpecies.addAll(view.getSelectedSpecyListModel().getSpecies()); + } + for (Object selectedFilteredSpecy : selectedFilteredSpecies) { + selectedSpecies.add((String)selectedFilteredSpecy); + } + + List<String> speciesList = new ArrayList<String>(selectedSpecies); + selection.setSelectedSpecies(speciesList); + view.getSelectedSpecyListModel().setSpecies(speciesList); + } + + /** + * Retire les especes selectionnées de la liste des esepeces sélectionnées. + * + * @param view + */ + public void removeSelectedSpecies(SelectionDetailsView view) { + + Selection selection = view.getContextValue(Selection.class); + + List<String> selectedSpecies = view.getSelectedSpecyListModel().getSpecies(); + Object[] selectedSelectedSpecies = view.getSelectedSpecyList().getSelectedValues(); + for (Object selectedSelectedSpecy : selectedSelectedSpecies) { + selectedSpecies.remove(selectedSelectedSpecy); + } + selection.setSelectedSpecies(selectedSpecies); + view.getSelectedSpecyListModel().setSpecies(selectedSpecies); + } + + /** + * Affiche les graphes de différence captures/taille dans le panel + * reféréncé par {@code cardLayoutContraints}. + * + * @param view view + * @param cardLayoutContraints + */ + public void showSelectedSpeciesGraph(SelectionDetailsView view, String cardLayoutContraints) { + + ChartService chartService = view.getContextValue(ChartService.class); + Project project = view.getContextValue(Project.class); + Selection selection = view.getContextValue(Selection.class); + + Object[] selectedFilteredSpecies = view.getFilteredSpecyList().getSelectedValues(); + Set<String> graphSpecies = new HashSet<String>(); + for (Object selectedFilteredSpecy : selectedFilteredSpecies) { + graphSpecies.add((String)selectedFilteredSpecy); + } + + Map<String, JFreeChart> chartsMap = chartService.getCompareCatchLengthGraph(project, selection, graphSpecies); + Collection<JFreeChart> charts = chartsMap.values(); + + view.getSpeciesGraphPanel().removeAll(); + Iterator<JFreeChart> itCharts = charts.iterator(); + int chartIndex = 0; + while (itCharts.hasNext()) { + JFreeChart chart = itCharts.next(); + + ChartPanel chartPanel = new ChartPanel(chart); + view.getSpeciesGraphPanel().add(chartPanel, + new GridBagConstraints(0, chartIndex, 1, 1, 1, 1, GridBagConstraints.CENTER, + GridBagConstraints.BOTH, new Insets(0, 3, 3, 3), 0, 0)); + chartIndex++; + } + view.getDetailDecisionPanelLayout().show(view.getDetailDecisionPanel(), cardLayoutContraints); + } + + /* + * Appelé lorsque la selection de la liste des especes change. + * + * @param view view + * + public void specyListChanged(SelectionDetailsView view) { + + if (log.isDebugEnabled()) { + log.debug("Species selection changed, updating registered species"); + } + + Selection selection = view.getContextValue(Selection.class); + + // get selected species + Object[] selectedSpecies = view.getSelectedSpecyList().getSelectedValues(); + List<String> species= new ArrayList<String>(); + for (Object selectedSpecy : selectedSpecies) { + species.add((String)selectedSpecy); + } + selection.setSelectedSpecies(species); + }*/ } Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java 2010-11-22 10:46:04 UTC (rev 243) @@ -0,0 +1,84 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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 3 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.List; + +import javax.swing.AbstractListModel; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Model contenant la liste des noms de strates (utilisé dans le detail de selection). + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class StrataListModel extends AbstractListModel implements CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8155676616312843132L; + + protected List<String> strata; + + public List<String> getStrata() { + return strata; + } + + public void setStrata(List<String> strata) { + this.strata = strata; + fireContentsChanged(this, 0, strata.size()); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + if (strata != null) { + size = strata.size(); + } + return size; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return strata.get(index); + } + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object element) { + return strata.indexOf(element); + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java 2010-11-22 10:46:04 UTC (rev 243) @@ -1,102 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 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 3 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection.model; - -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.ComboBoxModel; - -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.services.ProjectService; -import fr.ifremer.coser.ui.selection.SelectionDetailsView; - -/** - * Model pour combo box contenant la liste des années définies dans le projet. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class YearComboBoxModel extends AbstractListModel implements ComboBoxModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = 9172638630862188715L; - - protected SelectionDetailsView view; - - protected List<Integer> years; - - protected Object selectedItem; - - public YearComboBoxModel(SelectionDetailsView view) { - super(); - this.view = view; - } - - protected List<Integer> getYear() { - if (years == null) { - Selection selection = view.getContextValue(Selection.class); - ProjectService service = view.getContextValue(ProjectService.class); - years = service.getProjectYears(selection); - } - return years; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - return getYear().size(); - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return getYear().get(index); - } - - /* - * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object) - */ - @Override - public void setSelectedItem(Object anItem) { - selectedItem = anItem; - } - - /* - * @see javax.swing.ComboBoxModel#getSelectedItem() - */ - @Override - public Object getSelectedItem() { - return selectedItem; - } -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java 2010-11-22 10:46:04 UTC (rev 243) @@ -0,0 +1,90 @@ +/* + * #%L + * Coser :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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 3 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.List; + +import javax.swing.AbstractListModel; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Model pour list contenant la liste des années définies dans le projet et + * en selection la liste des années définie pour la selection. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class YearListModel extends AbstractListModel implements CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 9172638630862188715L; + + protected List<String> years; + + public YearListModel() { + super(); + } + + public List<String> getYears() { + return years; + } + + public void setYears(List<String> years) { + this.years = years; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (getYears() != null) { + result = getYears().size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return getYears().get(index); + } + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object element) { + return getYears().indexOf(element); + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java 2010-11-22 10:46:04 UTC (rev 243) @@ -1,84 +0,0 @@ -/* - * #%L - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 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 3 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection.model; - -import java.util.List; - -import javax.swing.AbstractListModel; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Model contenant la liste des noms de zone (utilisé dans le detail de selection). - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class ZoneListModel extends AbstractListModel implements CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -8155676616312843132L; - - protected List<String> zones; - - public List<String> getZones() { - return zones; - } - - public void setZones(List<String> zones) { - this.zones = zones; - fireContentsChanged(this, 0, zones.size()); - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int size = 0; - if (zones != null) { - size = zones.size(); - } - return size; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return zones.get(index); - } - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object element) { - return zones.indexOf(element); - } -} Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-22 10:46:04 UTC (rev 243) @@ -102,15 +102,21 @@ coser.ui.selection.createError=Creation error coser.ui.selection.details.beginDate=Begin date \: coser.ui.selection.details.comment=Comments +coser.ui.selection.details.dates= coser.ui.selection.details.description=Description \: coser.ui.selection.details.endDate=End date \: +coser.ui.selection.details.filteredSpecies= coser.ui.selection.details.name=Selection name \: coser.ui.selection.details.saveSelection=Save selection +coser.ui.selection.details.selectedSpecies= coser.ui.selection.details.showMapTip= coser.ui.selection.details.showSpreciesTip= coser.ui.selection.details.species=Species \: coser.ui.selection.details.strata=Strata \: coser.ui.selection.details.type= +coser.ui.selection.details.validDates= +coser.ui.selection.details.validFilter= +coser.ui.selection.details.validStrata= coser.ui.selection.filter.density=Density \: coser.ui.selection.filter.filter=Filter coser.ui.selection.filter.occurrence=Occurrence \: Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-21 14:24:33 UTC (rev 242) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-22 10:46:04 UTC (rev 243) @@ -100,17 +100,21 @@ coser.ui.result.rsufiVersion=Version de RSufi \: coser.ui.selection.allSpecies=L1 \: Toutes les esp\u00E8ces coser.ui.selection.createError=Erreur de cr\u00E9action -coser.ui.selection.details.beginDate=Date de d\u00E9but \: -coser.ui.selection.details.comment=Commentaire +coser.ui.selection.details.comment=Commentaire \: +coser.ui.selection.details.dates=Ann\u00E9es \: coser.ui.selection.details.description=Description \: -coser.ui.selection.details.endDate=Date de fin \: +coser.ui.selection.details.filteredSpecies=Esp\u00E8ces filtr\u00E9es \: coser.ui.selection.details.name=Nom de la s\u00E9lection \: -coser.ui.selection.details.saveSelection=Sauvegarder la s\u00E9lection +coser.ui.selection.details.saveSelection=Sauvegarder la s\u00E9lection \: +coser.ui.selection.details.selectedSpecies=Esp\u00E8ces s\u00E9lectionn\u00E9es \: coser.ui.selection.details.showMapTip=Afficher la carte des zones coser.ui.selection.details.showSpreciesTip=Afficher la table des esp\u00E8ces coser.ui.selection.details.species=Esp\u00E8ces \: coser.ui.selection.details.strata=Strates \: coser.ui.selection.details.type=Filtrer par type \: +coser.ui.selection.details.validDates=Valider les ann\u00E9es +coser.ui.selection.details.validFilter=Valider les filtres +coser.ui.selection.details.validStrata=Valider les strates coser.ui.selection.filter.density=Densit\u00E9 \: coser.ui.selection.filter.filter=Filtrer coser.ui.selection.filter.occurrence=Occurence \: Added: trunk/coser-ui/src/main/resources/icons/arrow_left.png =================================================================== (Binary files differ) Property changes on: trunk/coser-ui/src/main/resources/icons/arrow_left.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/coser-ui/src/main/resources/icons/arrow_right.png =================================================================== (Binary files differ) Property changes on: trunk/coser-ui/src/main/resources/icons/arrow_right.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream