Author: chatellier
Date: 2011-02-10 18:25:39 +0000 (Thu, 10 Feb 2011)
New Revision: 736
Log:
Fix data filtering after data validation
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.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/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-02-10 18:25:39 UTC (rev 736)
@@ -95,6 +95,9 @@
/**
* Service business method relative to project.
*
+ * Interessant à savoir, l'ordre pour traiter les fichiers correctement est:
+ * {@code Strates > Traits > Captures > Tailles}
+ *
* @author chatellier
* @version $Revision$
*
@@ -1593,8 +1596,34 @@
}
/**
- * Get zones name in project with data in [{@code beginYear}-{@code endYear}].
+ * Find all defined year in model.
*
+ * Le parcours est fait sur le fichier "haul", c'est potentiellement
+ * le plus petit.
+ *
+ * Used in selection ui.
+ *
+ * @param selection selection to search into
+ * @return year list
+ */
+ public List<String> getProjectYears(Selection selection) {
+
+ SortedSet<String> years = new TreeSet<String>();
+
+ Iterator<String[]> itTuple = selection.getHaul().iterator(true);
+ while (itTuple.hasNext()) {
+ String[] tuple = itTuple.next();
+ String year = tuple[Haul.INDEX_YEAR];
+ years.add(year);
+ }
+
+ List<String> result = new ArrayList<String>(years);
+ return result;
+ }
+
+ /**
+ * Get strata name in project with data in selected {@code years}.
+ *
* This methods set {@link Selection#setSelectedYears(List)}, and use
* it to known if control data need to be reloaded (don't set it yourself).
*
@@ -1602,14 +1631,14 @@
*
* @param project project
* @param selection selection
- * @param years selected years
+ * @param selectedYears selected years
* @return zones
* @throws CoserBusinessException
*/
- public List<String> filterDataYearsAndGetStrata(Project project, Selection selection, List<String> years) throws CoserBusinessException {
+ public List<String> filterDataYearsAndGetStrata(Project project, Selection selection, List<String> selectedYears) throws CoserBusinessException {
List<String> currentSelectionYears = selection.getSelectedYears();
- if (currentSelectionYears == null || !currentSelectionYears.containsAll(years)) {
+ if (currentSelectionYears == null || !currentSelectionYears.containsAll(selectedYears)) {
// la liste des nouvelles année est plus grande que la liste
// actuelle des données de la selection
// les données doivent être rechargée
@@ -1622,9 +1651,9 @@
Iterator<String[]> itHaul = selection.getHaul().iterator(true);
while (itHaul.hasNext()) {
String[] tupleHaul = itHaul.next();
- String annee = tupleHaul[Haul.INDEX_YEAR];
+ String year = tupleHaul[Haul.INDEX_YEAR];
- if (!years.contains(annee)) {
+ if (!selectedYears.contains(year)) {
itHaul.remove();
}
else {
@@ -1636,46 +1665,111 @@
}
if (log.isDebugEnabled()) {
- log.debug("Haul data filtered by " + years);
+ log.debug("Haul data filtered by " + selectedYears);
}
// manage catch
Iterator<String[]> itCatch = selection.getCatch().iterator(true);
while (itCatch.hasNext()) {
String[] tupleCatch = itCatch.next();
- String annee = tupleCatch[Catch.INDEX_YEAR];
+ String year = tupleCatch[Catch.INDEX_YEAR];
- if (!years.contains(annee)) {
+ if (!selectedYears.contains(year)) {
itCatch.remove();
}
}
if (log.isDebugEnabled()) {
- log.debug("Catch data filtered by " + years);
+ log.debug("Catch data filtered by " + selectedYears);
}
// manage length
Iterator<String[]> itLength = selection.getLength().iterator(true);
while (itLength.hasNext()) {
String[] tupleLength = itLength.next();
- String annee = tupleLength[Length.INDEX_YEAR];
+ String year = tupleLength[Length.INDEX_YEAR];
- if (!years.contains(annee)) {
+ if (!selectedYears.contains(year)) {
itLength.remove();
}
}
if (log.isDebugEnabled()) {
- log.debug("Length data filtered by " + years);
+ log.debug("Length data filtered by " + selectedYears);
}
// the only place to set this value
- selection.setSelectedYears(years);
+ selection.setSelectedYears(selectedYears);
return result;
}
/**
+ * Update data to remove non selected strata.
+ *
+ * @param project project
+ * @param selection selection
+ * @param selectedStrata selected strata
+ */
+ public void filterDataStrata(Project project, Selection selection, List<String> selectedStrata) {
+
+ Collection<String> existentHauls = new HashSet<String>();
+
+ // manage strata file
+ Iterator<String[]> itStrata = selection.getStrata().iterator(true);
+ while (itStrata.hasNext()) {
+ String[] tupleStrata = itStrata.next();
+ String stratum = tupleStrata[Strata.INDEX_STRATUM];
+
+ if (!selectedStrata.contains(stratum)) {
+ itStrata.remove();
+ }
+ }
+
+ // manage haul file
+ Iterator<String[]> itHaul = selection.getHaul().iterator(true);
+ while (itHaul.hasNext()) {
+ String[] tupleHaul = itHaul.next();
+ String stratum = tupleHaul[Haul.INDEX_STRATUM];
+
+ if (!selectedStrata.contains(stratum)) {
+ itHaul.remove();
+ }
+ else {
+ // sauvegarde les traits qui existent encore
+ // apres la suppression des strates
+ String haul = tupleHaul[Haul.INDEX_HAUL];
+ existentHauls.add(haul);
+ }
+ }
+
+ // manage catch file
+ Iterator<String[]> itCatch = selection.getCatch().iterator(true);
+ while (itCatch.hasNext()) {
+ String[] tupleCatch = itCatch.next();
+ String haul = tupleCatch[Catch.INDEX_HAUL];
+
+ if (!existentHauls.contains(haul)) {
+ itCatch.remove();
+ }
+ }
+
+ // manage length file
+ Iterator<String[]> itLength = selection.getLength().iterator(true);
+ while (itLength.hasNext()) {
+ String[] tupleLength = itLength.next();
+ String haul = tupleLength[Length.INDEX_HAUL];
+
+ if (!existentHauls.contains(haul)) {
+ itLength.remove();
+ }
+ }
+
+ // only place to do it
+ selection.setSelectedStrata(selectedStrata);
+ }
+
+ /**
* Retourne la liste des type d'especes definie dans le projet sous forme
* de map avec leur commentaire (sauf "Tous").
*
@@ -1704,31 +1798,40 @@
return types;
}
-
+
/**
- * Find all defined year in model.
+ * Update data to remove non selected species.
*
- * Le parcours est fait sur le fichier "haul", c'est potentiellement
- * le plus petit.
- *
- * Used in selection ui.
- *
- * @param selection selection to search into
- * @return year list
+ * @param project project
+ * @param selection selection
+ * @param selectedSpecies selected species
*/
- public List<String> getProjectYears(Selection selection) {
+ public void filterDataSpecies(Project project, Selection selection, List<String> selectedSpecies) {
- SortedSet<String> years = new TreeSet<String>();
+ // manage catch file
+ Iterator<String[]> itCatch = selection.getCatch().iterator(true);
+ while (itCatch.hasNext()) {
+ String[] tupleCatch = itCatch.next();
+ String species = tupleCatch[Catch.INDEX_SPECIES];
- Iterator<String[]> itTuple = selection.getHaul().iterator(true);
- while (itTuple.hasNext()) {
- String[] tuple = itTuple.next();
- String year = tuple[Haul.INDEX_YEAR];
- years.add(year);
+ if (!selectedSpecies.contains(species)) {
+ itCatch.remove();
+ }
}
-
- List<String> result = new ArrayList<String>(years);
- return result;
+
+ // manage length file
+ Iterator<String[]> itLength = selection.getLength().iterator(true);
+ while (itLength.hasNext()) {
+ String[] tupleLength = itLength.next();
+ String species = tupleLength[Length.INDEX_SPECIES];
+
+ if (!selectedSpecies.contains(species)) {
+ itLength.remove();
+ }
+ }
+
+ // only place to do it
+ selection.setSelectedSpecies(selectedSpecies);
}
/**
@@ -1838,40 +1941,21 @@
*
* @param project project
* @param container data container
- * @param strataNames strata names
* @param filterSpecyType filterSpecyType
* @return species
*/
- public List<String> getProjectSpecies(Project project, AbstractDataContainer container, List<String> strataNames,
- List<String> filterSpecyType) {
+ public List<String> getProjectSpecies(Project project, AbstractDataContainer container, List<String> filterSpecyType) {
- // first get traits list
- Set<String> traits = new HashSet<String>();
- Iterator<String[]> itTuple = container.getHaul().iterator(true);
- while (itTuple.hasNext()) {
- String[] tuple = itTuple.next();
-
- // Campagne;Annee;Trait;Mois;Strate;SurfaceBalayee;Lat;Long;ProfMoy
- String strataName = tuple[Haul.INDEX_STRATUM];
- if (strataNames.contains(strataName)) {
- String traitsName = tuple[Haul.INDEX_HAUL];
- traits.add(traitsName);
- }
- }
-
- // second get species with trait list
+ // first get species with trait list
List<String> result = new ArrayList<String>();
- itTuple = container.getCatch().iterator(true);
- while (itTuple.hasNext()) {
- String[] tuple = itTuple.next();
+ Iterator<String[]> itCatch = container.getCatch().iterator(true);
+ while (itCatch.hasNext()) {
+ String[] tuple = itCatch.next();
// "Campagne","Annee","Trait","Espece","Nombre","Poids"
- String haul = tuple[Catch.INDEX_HAUL];
- if (traits.contains(haul)) {
- String species = tuple[Catch.INDEX_SPECIES];
- if (!result.contains(species)) {
- result.add(species);
- }
+ String species = tuple[Catch.INDEX_SPECIES];
+ if (!result.contains(species)) {
+ result.add(species);
}
}
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 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2011-02-10 18:25:39 UTC (rev 736)
@@ -279,27 +279,36 @@
// all data
List<String> allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
- List<String> species = projectService.getProjectSpecies(project, selection, allStrata, null);
+ projectService.filterDataStrata(project, selection, allStrata);
+ List<String> species = projectService.getProjectSpecies(project, selection, null);
Assert.assertEquals(4, species.size());
// data in 2011
+ projectService.loadControlDataToSelection(project, selection);
allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years2011);
- species = projectService.getProjectSpecies(project, selection, allStrata, null);
+ projectService.filterDataStrata(project, selection, allStrata);
+ species = projectService.getProjectSpecies(project, selection, null);
Assert.assertEquals(4, species.size());
// all strata but no data for years
+ projectService.loadControlDataToSelection(project, selection);
allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years2009);
- species = projectService.getProjectSpecies(project, selection, allStrata, null);
+ projectService.filterDataStrata(project, selection, allStrata);
+ species = projectService.getProjectSpecies(project, selection, null);
Assert.assertEquals(0, species.size());
// test with no strata
+ projectService.loadControlDataToSelection(project, selection);
allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
- species = projectService.getProjectSpecies(project, selection, new ArrayList<String>(), null);
+ projectService.filterDataStrata(project, selection, new ArrayList<String>());
+ species = projectService.getProjectSpecies(project, selection, null);
Assert.assertEquals(0, species.size());
// test with only one stratum
+ projectService.loadControlDataToSelection(project, selection);
allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
- species = projectService.getProjectSpecies(project, selection, Collections.singletonList("STR6"), null);
+ projectService.filterDataStrata(project, selection, Collections.singletonList("STR6"));
+ species = projectService.getProjectSpecies(project, selection, null);
Assert.assertEquals(4, species.size());
}
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 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2011-02-10 18:25:39 UTC (rev 736)
@@ -41,11 +41,12 @@
<Boolean id="creationState" javaBean="false" />
<Boolean id="yearsValidated" javaBean="false" />
<Boolean id="strataValidated" javaBean="false" />
+ <Boolean id="speciesValidated" javaBean="false" />
<!-- Validation -->
<fr.ifremer.coser.bean.Selection id="selection" javaBean="null" />
<jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel'
- onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && getSelectedSpeciesListModel().getSize() != 0)'/>
+ onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && isSpeciesValidated())'/>
<BeanValidator id='validatorSelection' bean='selection'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"
errorTableModel="errorsTableModel">
@@ -132,7 +133,7 @@
</cell>
<cell anchor="south">
<JButton id="validDatesButton" text="coser.ui.selection.details.validYears"
- onActionPerformed="getHandler().updateSelectionYearsData(this, false);setYearsValidated(true)"
+ onActionPerformed="getHandler().validSelectionYearsData(this);setYearsValidated(true)"
enabled="{!isYearsValidated()}"/>
</cell>
</row>
@@ -168,7 +169,7 @@
<row>
<cell anchor="south" columns="2">
<JButton id="validStrataButton" text="coser.ui.selection.details.validStrata"
- onActionPerformed="getHandler().updateSelectionStrataData(this, false);setStrataValidated(true)"
+ onActionPerformed="getHandler().validSelectionStrataData(this);setStrataValidated(true)"
enabled="{isYearsValidated() && !isStrataValidated()}"/>
</cell>
</row>
@@ -246,7 +247,7 @@
<cell weightx="1" weighty="1" fill="both">
<JScrollPane>
<SpeciesListModel id="selectedSpeciesListModel"
- onContentsChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && getSelectedSpeciesListModel().getSize() != 0);selectedSpeciesLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/>
+ onContentsChanged='setSpeciesValidated(false);selectedSpeciesLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/>
<JList id="selectedSpeciesList" model="{selectedSpeciesListModel}"
onMouseClicked="getHandler().showSelectedSpeciesContextMenu(this, event)"
selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}"
@@ -264,6 +265,13 @@
</Table>
</cell>
</row>
+ <row>
+ <cell anchor="east" columns="4">
+ <JButton id="validSpeciesButton" text="coser.ui.selection.details.validSpecies"
+ onActionPerformed="getHandler().validSelectionSpeciesData(this);setSpeciesValidated(true);saveSelectionButton.setEnabled(true)"
+ enabled="{isYearsValidated() && isStrataValidated() && !isSpeciesValidated()}"/>
+ </cell>
+ </row>
</Table>
</AccordionPaneSubPanel>
</AccordionPane>
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 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2011-02-10 18:25:39 UTC (rev 736)
@@ -120,7 +120,11 @@
List<String> selectionSpeciesList = selection.getSelectedSpecies();
if (!selectionSpeciesList.equals(currentList)) {
-
+
+ if (log.isDebugEnabled()) {
+ log.debug("Data changed, fill default selection");
+ }
+
// on calcul également les matrices de d'occurence, densité
Project project = view.getContextValue(Project.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -146,6 +150,7 @@
if (!selection.getSelectedSpeciesOccDens().isEmpty() ||
!selection.getSelectedSpeciesSizeAllYear().isEmpty() ||
!selection.getSelectedSpeciesMaturity().isEmpty()) {
+
selectionListsView.getSelectionFilterOccurrenceField().setText(String.valueOf(selection.getOccurrenceFilter()));
selectionListsView.getSelectionFilterDensityField().setText(String.valueOf(selection.getDensityFilter()));
@@ -155,6 +160,11 @@
((CoserListSelectionModel)selectionListsView.getSelectionMaturityList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesMaturity());
}
else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Apply occurrence/density filter");
+ }
+
// select all list (not to do for reload)
// init allSize and maturity before (select all with updateOccurrenceDensityFilter)
updateOccurrenceDensityFilter(selectionListsView);
@@ -202,9 +212,6 @@
view.getFilteredSpeciesList().clearSelection();
view.getSelectedSpeciesListModel().setSpecies(new ArrayList<String>());
view.getSelectedSpeciesList().clearSelection();
-
- // clear species list to renable filtering
- selection.getSelectedSpecies().clear();
}
/**
@@ -230,18 +237,20 @@
((CoserListSelectionModel)detailView.getYearsList().getSelectionModel()).setSelectedObjects(selectedYears);
// details view : fill strata data and selection
- updateSelectionYearsData(detailView, true);
+ updateSelectionYearsData(detailView);
List<String> selectedStrata = selection.getSelectedStrata();
((CoserListSelectionModel)detailView.getStrataList().getSelectionModel()).setSelectedObjects(selectedStrata);
// details view : fill species list and selection
- updateSelectionStrataData(detailView, true);
+ detailView.getSelectedSpeciesListModel().setSpecies(selection.getSelectedSpecies());
+ updateSelectionStrataData(detailView);
List<String> selectedSpecies = selection.getSelectedSpecies();
detailView.getSelectedSpeciesListModel().setSpecies(selectedSpecies);
// disable tabs and other actions
detailView.setYearsValidated(!selectedYears.isEmpty());
detailView.setStrataValidated(!selectedStrata.isEmpty());
+ detailView.setSpeciesValidated(!selectedSpecies.isEmpty());
view.setEnabledAt(2, selection.isValidated()); // rsufi
}
@@ -285,13 +294,11 @@
/**
* Rafraichit la liste des zones suite à la selection des années.
+ * Rechargement de selection ou action utilisateur.
*
- * N'affiche pas de message utilsateur dans le cas d'un reload.
- *
* @param view view
- * @param reload reload total de la selection (n'affiche pas de message)
*/
- protected void updateSelectionYearsData(SelectionDetailsView view, boolean reload) {
+ protected void updateSelectionYearsData(SelectionDetailsView view) {
Project project = view.getContextValue(Project.class);
Selection selection = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -322,14 +329,6 @@
view.getSelectedSpeciesListModel().setSpecies(new ArrayList<String>());
view.getSelectedSpeciesList().clearSelection();
- if (!reload) {
- JOptionPane.showMessageDialog(view, _("coser.ui.selection.detail.yearsvalidated"),
- _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
-
- // auto select strata accordion pane
- view.getDetailAccordionPane().setSelected(2);
- }
-
if (log.isDebugEnabled()) {
log.debug("Years list refreshed");
}
@@ -337,7 +336,31 @@
throw new CoserException("Can't filters data with specified years", ex);
}
}
+
+ /**
+ * Rafraichit la liste des zones suite à la selection des années.
+ *
+ * Action utilisateur.
+ *
+ * @param view view
+ */
+ public void validSelectionYearsData(SelectionDetailsView view) {
+ try {
+ setWaitCursor(view);
+
+ updateSelectionYearsData(view);
+
+ JOptionPane.showMessageDialog(view, _("coser.ui.selection.detail.yearsvalidated"),
+ _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
+
+ // auto select strata accordion pane
+ view.getDetailAccordionPane().setSelected(2);
+ } finally {
+ setDefaultCursor(view);
+ }
+ }
+
/**
* Init openmap toolbar and openmap layers.
*
@@ -356,40 +379,64 @@
}
/**
- * Appelé lorsque la selection de la liste des zones a changé.
+ * Appelé lorsque la selection de la liste des strate a changé.
+ * Rechargement de selection ou action utilsateur.
*
* @param view view
- * @param reload reload total de la selection (n'affiche pas de message)
*/
- public void updateSelectionStrataData(SelectionDetailsView view, boolean reload) {
+ protected void updateSelectionStrataData(SelectionDetailsView view) {
+
+ Project project = view.getContextValue(Project.class);
+ Selection selection = view.getContextValue(Selection.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+
if (log.isDebugEnabled()) {
- log.debug("Zone list selection changed, updating species list");
+ log.debug("Strata list selection changed, updating species list");
}
- Selection selection = view.getContextValue(Selection.class);
-
// 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);
+ // do selection.setSelectedStrata(strata);
+ projectService.filterDataStrata(project, selection, strata);
+ // remove non selected stata non in data anymore
+ // maybe will be improved for v2
+ view.getStrataListModel().setStrata(strata);
+ ((CoserListSelectionModel)view.getStrataList().getSelectionModel()).setSelectedObjects(strata);
+
updateSelectionSpecies(view);
-
- if (!reload) {
+ }
+
+ /**
+ * Appelé lorsque la selection de la liste des strate a changé.
+ * Action utilsteur seulement.
+ *
+ * @param view view
+ */
+ public void validSelectionStrataData(SelectionDetailsView view) {
+ try {
+ setWaitCursor(view);
+
+ updateSelectionStrataData(view);
+
JOptionPane.showMessageDialog(view, _("coser.ui.selection.detail.stratavalidated"),
_("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
-
+
// auto select species accordion pane
view.getDetailAccordionPane().setSelected(3);
}
+ finally {
+ setDefaultCursor(view);
+ }
}
/**
* Rafraichit la liste des especes avec les dates sélectionnées
- * et les zones selectionnées ET filtrées par la liste
+ * et les strates selectionnées ET filtrées par la liste
* des type d'especes.
*
* Appelé lorsque la selection de la liste des zones change.
@@ -397,7 +444,7 @@
* @param view view
*/
public void updateSelectionSpecies(SelectionDetailsView view) {
-
+
if (log.isDebugEnabled()) {
log.debug("Updating species list");
}
@@ -406,9 +453,6 @@
Selection selection = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
- // get selected zones as list
- List<String> strata = selection.getSelectedStrata();
-
// get selected species types
Object[] selectedSpeciesTypes = view.getTypeSpeciesList().getSelectedValues();
List<String> speciesTypes = new ArrayList<String>();
@@ -416,15 +460,46 @@
speciesTypes.add((String)selectedSpeciesType);
}
- List<String> filteredSpecies = projectService.getProjectSpecies(project, selection, strata, speciesTypes);
-
+ List<String> filteredSpecies = projectService.getProjectSpecies(project, selection, speciesTypes);
+
// ne fait pas apparaitre les especes deja selectionnées
- if (selection.getSelectedSpecies() != null) {
- filteredSpecies.removeAll(selection.getSelectedSpecies());
- }
+ List<String> selectedSpecies = view.getSelectedSpeciesListModel().getSpecies();
+ filteredSpecies.removeAll(selectedSpecies);
view.getFilteredSpeciesListModel().setSpecies(filteredSpecies);
}
+
+ /**
+ * Rafraichit la liste des especes avec les dates sélectionnées
+ * et les strates selectionnées ET filtrées par la liste
+ * des type d'especes.
+ *
+ * Appelé lorsque la selection de la liste des zones change.
+ *
+ * @param view view
+ */
+ public void validSelectionSpeciesData(SelectionDetailsView view) {
+ try {
+ setWaitCursor(view);
+ Project project = view.getContextValue(Project.class);
+ Selection selection = view.getContextValue(Selection.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+
+ // get selected species
+ List<String> selectedSpecies = view.getSelectedSpeciesListModel().getSpecies();
+ projectService.filterDataSpecies(project, selection, selectedSpecies);
+
+ // to remove from view, non available species
+ updateSelectionSpecies(view);
+
+ JOptionPane.showMessageDialog(view, _("coser.ui.selection.detail.speciesvalidated"),
+ _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
+ }
+ finally {
+ setDefaultCursor(view);
+ }
+ }
+
/**
* Affiche un menu contextuel lors du clic (droit) sur la liste des années.
*
@@ -970,8 +1045,6 @@
*/
public void addSelectedFilteredSpecies(SelectionDetailsView view) {
- Selection selection = view.getContextValue(Selection.class);
-
// get selected species
Object[] selectedFilteredSpecies = view.getFilteredSpeciesList().getSelectedValues();
Set<String> selectedSpecies = new HashSet<String>();
@@ -985,7 +1058,6 @@
// met a jour le liste des especes selectionnées
List<String> selectedSpeciesList = new ArrayList<String>(selectedSpecies);
Collections.sort(selectedSpeciesList);
- selection.setSelectedSpecies(selectedSpeciesList);
view.getSelectedSpeciesListModel().setSpecies(selectedSpeciesList);
// met a jour la liste filtrée (retrait des especes selectionnées)
@@ -1001,8 +1073,6 @@
* @param view view
*/
public void removeSelectedSpecies(SelectionDetailsView view) {
-
- Selection selection = view.getContextValue(Selection.class);
List<String> filteredSpecies = new ArrayList<String>(view.getFilteredSpeciesListModel().getSpecies());
List<String> selectedSpecies = new ArrayList<String>(view.getSelectedSpeciesListModel().getSpecies());
@@ -1015,7 +1085,6 @@
Collections.sort(filteredSpecies);
// met à jour la liste des especes selectionnées
- selection.setSelectedSpecies(selectedSpecies);
view.getSelectedSpeciesListModel().setSpecies(selectedSpecies);
// met a jour la liste filtrée (retrait des especes selectionnées)
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 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2011-02-10 18:25:39 UTC (rev 736)
@@ -165,10 +165,11 @@
coser.ui.selection.allSpecies=L1 \: All species (%d/%d)
coser.ui.selection.comment=Comment \:
coser.ui.selection.createError=Creation error
-coser.ui.selection.detail.confirmcontrolreload=Are you sure you want to reload control data ?\nAll modifications done on current selection will be lost.
-coser.ui.selection.detail.controldatareloaded=Control data reloaded.
+coser.ui.selection.detail.confirmcontrolreload=Are you sure you want to reload controled data ?\nAll modifications done on current selection will be lost.
+coser.ui.selection.detail.controldatareloaded=Controled data reloaded.
coser.ui.selection.detail.mainAccordion=Details
coser.ui.selection.detail.speciesAccordion=Species
+coser.ui.selection.detail.speciesvalidated=Species validated.
coser.ui.selection.detail.strataAccordion=Strata
coser.ui.selection.detail.stratavalidated=Strata validated.
coser.ui.selection.detail.yearAccordion=Years
@@ -189,6 +190,7 @@
coser.ui.selection.details.type=Filter by type (%d/%d) \:
coser.ui.selection.details.validFilter=Valid filter
coser.ui.selection.details.validSelection=Valid selection
+coser.ui.selection.details.validSpecies=Valid species
coser.ui.selection.details.validStrata=Valid strata
coser.ui.selection.details.validYears=Valid years
coser.ui.selection.details.years=Years \:
@@ -210,7 +212,7 @@
coser.ui.selection.nonJustifiedTitle=Unjustified selection
coser.ui.selection.occurrenceDensitySpecies=L2 \: Filtered species (%d/%d)
coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html>
-coser.ui.selection.reloadcontroldata=Reload control data
+coser.ui.selection.reloadcontroldata=Reload controled data
coser.ui.selection.replayerror=Replay error
coser.ui.selection.rsufidataextracted=RSufi data extracted.
coser.ui.selection.saveError=Save error
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 2011-02-10 18:17:24 UTC (rev 735)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2011-02-10 18:25:39 UTC (rev 736)
@@ -165,10 +165,11 @@
coser.ui.selection.allSpecies=L1 \: Toutes les esp\u00E8ces (%d/%d)
coser.ui.selection.comment=Commentaire \:
coser.ui.selection.createError=Erreur de cr\u00E9action
-coser.ui.selection.detail.confirmcontrolreload=\u00CAtes vous s\u00FBr de vouloir recharger les donn\u00E9es de contr\u00F4le ?\nToutes les modifications de la s\u00E9lection en cours seront perdues.
-coser.ui.selection.detail.controldatareloaded=Donn\u00E9es de contr\u00F4le recharg\u00E9es.
+coser.ui.selection.detail.confirmcontrolreload=\u00CAtes vous s\u00FBr de vouloir recharger les donn\u00E9es contr\u00F4l\u00E9es ?\nToutes les modifications de la s\u00E9lection en cours seront perdues.
+coser.ui.selection.detail.controldatareloaded=Donn\u00E9es contr\u00F4l\u00E9es recharg\u00E9es.
coser.ui.selection.detail.mainAccordion=D\u00E9tails
coser.ui.selection.detail.speciesAccordion=Esp\u00E8ces
+coser.ui.selection.detail.speciesvalidated=Esp\u00E8ces valid\u00E9es.
coser.ui.selection.detail.strataAccordion=Strates
coser.ui.selection.detail.stratavalidated=Strates valid\u00E9es.
coser.ui.selection.detail.yearAccordion=Ann\u00E9es
@@ -189,6 +190,7 @@
coser.ui.selection.details.type=Filtrer par type (%d/%d) \:
coser.ui.selection.details.validFilter=Valider les filtres
coser.ui.selection.details.validSelection=Valider la s\u00E9lection
+coser.ui.selection.details.validSpecies=Valider les esp\u00E8ces
coser.ui.selection.details.validStrata=Valider les strates
coser.ui.selection.details.validYears=Valider les ann\u00E9es
coser.ui.selection.details.years=Ann\u00E9es \:
@@ -210,7 +212,7 @@
coser.ui.selection.nonJustifiedTitle=S\u00E9lection non justifi\u00E9e
coser.ui.selection.occurrenceDensitySpecies=L2 \: Esp\u00E8ces filtr\u00E9es (%d/%d)
coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html>
-coser.ui.selection.reloadcontroldata=Recharger les donn\u00E9es de contr\u00F4le
+coser.ui.selection.reloadcontroldata=Recharger les donn\u00E9es contr\u00F4l\u00E9es
coser.ui.selection.replayerror=Erreur de reapplication
coser.ui.selection.rsufidataextracted=Donn\u00E9es RSufi extraites.
coser.ui.selection.saveError=Erreur de sauvegarde