r404 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model
Author: chatellier Date: 2010-12-14 13:55:38 +0000 (Tue, 14 Dec 2010) New Revision: 404 Log: Display species type comment un specy type renderer. Refactoring (specy > species) Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java Removed: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java 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/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 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-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-12-14 13:55:38 UTC (rev 404) @@ -49,7 +49,9 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.SortedMap; import java.util.SortedSet; +import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Pattern; @@ -60,7 +62,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.math.util.MathUtils; -import org.nuiton.math.matrix.DoubleVector; import org.nuiton.math.matrix.MatrixFactory; import org.nuiton.math.matrix.MatrixND; @@ -1477,13 +1478,14 @@ } /** - * Retourne la liste des type d'especes definie dans le projet. + * Retourne la liste des type d'especes definie dans le projet sous forme + * de map avec leur commentaire. * * @param project project to search into * @return project species type */ - public List<String> getProjectSpeciesTypes(Project project) { - List<String> types = new ArrayList<String>(); + public Map<String, String> getProjectSpeciesTypes(Project project) { + SortedMap<String, String> types = new TreeMap<String, String>(); // "Types","Commentaire","NumSys min","NumSys max" @@ -1494,10 +1496,10 @@ String[] tuple = itTuples.next(); String type = tuple[0]; - types.add(type); + String comment = tuple[1]; + types.put(type, comment); } - Collections.sort(types); return types; } @@ -1752,10 +1754,10 @@ * Used in selection ui. * * @param project project (avec reftax) - * @param newSpecyName specy code to test + * @param newSpeciesName species code to test * @return {@code true} if specy name exist */ - public boolean isSpecyNameExist(Project project, String newSpecyName) { + public boolean isSpeciesNameExist(Project project, String newSpeciesName) { boolean result = false; @@ -1765,7 +1767,7 @@ String[] tuple = itTuple.next(); // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String specyCode = tuple[3]; - if (specyCode.equals(newSpecyName)) { + if (specyCode.equals(newSpeciesName)) { result = true; } } @@ -1779,20 +1781,20 @@ * * @param project project * @param selection selection - * @param newSpecyName new specy name (after merge) + * @param newSpeciesName new specy name (after merge) * @param comment comment * @param speciesNames species name to merge * @return project * @throws CoserBusinessException */ - public Project mergeSpecies(Project project, Selection selection, String newSpecyName, String comment, String... speciesNames) throws CoserBusinessException { + public Project mergeSpecies(Project project, Selection selection, String newSpeciesName, String comment, String... speciesNames) throws CoserBusinessException { - if (!isSpecyNameExist(project, newSpecyName)) { - throw new CoserBusinessException(_("Species %s doesn't exist in referential", newSpecyName)); + if (!isSpeciesNameExist(project, newSpeciesName)) { + throw new CoserBusinessException(_("Species %s doesn't exist in referential", newSpeciesName)); } MergeSpeciesCommand command = new MergeSpeciesCommand(); - command.setNewSpecyName(newSpecyName); + command.setNewSpecyName(newSpeciesName); command.setSpeciesNames(speciesNames); command.setComment(comment); commandService.doAction(command, project, selection); 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-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-12-14 13:55:38 UTC (rev 404) @@ -200,9 +200,9 @@ @Test public void testSpeciesExistence() throws CoserBusinessException { Project project = createTestProject(projectService, false); - Assert.assertFalse(projectService.isSpecyNameExist(project, "Coser_invalid")); - Assert.assertTrue(projectService.isSpecyNameExist(project, "COSER_SPECIES1")); - Assert.assertTrue(projectService.isSpecyNameExist(project, "COSER_SPECIES2")); + Assert.assertFalse(projectService.isSpeciesNameExist(project, "Coser_invalid")); + Assert.assertTrue(projectService.isSpeciesNameExist(project, "COSER_SPECIES1")); + Assert.assertTrue(projectService.isSpeciesNameExist(project, "COSER_SPECIES2")); } /** @@ -307,7 +307,7 @@ Selection selection = projectService.initProjectSelection(project); selection.setName("test"); - Assert.assertTrue(projectService.isSpecyNameExist(project, "COSER_SPECIES_MERGE")); + Assert.assertTrue(projectService.isSpeciesNameExist(project, "COSER_SPECIES_MERGE")); Assert.assertEquals(25, selection.getCatch().size()); Assert.assertEquals(30, selection.getLength().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 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-12-14 13:55:38 UTC (rev 404) @@ -31,8 +31,8 @@ void $afterCompleteSetup() { // modification (species -> selection model) - filteredSpecyListModel.addListDataListener((CoserListSelectionModel)filteredSpecyList.getSelectionModel()); - selectedSpecyListModel.addListDataListener((CoserListSelectionModel)selectedSpecyList.getSelectionModel()); + filteredSpeciesListModel.addListDataListener((CoserListSelectionModel)filteredSpeciesList.getSelectionModel()); + selectedSpeciesListModel.addListDataListener((CoserListSelectionModel)selectedSpeciesList.getSelectionModel()); } ]]></script> @@ -45,7 +45,7 @@ <!-- Validation --> <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && getSelectedSpecyListModel().getSize() != 0)'/> + onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && getSelectedSpeciesListModel().getSize() != 0)'/> <BeanValidator id='validatorSelection' bean='selection' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" errorTableModel="errorsTableModel"> @@ -175,18 +175,19 @@ <Table> <row> <cell fill="horizontal" columns="4"> - <JLabel id="typeSpecyLabel" text='{_("coser.ui.selection.details.type", typeSpecyList.getSelectedIndices().length, typeSpecyList.getModel().getSize())}' /> + <JLabel id="typeSpeciesLabel" text='{_("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize())}' /> </cell> </row> <row> <cell fill="both" weightx="1" weighty="1" columns="2"> <JScrollPane> - <SpecyTypesListModel id="typeSpecyModel" constructorParams="this" - onContentsChanged='typeSpecyLabel.setText(_("coser.ui.selection.details.type", typeSpecyList.getSelectedIndices().length, typeSpecyList.getModel().getSize()))'/> - <JList id="typeSpecyList" model="{typeSpecyModel}" - selectionModel="{new CoserListSelectionModel(typeSpecyList.getSelectionModel(), typeSpecyModel)}" + <SpeciesTypesListModel id="typeSpeciesModel" constructorParams="this" + onContentsChanged='typeSpeciesLabel.setText(_("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))'/> + <JList id="typeSpeciesList" model="{typeSpeciesModel}" + cellRenderer="{new SpeciesTypesRenderer()}" + selectionModel="{new CoserListSelectionModel(typeSpeciesList.getSelectionModel(), typeSpeciesModel)}" enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='validFilterButton.setEnabled(true); typeSpecyLabel.setText(_("coser.ui.selection.details.type", typeSpecyList.getSelectedIndices().length, typeSpecyList.getModel().getSize()))' /> + onValueChanged='validFilterButton.setEnabled(true); typeSpeciesLabel.setText(_("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))' /> </JScrollPane> </cell> <cell anchor="south" columns="2"> @@ -200,23 +201,23 @@ <Table> <row> <cell fill="horizontal" columns="2"> - <JLabel id="filteredSpecyLabel" text='{_("coser.ui.selection.details.filteredSpecies", 0, 0)}' /> + <JLabel id="filteredSpeciesLabel" text='{_("coser.ui.selection.details.filteredSpecies", 0, 0)}' /> </cell> <cell fill="horizontal"> - <JLabel id="selectedSpecyLabel" text='{_("coser.ui.selection.details.selectedSpecies", 0, 0)}' /> + <JLabel id="selectedSpeciesLabel" text='{_("coser.ui.selection.details.selectedSpecies", 0, 0)}' /> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both"> <JScrollPane> - <SpecyListModel id="filteredSpecyListModel" - onContentsChanged='filteredSpecyLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpecyList.getSelectedIndices().length, filteredSpecyList.getModel().getSize()))'/> - <JList id="filteredSpecyList" model="{filteredSpecyListModel}" + <SpeciesListModel id="filteredSpeciesListModel" + onContentsChanged='filteredSpeciesLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))'/> + <JList id="filteredSpeciesList" model="{filteredSpeciesListModel}" onMouseClicked="getHandler().showFilteredSpeciesContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(filteredSpecyList.getSelectionModel(), filteredSpecyListModel)}" + selectionModel="{new CoserListSelectionModel(filteredSpeciesList.getSelectionModel(), filteredSpeciesListModel)}" enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='filteredSpecyLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpecyList.getSelectedIndices().length, filteredSpecyList.getModel().getSize()))' /> - <ListSelectionModel id="filteredSpecyListSelectionModel" javaBean="filteredSpecyList.getSelectionModel()" /> + onValueChanged='filteredSpeciesLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))' /> + <ListSelectionModel id="filteredSpeciesListSelectionModel" javaBean="filteredSpeciesList.getSelectionModel()" /> </JScrollPane> </cell> <cell anchor="north"> @@ -226,7 +227,7 @@ <JButton icon="arrow_right.png" toolTipText="coser.ui.selection.details.addToSelectedListTip" onActionPerformed="getHandler().addSelectedFilteredSpecies(this)" - enabled="{getFilteredSpecyList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> + enabled="{getFilteredSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> </cell> </row> <row> @@ -234,21 +235,21 @@ <JButton icon="arrow_left.png" toolTipText="coser.ui.selection.details.removeFromSelectedListTip" onActionPerformed="getHandler().removeSelectedSpecies(this)" - enabled="{getSelectedSpecyList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> + enabled="{getSelectedSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> </cell> </row> </Table> </cell> <cell weightx="1" weighty="1" fill="both"> <JScrollPane> - <SpecyListModel id="selectedSpecyListModel" - onContentsChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && getSelectedSpecyListModel().getSize() != 0);selectedSpecyLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpecyList.getSelectedIndices().length, selectedSpecyList.getModel().getSize()))'/> - <JList id="selectedSpecyList" model="{selectedSpecyListModel}" + <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()))'/> + <JList id="selectedSpeciesList" model="{selectedSpeciesListModel}" onMouseClicked="getHandler().showSelectedSpeciesContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(selectedSpecyList.getSelectionModel(), selectedSpecyListModel)}" + selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}" enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='selectedSpecyLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpecyList.getSelectedIndices().length, selectedSpecyList.getModel().getSize()))'/> - <ListSelectionModel id="selectedSpecyListSelectionModel" javaBean="selectedSpecyList.getSelectionModel()" /> + onValueChanged='selectedSpeciesLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/> + <ListSelectionModel id="selectedSpeciesListSelectionModel" javaBean="selectedSpeciesList.getSelectionModel()" /> </JScrollPane> </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-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-12-14 13:55:38 UTC (rev 404) @@ -73,7 +73,7 @@ import fr.ifremer.coser.services.PublicationService; import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.result.SelectionAddResultDialog; -import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; +import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel; import fr.ifremer.coser.ui.util.CoserListSelectionModel; /** @@ -121,9 +121,9 @@ // on met à jour la liste de "Toutes les especes" (L1) List<String> currentList = selectionListsView.getSelectionAllSpeciesListModel().getSpecies(); - List<String> selectionSpecyList = selection.getSelectedSpecies(); + List<String> selectionSpeciesList = selection.getSelectedSpecies(); - if (!selectionSpecyList.equals(currentList)) { + if (!selectionSpeciesList.equals(currentList)) { // on calcul également les matrices de d'occurence, densité Project project = view.getContextValue(Project.class); @@ -139,8 +139,8 @@ selectionListsView.getSelectionOccurrenceDensityListModel().setOccurrence(occurrence); selectionListsView.getSelectionOccurrenceDensityListModel().setDensity(density); - // fill all specy data (at final) - selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpecyList); + // fill all species data (at final) + selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpeciesList); ((CoserListSelectionModel)selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection(); selectionListsView.getSelectionSizeAllYearListModel().setSizeAllYearSpecies(speciesAllYear); selectionListsView.getSelectionMaturityListModel().setMaturitySpecies(speciesWithMaturity); @@ -217,10 +217,10 @@ List<String> selectedStrata = selection.getSelectedStrata(); ((CoserListSelectionModel)detailView.getStrataList().getSelectionModel()).setSelectedObjects(selectedStrata); - // details view : fill specy list and selection + // details view : fill species list and selection strataListChanged(detailView); List<String> selectedSpecies = selection.getSelectedSpecies(); - detailView.getSelectedSpecyListModel().setSpecies(selectedSpecies); + detailView.getSelectedSpeciesListModel().setSpecies(selectedSpecies); // disable tabs and other actions detailView.setYearsValidated(!selectedYears.isEmpty()); @@ -322,20 +322,20 @@ // get selected zones as list List<String> strata = selection.getSelectedStrata(); - // get selected specy types - Object[] selectedSpecyTypes = view.getTypeSpecyList().getSelectedValues(); - List<String> specyTypes = new ArrayList<String>(); - for (Object selectedSpecyType : selectedSpecyTypes) { - specyTypes.add((String)selectedSpecyType); + // get selected species types + Object[] selectedSpeciesTypes = view.getTypeSpeciesList().getSelectedValues(); + List<String> speciesTypes = new ArrayList<String>(); + for (Object selectedSpeciesType : selectedSpeciesTypes) { + speciesTypes.add((String)selectedSpeciesType); } - List<String> filteredSpecies = projectService.getProjectSpecies(project, selection, strata, specyTypes); + List<String> filteredSpecies = projectService.getProjectSpecies(project, selection, strata, speciesTypes); // ne fait pas apparaitre les especes deja selectionnées if (selection.getSelectedSpecies() != null) { filteredSpecies.removeAll(selection.getSelectedSpecies()); } - view.getFilteredSpecyListModel().setSpecies(filteredSpecies); + view.getFilteredSpeciesListModel().setSpecies(filteredSpecies); } /** @@ -428,7 +428,7 @@ JPopupMenu popupMenu = new JPopupMenu(); // affiche le menu contextuel si au moins 2 especes selectionnées - int[] selectedRows = view.getFilteredSpecyList().getSelectedIndices(); + int[] selectedRows = view.getFilteredSpeciesList().getSelectedIndices(); if (selectedRows.length > 1) { // merge menu JMenuItem fusionMenu = new JMenuItem(_("coser.ui.selection.speciesMenuFusion")); @@ -438,8 +438,8 @@ SpeciesFusionDialog speciesFusionDialog = new SpeciesFusionDialog(view); speciesFusionDialog.setHandler(SelectionHandler.this); - // pre fill new speci name with first selected specy name - String firstSelected = (String)view.getFilteredSpecyList().getSelectedValue(); + // pre fill new speci name with first selected species name + String firstSelected = (String)view.getFilteredSpeciesList().getSelectedValue(); speciesFusionDialog.getNewSpeciesNameField().setText(firstSelected); speciesFusionDialog.setLocationRelativeTo(view); @@ -455,7 +455,7 @@ graphMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - showSelectedSpeciesGraph(view, view.getFilteredSpecyList()); + showSelectedSpeciesGraph(view, view.getFilteredSpeciesList()); } }); popupMenu.add(graphMenu); @@ -466,8 +466,8 @@ selectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - int size = view.getFilteredSpecyList().getModel().getSize(); - view.getFilteredSpecyList().getSelectionModel().addSelectionInterval(0, size - 1); + int size = view.getFilteredSpeciesList().getModel().getSize(); + view.getFilteredSpeciesList().getSelectionModel().addSelectionInterval(0, size - 1); } }); popupMenu.add(selectAllMenu); @@ -479,12 +479,12 @@ unselectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - view.getFilteredSpecyList().getSelectionModel().clearSelection(); + view.getFilteredSpeciesList().getSelectionModel().clearSelection(); } }); popupMenu.add(unselectAllMenu); - popupMenu.show(view.getFilteredSpecyList(), event.getX(), event.getY()); + popupMenu.show(view.getFilteredSpeciesList(), event.getX(), event.getY()); } } @@ -502,14 +502,14 @@ JPopupMenu popupMenu = new JPopupMenu(); - int[] selectedRows = view.getSelectedSpecyList().getSelectedIndices(); + int[] selectedRows = view.getSelectedSpeciesList().getSelectedIndices(); if (selectedRows.length > 0) { // graph JMenuItem graphMenu = new JMenuItem(_("coser.ui.selection.details.displayDiffCatchLengthGraph")); graphMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - showSelectedSpeciesGraph(view, view.getSelectedSpecyList()); + showSelectedSpeciesGraph(view, view.getSelectedSpeciesList()); } }); popupMenu.add(graphMenu); @@ -520,8 +520,8 @@ selectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - int size = view.getSelectedSpecyList().getModel().getSize(); - view.getSelectedSpecyList().getSelectionModel().addSelectionInterval(0, size - 1); + int size = view.getSelectedSpeciesList().getModel().getSize(); + view.getSelectedSpeciesList().getSelectionModel().addSelectionInterval(0, size - 1); } }); popupMenu.add(selectAllMenu); @@ -531,12 +531,12 @@ unselectAllMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - view.getSelectedSpecyList().getSelectionModel().clearSelection(); + view.getSelectedSpeciesList().getSelectionModel().clearSelection(); } }); popupMenu.add(unselectAllMenu); - popupMenu.show(view.getSelectedSpecyList(), event.getX(), event.getY()); + popupMenu.show(view.getSelectedSpeciesList(), event.getX(), event.getY()); } } @@ -774,13 +774,13 @@ */ protected Set<String> getOccurenceDensityFilteredSpecies(SelectionListsView view, double occurrence, double density) { // construction de la liste de selection des especes - OccurrenceDensitySpecyListModel model = view.getSelectionOccurrenceDensityListModel(); + OccurrenceDensitySpeciesListModel model = view.getSelectionOccurrenceDensityListModel(); int speciesCount = model.getSize(); Set<String> filteredSpecies = new HashSet<String>(); for (int speciesIndex = 0 ; speciesIndex < speciesCount ; speciesIndex++) { - String specy = (String)model.getElementAt(speciesIndex); - if (model.getDensity(specy) >= density && model.getOccurrence(specy) >= occurrence) { - filteredSpecies.add(specy); + String species = (String)model.getElementAt(speciesIndex); + if (model.getDensity(species) >= density && model.getOccurrence(species) >= occurrence) { + filteredSpecies.add(species); } } return filteredSpecies; @@ -798,29 +798,29 @@ // TODO echatellier 20101021 attention a ce que la selection // ne change pas (la fenetre est modale pour l'instant) - String newSpecyName = view.getNewSpeciesNameField().getText(); + String newSpeciesName = view.getNewSpeciesNameField().getText(); String comment = view.getCommentField().getText(); Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); - boolean newSpecyExist = projectService.isSpecyNameExist(project, newSpecyName); - if (!newSpecyExist) { + boolean newSpeciesExist = projectService.isSpeciesNameExist(project, newSpeciesName); + if (!newSpeciesExist) { JOptionPane.showMessageDialog(view, _("coser.ui.selection.invalidFusionName"), _("coser.ui.selection.fusionError"), JOptionPane.ERROR_MESSAGE); view.getNewSpeciesNameField().requestFocus(); } else { SelectionDetailsView parent = view.getContextValue(SelectionDetailsView.class, JAXXUtil.PARENT); - Object[] selectedSpecies = parent.getFilteredSpecyList().getSelectedValues(); - String[] specyNames = new String[selectedSpecies.length]; + Object[] selectedSpecies = parent.getFilteredSpeciesList().getSelectedValues(); + String[] speciesNames = new String[selectedSpecies.length]; for (int i = 0 ; i < selectedSpecies.length ; ++i) { - String selectedSpecy = (String)selectedSpecies[i]; - specyNames[i] = selectedSpecy; + String singleSelectedSpecies = (String)selectedSpecies[i]; + speciesNames[i] = singleSelectedSpecies; } try { - projectService.mergeSpecies(project, selection, newSpecyName, comment, specyNames); + projectService.mergeSpecies(project, selection, newSpeciesName, comment, speciesNames); } catch (CoserBusinessException ex) { throw new CoserException("Can't merge species", ex); @@ -872,26 +872,26 @@ Selection selection = view.getContextValue(Selection.class); // get selected species - Object[] selectedFilteredSpecies = view.getFilteredSpecyList().getSelectedValues(); + Object[] selectedFilteredSpecies = view.getFilteredSpeciesList().getSelectedValues(); Set<String> selectedSpecies = new HashSet<String>(); - if (view.getSelectedSpecyListModel().getSpecies() != null) { - selectedSpecies.addAll(view.getSelectedSpecyListModel().getSpecies()); + if (view.getSelectedSpeciesListModel().getSpecies() != null) { + selectedSpecies.addAll(view.getSelectedSpeciesListModel().getSpecies()); } - for (Object selectedFilteredSpecy : selectedFilteredSpecies) { - selectedSpecies.add((String)selectedFilteredSpecy); + for (Object singleSelectedFilteredSpecies : selectedFilteredSpecies) { + selectedSpecies.add((String)singleSelectedFilteredSpecies); } // met a jour le liste des especes selectionnées List<String> selectedSpeciesList = new ArrayList<String>(selectedSpecies); Collections.sort(selectedSpeciesList); selection.setSelectedSpecies(selectedSpeciesList); - view.getSelectedSpecyListModel().setSpecies(selectedSpeciesList); + view.getSelectedSpeciesListModel().setSpecies(selectedSpeciesList); // met a jour la liste filtrée (retrait des especes selectionnées) // ne fait pas apparaitre les especes deja selectionnées - List<String> filteredSpecies = view.getFilteredSpecyListModel().getSpecies(); + List<String> filteredSpecies = view.getFilteredSpeciesListModel().getSpecies(); filteredSpecies.removeAll(selectedSpeciesList); - view.getFilteredSpecyListModel().setSpecies(filteredSpecies); + view.getFilteredSpeciesListModel().setSpecies(filteredSpecies); } /** @@ -903,22 +903,22 @@ Selection selection = view.getContextValue(Selection.class); - List<String> filteredSpecies = new ArrayList<String>(view.getFilteredSpecyListModel().getSpecies()); - List<String> selectedSpecies = new ArrayList<String>(view.getSelectedSpecyListModel().getSpecies()); - Object[] selectedSelectedSpecies = view.getSelectedSpecyList().getSelectedValues(); - for (Object selectedSelectedSpecy : selectedSelectedSpecies) { - selectedSpecies.remove((String)selectedSelectedSpecy); - filteredSpecies.add((String)selectedSelectedSpecy); + List<String> filteredSpecies = new ArrayList<String>(view.getFilteredSpeciesListModel().getSpecies()); + List<String> selectedSpecies = new ArrayList<String>(view.getSelectedSpeciesListModel().getSpecies()); + Object[] selectedSelectedSpecies = view.getSelectedSpeciesList().getSelectedValues(); + for (Object singleSelectedSelectedSpecies : selectedSelectedSpecies) { + selectedSpecies.remove((String)singleSelectedSelectedSpecies); + filteredSpecies.add((String)singleSelectedSelectedSpecies); } Collections.sort(selectedSpecies); Collections.sort(filteredSpecies); // met à jour la liste des especes selectionnées selection.setSelectedSpecies(selectedSpecies); - view.getSelectedSpecyListModel().setSpecies(selectedSpecies); + view.getSelectedSpeciesListModel().setSpecies(selectedSpecies); // met a jour la liste filtrée (retrait des especes selectionnées) - view.getFilteredSpecyListModel().setSpecies(filteredSpecies); + view.getFilteredSpeciesListModel().setSpecies(filteredSpecies); } /** Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-12-14 13:55:38 UTC (rev 404) @@ -100,7 +100,7 @@ <row> <cell weighty="1" weightx="1" fill="both" columns="2"> <JScrollPane> - <SpecyListModel id="selectionAllSpeciesListModel" + <SpeciesListModel id="selectionAllSpeciesListModel" onContentsChanged='allSpeciesLabel.setTitle(_("coser.ui.selection.allSpecies", selectionAllSpeciesList.getSelectedIndices().length, selectionAllSpeciesList.getModel().getSize()))' /> <JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}" selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}" @@ -110,17 +110,17 @@ </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <OccurrenceDensitySpecyListModel id="selectionOccurrenceDensityListModel" + <OccurrenceDensitySpeciesListModel id="selectionOccurrenceDensityListModel" onContentsChanged='occurrenceDensitySpeciesLabel.setTitle(_("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))' /> <JList id="selectionOccurrenceDensityList" model="{selectionOccurrenceDensityListModel}" - cellRenderer="{new SpecyListOccDensRenderer(selectionOccurrenceDensityListModel)}" + cellRenderer="{new SpeciesListOccDensRenderer()}" selectionModel="{new CoserListSelectionModel(selectionOccurrenceDensityList.getSelectionModel(), selectionOccurrenceDensityListModel)}" onValueChanged='applyOccDensFilter.setEnabled(true); occurrenceDensitySpeciesLabel.setTitle(_("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))' /> </JScrollPane> </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <SizeAllYearSpecyListModel id="selectionSizeAllYearListModel" + <SizeAllYearSpeciesListModel id="selectionSizeAllYearListModel" onContentsChanged='sizeAllYearSpeciesLabel.setTitle(_("coser.ui.selection.sizeAllYearSpecies", selectionSizeAllYearList.getSelectedIndices().length, selectionSizeAllYearList.getModel().getSize()))' /> <JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}" selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}" @@ -129,7 +129,7 @@ </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <MaturitySpecyListModel id="selectionMaturityListModel" + <MaturitySpeciesListModel id="selectionMaturityListModel" onContentsChanged='maturitySpeciesLabel.setTitle(_("coser.ui.selection.maturitySpecies", selectionMaturityList.getSelectedIndices().length, selectionMaturityList.getModel().getSize()))' /> <JList id="selectionMaturityList" model="{selectionMaturityListModel}" selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}" Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,66 @@ +/* + * #%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; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; + +import javax.swing.JList; + +import org.jdesktop.swingx.renderer.DefaultListRenderer; + +import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel; + +/** + * Specy renderer with occurrence and density display. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpeciesListOccDensRenderer extends DefaultListRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -5404111064519251687L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + String species = (String)value; + OccurrenceDensitySpeciesListModel model = (OccurrenceDensitySpeciesListModel)list.getModel(); + + double occurrence = model.getOccurrence(species); + double density = model.getDensity(species); + String stringValue = _("coser.ui.selection.occurrencedensityrenderer", species, occurrence, density); + + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); + } + +} Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,70 @@ +/* + * #%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; + +import java.awt.Component; + +import javax.swing.JList; + +import org.apache.commons.lang.StringUtils; +import org.jdesktop.swingx.renderer.DefaultListRenderer; + +import fr.ifremer.coser.ui.selection.model.SpeciesTypesListModel; + +/** + * Specy type renderer (with comment display when available). + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpeciesTypesRenderer extends DefaultListRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -6218097608544949959L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + String species = (String)value; + SpeciesTypesListModel model = (SpeciesTypesListModel)list.getModel(); + + String comment = model.getComment(species); + String stringValue = null; + if (StringUtils.isEmpty(comment)) { + stringValue = species; + } + else { + stringValue = species + " (" + comment + ")"; + } + + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); + } + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,77 +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; - -import static org.nuiton.i18n.I18n._; - -import java.awt.Component; - -import javax.swing.JList; - -import org.jdesktop.swingx.renderer.DefaultListRenderer; - -import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; - -/** - * Specy renderer with occurrence and density display. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyListOccDensRenderer extends DefaultListRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = -5404111064519251687L; - - protected OccurrenceDensitySpecyListModel model; - - public SpecyListOccDensRenderer(OccurrenceDensitySpecyListModel model) { - this.model = model; - } - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - String specy = (String)value; - - String stringValue = null; - if (model != null) { - double occurrence = model.getOccurrence(specy); - double density = model.getDensity(specy); - stringValue = _("coser.ui.selection.occurrencedensityrenderer", specy, occurrence, density); - } - else { - stringValue = specy; - } - - return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); - } - -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java (from rev 252, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpecyListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,119 @@ +/* + * #%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.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Specy list model with size all year. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MaturitySpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + protected Collection<String> maturitySpecies; + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = new ArrayList<String>(species); + this.species.retainAll(maturitySpecies); + fireContentsChanged(this, 0, this.species.size()); + } + + public void setMaturitySpecies(Collection<String> maturitySpecies) { + this.maturitySpecies = maturitySpecies; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + if (maturitySpecies.contains(specy)) { + species.add(specy); + } + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpecyListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpecyListModel.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpecyListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,119 +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.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.JList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Specy list model with size all year. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class MaturitySpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -4769109927915812519L; - - protected List<String> species = new ArrayList<String>(); - - protected Collection<String> maturitySpecies; - - public List<String> getSpecies() { - return species; - } - - public void setSpecies(List<String> species) { - this.species = new ArrayList<String>(species); - this.species.retainAll(maturitySpecies); - fireContentsChanged(this, 0, this.species.size()); - } - - public void setMaturitySpecies(Collection<String> maturitySpecies) { - this.maturitySpecies = maturitySpecies; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int result = 0; - if (species != null) { - result = species.size(); - } - return result; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return species.get(index); - } - - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object o) { - return species.indexOf(o); - } - - /* - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - @Override - public void valueChanged(ListSelectionEvent event) { - - if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); - Object[] selectedValues = source.getSelectedValues(); - species.clear(); - for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; - if (maturitySpecies.contains(specy)) { - species.add(specy); - } - } - fireContentsChanged(this, 0, species.size() - 1); - } - } -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java (from rev 272, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,137 @@ +/* + * #%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.ArrayList; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.nuiton.math.matrix.MatrixND; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Occurence and density filered specy list model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class OccurrenceDensitySpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + protected MatrixND occurrence = null; + + protected MatrixND density = null; + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = species; + fireContentsChanged(this, 0, species.size()); + } + + public void setOccurrence(MatrixND occurrence) { + this.occurrence = occurrence; + } + + public void setDensity(MatrixND density) { + this.density = density; + } + + public double getOccurrence(String specy) { + List<String> years = (List<String>)occurrence.getSemantic(1); + // get(0) == mean value (meanOverDim(1)) + double result = occurrence.getValue(specy, years.get(0)); + return result; + } + + public double getDensity(String specy) { + List<String> years = (List<String>)density.getSemantic(1); + // get(0) == mean value (meanOverDim(1)) + double result = density.getValue(specy, years.get(0)); + return result; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + species.add(specy); + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,137 +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.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.JList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.nuiton.math.matrix.MatrixND; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Occurence and density filered specy list model. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class OccurrenceDensitySpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -4769109927915812519L; - - protected List<String> species = new ArrayList<String>(); - - protected MatrixND occurrence = null; - - protected MatrixND density = null; - - public List<String> getSpecies() { - return species; - } - - public void setSpecies(List<String> species) { - this.species = species; - fireContentsChanged(this, 0, species.size()); - } - - public void setOccurrence(MatrixND occurrence) { - this.occurrence = occurrence; - } - - public void setDensity(MatrixND density) { - this.density = density; - } - - public double getOccurrence(String specy) { - List<String> years = (List<String>)occurrence.getSemantic(1); - // get(0) == mean value (meanOverDim(1)) - double result = occurrence.getValue(specy, years.get(0)); - return result; - } - - public double getDensity(String specy) { - List<String> years = (List<String>)density.getSemantic(1); - // get(0) == mean value (meanOverDim(1)) - double result = density.getValue(specy, years.get(0)); - return result; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int result = 0; - if (species != null) { - result = species.size(); - } - return result; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return species.get(index); - } - - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object o) { - return species.indexOf(o); - } - - /* - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - @Override - public void valueChanged(ListSelectionEvent event) { - - if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); - Object[] selectedValues = source.getSelectedValues(); - species.clear(); - for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; - species.add(specy); - } - fireContentsChanged(this, 0, species.size() - 1); - } - } -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java (from rev 252, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpecyListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,119 @@ +/* + * #%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.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Specy list model with size all year. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SizeAllYearSpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + protected Collection<String> sizeAllYearSpecies; + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = new ArrayList<String>(species); + this.species.retainAll(sizeAllYearSpecies); + fireContentsChanged(this, 0, this.species.size()); + } + + public void setSizeAllYearSpecies(Collection<String> sizeAllYearSpecies) { + this.sizeAllYearSpecies = sizeAllYearSpecies; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + if (sizeAllYearSpecies.contains(specy)) { + species.add(specy); + } + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpecyListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpecyListModel.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpecyListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,119 +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.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.JList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Specy list model with size all year. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SizeAllYearSpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -4769109927915812519L; - - protected List<String> species = new ArrayList<String>(); - - protected Collection<String> sizeAllYearSpecies; - - public List<String> getSpecies() { - return species; - } - - public void setSpecies(List<String> species) { - this.species = new ArrayList<String>(species); - this.species.retainAll(sizeAllYearSpecies); - fireContentsChanged(this, 0, this.species.size()); - } - - public void setSizeAllYearSpecies(Collection<String> sizeAllYearSpecies) { - this.sizeAllYearSpecies = sizeAllYearSpecies; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int result = 0; - if (species != null) { - result = species.size(); - } - return result; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return species.get(index); - } - - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object o) { - return species.indexOf(o); - } - - /* - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - @Override - public void valueChanged(ListSelectionEvent event) { - - if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); - Object[] selectedValues = source.getSelectedValues(); - species.clear(); - for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; - if (sizeAllYearSpecies.contains(specy)) { - species.add(specy); - } - } - fireContentsChanged(this, 0, species.size() - 1); - } - } -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,109 @@ +/* + * #%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.ArrayList; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * No filtered species model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = species; + fireContentsChanged(this, 0, species.size()); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + species.add(specy); + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java (from rev 207, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -0,0 +1,105 @@ +/* + * #%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.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.swing.AbstractListModel; + +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.services.ProjectService; +import fr.ifremer.coser.ui.selection.SelectionDetailsView; +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Affiche la liste des types d'especes définie dans le projet. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpeciesTypesListModel extends AbstractListModel implements CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 441910182067909029L; + + protected SelectionDetailsView view; + + protected List<String> types; + + protected Map<String, String> typesComments; + + public SpeciesTypesListModel(SelectionDetailsView view) { + super(); + this.view = view; + } + + protected List<String> getTypes() { + if (types == null) { + Project project = view.getContextValue(Project.class); + ProjectService service = view.getContextValue(ProjectService.class); + typesComments = service.getProjectSpeciesTypes(project); + types = new ArrayList<String>(typesComments.keySet()); + } + return types; + } + + /** + * Get species comment (used in renderer). + * + * @param species species + * @return species comment + */ + public String getComment(String species) { + return typesComments.get(species); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + return getTypes().size(); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return getTypes().get(index); + } + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object element) { + return getTypes().indexOf(element); + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,109 +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.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.JList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * No filtered species model. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -4769109927915812519L; - - protected List<String> species = new ArrayList<String>(); - - public List<String> getSpecies() { - return species; - } - - public void setSpecies(List<String> species) { - this.species = species; - fireContentsChanged(this, 0, species.size()); - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int result = 0; - if (species != null) { - result = species.size(); - } - return result; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return species.get(index); - } - - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object o) { - return species.indexOf(o); - } - - /* - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - @Override - public void valueChanged(ListSelectionEvent event) { - - if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); - Object[] selectedValues = source.getSelectedValues(); - species.clear(); - for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; - species.add(specy); - } - fireContentsChanged(this, 0, species.size() - 1); - } - } -} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java 2010-12-14 11:01:06 UTC (rev 403) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java 2010-12-14 13:55:38 UTC (rev 404) @@ -1,90 +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.bean.Project; -import fr.ifremer.coser.services.ProjectService; -import fr.ifremer.coser.ui.selection.SelectionDetailsView; -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Affiche la liste des types d'especes définie dans le projet. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyTypesListModel extends AbstractListModel implements CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = 441910182067909029L; - - protected SelectionDetailsView view; - - protected List<String> types; - - public SpecyTypesListModel(SelectionDetailsView view) { - super(); - this.view = view; - } - - protected List<String> getTypes() { - if (types == null) { - Project project = view.getContextValue(Project.class); - ProjectService service = view.getContextValue(ProjectService.class); - types = service.getProjectSpeciesTypes(project); - } - return types; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - return getTypes().size(); - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return getTypes().get(index); - } - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object element) { - return getTypes().indexOf(element); - } -}
participants (1)
-
chatellier@users.labs.libre-entreprise.org