Coser-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
November 2010
- 2 participants
- 175 discussions
r204 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 16:58:38 +0000 (Wed, 10 Nov 2010)
New Revision: 204
Log:
Fix la selection des especes apres fusion
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 16:58:20 UTC (rev 203)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 16:58:38 UTC (rev 204)
@@ -27,6 +27,11 @@
<script><![CDATA[
import fr.ifremer.coser.ui.selection.model.*;
import fr.ifremer.coser.ui.util.*;
+
+ void $afterCompleteSetup() {
+ // modification (species -> selection model)
+ specyListModel.addListDataListener((CoserListSelectionModel)specyList.getSelectionModel());
+ }
]]></script>
<SelectionHandler id="handler" javaBean="null" />
1
0
r203 - in trunk/coser-ui/src/main: java/fr/ifremer/coser/ui/selection resources/i18n
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 16:58:20 +0000 (Wed, 10 Nov 2010)
New Revision: 203
Log:
Fix comment label
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx
trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx 2010-11-10 16:47:00 UTC (rev 202)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx 2010-11-10 16:58:20 UTC (rev 203)
@@ -39,7 +39,7 @@
</cell>
</row>
<row>
- <cell fill="horizontal">
+ <cell fill="horizontal" anchor="northwest">
<JLabel text="coser.ui.selection.fusion.comment" />
</cell>
<cell weightx="2" weighty="1" fill="both" columns="3">
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 16:47:00 UTC (rev 202)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 16:58:20 UTC (rev 203)
@@ -108,7 +108,7 @@
coser.ui.selection.filter.density=Densit\u00E9 \:
coser.ui.selection.filter.filter=Filtrer
coser.ui.selection.filter.occurrence=Occurence \:
-coser.ui.selection.fusion.comment=Commentaire
+coser.ui.selection.fusion.comment=Commentaire \:
coser.ui.selection.fusion.description=Fusion d'esp\u00E8ces. Veuillez renseigner un nouveau nom pr\u00E9sent dans le r\u00E9f\u00E9rentiel.
coser.ui.selection.fusion.name=Nouveau nom \:
coser.ui.selection.fusion.title=Fusion
1
0
r202 - 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 coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model coser-ui/src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 16:47:00 +0000 (Wed, 10 Nov 2010)
New Revision: 202
Log:
Refactoring sur les mod?\195?\168les.
Filtrage de la liste L2 par l'occurrence et la densit?\195?\169.
Added:
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/OccurrenceDensitySpecyListModel.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
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java
Removed:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.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/CoserFrame.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.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
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 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -515,7 +515,7 @@
// fichier de validation existe ici ou pas
Project localProject = project;
- if (!localProject.getControl().isDataLoaded()) {
+ if (localProject.getControl() == null || !localProject.getControl().isDataLoaded()) {
localProject = loadControlData(localProject);
}
@@ -1350,7 +1350,7 @@
* @param selection
* @return occurence as matrix
*/
- public MatrixND getOccurence(Project project, Selection selection) {
+ public MatrixND getOccurrence(Project project, Selection selection) {
// map species > "year, hauls"
Map<String, Map<String, Set<String>>> dynMatrix = new HashMap<String, Map<String, Set<String>>>();
@@ -1535,6 +1535,12 @@
try {
Double number = Double.valueOf(numberAsString);
Double sweptSurface = haulAndSweptSurface.get(year + ";" + haul);
+ if (sweptSurface == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find swept surface for " + year + ";" + haul);
+ }
+ continue;
+ }
Double density = number / sweptSurface;
// count for species and year
@@ -1591,7 +1597,7 @@
double meanDensity = totalDensity / densityCount;
// surfaceparstrate
- double surfaceparstrate = surfacesParStrates.get(haulCountForYearEntry.getKey() + ";" + dynMatrixEntry.getKey());
+ //double surfaceparstrate = surfacesParStrates.get(haulCountForYearEntry.getKey() + ";" + dynMatrixEntry.getKey());
//TODO echatellier 20101109 finir
//matrix.setValue(dynMatrixEntry.getKey(), haulCountForYearEntry.getKey(), occurence);
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -324,7 +324,7 @@
Project project = createTestProject(projectService);
Selection selection = projectService.initProjectSelection(project);
selection.setName("test");
- MatrixND matrix = projectService.getOccurence(project, selection);
+ MatrixND matrix = projectService.getOccurrence(project, selection);
Assert.assertNotNull(matrix);
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-10 16:47:00 UTC (rev 202)
@@ -25,7 +25,7 @@
<JFrame title="coser.ui.mainview.title" layout="{new BorderLayout()}"
name="mainFrame" onWindowClosing="getHandler().quit()">
- <CoserFrameHandler id="handler" javaBean="new CoserFrameHandler(this)" />
+ <CoserFrameHandler id="handler" constructorParams="this" />
<JMenuBar id='coserMenuBar'>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -418,7 +418,7 @@
*/
protected boolean checkControlSession() {
- boolean result = false;
+ boolean result = true;
// basé sur un hack, car ici, on ne sais pas ce que contient
// le panel principal
@@ -457,10 +457,14 @@
SelectionHandler handler = new SelectionHandler();
selectionView.setHandler(handler);
handler.reloadSelection(selectionView);
-
- File file = new File("/home/chatellier/tmp/coser/zones.png");
- selectionView.getSelectionDetailsTab().getZonesMap().setImage(file);
-
+
+ try {
+ File file = new File("/home/chatellier/tmp/coser/zones.png");
+ selectionView.getSelectionDetailsTab().getZonesMap().setImage(file);
+ } catch(Exception e) {
+ e.printStackTrace();
+ };
+
setMainComponent(selectionView);
} catch (CoserBusinessException ex) {
throw new CoserException("Can't reload selection data", ex);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 16:47:00 UTC (rev 202)
@@ -25,8 +25,8 @@
<Table>
<script><![CDATA[
- import fr.ifremer.coser.ui.selection.model.SpecyListTestModel;
- import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+ import fr.ifremer.coser.ui.selection.model.*;
+ import fr.ifremer.coser.ui.util.*;
]]></script>
<SelectionHandler id="handler" javaBean="null" />
@@ -105,7 +105,6 @@
<JScrollPane>
<ZoneListModel id="zoneListModel" />
<JList id="zoneList" model="{zoneListModel}"
- cellRenderer="{new ZoneListRenderer()}"
enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}"
selectionModel="{new CoserListSelectionModel(zoneList.getSelectionModel(), zoneListModel)}"
onValueChanged="getHandler().zoneListChanged(this, event);"/>
@@ -138,9 +137,8 @@
<row>
<cell weighty="2" fill="both" columns="2">
<JScrollPane>
- <fr.ifremer.coser.ui.selection.model.SpecyListTestModel id="specyListModel" />
+ <SpecyListModel id="specyListModel" />
<JList id="specyList" model="{specyListModel}"
- cellRenderer="{new SpecyListRenderer()}"
enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}"
onMouseClicked="getHandler().showSpeciesContextMenu(this, event)"
selectionModel="{new CoserListSelectionModel(specyList.getSelectionModel(), specyListModel)}"
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -49,6 +49,7 @@
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Selection;
import fr.ifremer.coser.services.ProjectService;
+import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel;
import fr.ifremer.coser.ui.util.CoserListSelectionModel;
/**
@@ -80,18 +81,34 @@
if (log.isDebugEnabled()) {
log.debug("List details tab selected");
}
-
+
Selection selection = view.getContextValue(Selection.class);
// si la selection n'est pas la même que que celle de la sélection
// on met à jour la liste de "Toutes les especes" (L1)
-
+
List<String> currentList = selectionListsView.getSelectionAllSpeciesListModel().getSpecies();
List<String> selectionSpecyList = selection.getSpecies();
-
+
if (!selectionSpecyList.equals(currentList)) {
+ // on calcul également les matrices de d'occurence, densité
+ Project project = view.getContextValue(Project.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+ MatrixND occurrence = projectService.getOccurrence(project, selection);
+ //MatrixND density = projectService.getDensity(project, selection);
+ //MatrixND samplingEffort = projectService.getSamplingEffort(project, selection);
+
+ // set matrix on list model
+ selectionListsView.getSelectionOccurrenceDensityListModel().setOccurrence(occurrence);
+
+ // fill all specy data (at final)
selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpecyList);
+
+ // select all list (not to do for reload)
((CoserListSelectionModel)selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection();
+ updateOccurrenceDensityFilter(selectionListsView);
+ ((CoserListSelectionModel)selectionListsView.getSelectionSizeAllYearList().getSelectionModel()).fillSelection();
+ ((CoserListSelectionModel)selectionListsView.getSelectionMaturityList().getSelectionModel()).fillSelection();
}
}
}
@@ -365,6 +382,43 @@
}
/**
+ * Mise à jour du filtre d'ocurrence et densité.
+ *
+ * Selectionne dans la liste seulement les especes ayant une densité
+ * suppérieure à celle indique (idem pour l'occurence).
+ *
+ * @param view selection list view
+ */
+ public void updateOccurrenceDensityFilter(SelectionListsView view) {
+ String stringOccurrence = view.getSelectionFilterOccurrenceField().getText().trim();
+ String stringDensity = view.getSelectionFilterDensityField().getText().trim();
+
+ try {
+ double occurrence = Double.valueOf(stringOccurrence);
+ double density = Double.valueOf(stringDensity);
+
+ // construction de la liste de selection des especes
+ OccurrenceDensitySpecyListModel model = view.getSelectionOccurrenceDensityListModel();
+ int speciesCount = model.getSize();
+ List<String> filteredSpecies = new ArrayList<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);
+ }
+ }
+
+ // application de la nouvelle selection
+ ((CoserListSelectionModel)view.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(filteredSpecies);
+ }
+ catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse occurrence or density as double", ex);
+ }
+ }
+ }
+
+ /**
* Sauvegarde des listes des selectino d'especes.
*
* @param view view
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-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-10 16:47:00 UTC (rev 202)
@@ -26,18 +26,18 @@
<SelectionHandler id="handler" javaBean="null" />
<script><![CDATA[
- import fr.ifremer.coser.ui.selection.model.SpecyListTestModel;
- import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+ import fr.ifremer.coser.ui.selection.model.*;
+ import fr.ifremer.coser.ui.util.*;
// le modele de la liste est allimenté par la selection de la précédente liste
// la selection est mise à jour par la modification du model de la liste
void $afterCompleteSetup() {
// modification (all species -> all species list)
- selectionAllSpeciesList.addListSelectionListener(selectionOccurenceDensityListModel);
- selectionOccurenceDensityListModel.addListDataListener((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel());
+ selectionAllSpeciesList.addListSelectionListener(selectionOccurrenceDensityListModel);
+ selectionOccurrenceDensityListModel.addListDataListener((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel());
- selectionOccurenceDensityList.addListSelectionListener(selectionSizeAllYearListModel);
+ selectionOccurrenceDensityList.addListSelectionListener(selectionSizeAllYearListModel);
selectionSizeAllYearListModel.addListDataListener((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel());
selectionSizeAllYearList.addListSelectionListener(selectionMaturityListModel);
@@ -69,7 +69,7 @@
<JTextField id="selectionFilterOccurrenceField" columns="3" text="5" />
<JLabel text="coser.ui.selection.filter.density" />
<JTextField id="selectionFilterDensityField" columns="3" text="5" />
- <JButton text="coser.ui.selection.filter.filter" />
+ <JButton text="coser.ui.selection.filter.filter" onActionPerformed="getHandler().updateOccurrenceDensityFilter(this)" />
</JPanel>
</cell>
<cell columns="2">
@@ -82,34 +82,31 @@
<row>
<cell weighty="1" weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionAllSpeciesListModel" />
+ <SpecyListModel id="selectionAllSpeciesListModel" />
<JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}"
- cellRenderer="{new SpecyListCheckBoxRenderer()}"
selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}"
enabled="false" />
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionOccurenceDensityListModel" />
- <JList id="selectionOccurenceDensityList" model="{selectionOccurenceDensityListModel}"
- cellRenderer="{new SpecyListCheckBoxRenderer(true)}"
- selectionModel="{new CoserListSelectionModel(selectionOccurenceDensityList.getSelectionModel(), selectionOccurenceDensityListModel)}"/>
+ <OccurrenceDensitySpecyListModel id="selectionOccurrenceDensityListModel" />
+ <JList id="selectionOccurrenceDensityList" model="{selectionOccurrenceDensityListModel}"
+ cellRenderer="{new SpecyListOccDensRenderer(selectionOccurrenceDensityListModel)}"
+ selectionModel="{new CoserListSelectionModel(selectionOccurrenceDensityList.getSelectionModel(), selectionOccurrenceDensityListModel)}"/>
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionSizeAllYearListModel" />
+ <SpecyListModel id="selectionSizeAllYearListModel" />
<JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}"
- cellRenderer="{new SpecyListCheckBoxRenderer()}"
selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}"/>
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionMaturityListModel" />
+ <SpecyListModel id="selectionMaturityListModel" />
<JList id="selectionMaturityList" model="{selectionMaturityListModel}"
- cellRenderer="{new SpecyListCheckBoxRenderer()}"
selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}"/>
</JScrollPane>
</cell>
@@ -125,11 +122,11 @@
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.selectAll.short'
- onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).fillSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).fillSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.unselectAll.short'
- onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).clearSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).clearSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.selectAll.short'
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -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 java.awt.Component;
-
-import javax.swing.JList;
-
-import org.jdesktop.swingx.renderer.DefaultListRenderer;
-
-/**
- * Check box list renderer.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SpecyListCheckBoxRenderer extends DefaultListRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4329272863520663978L;
-
- protected boolean displayOccurrenceAndDensity;
-
- public SpecyListCheckBoxRenderer() {
- this(false);
- }
-
- public SpecyListCheckBoxRenderer(boolean displayOccurrenceAndDensity) {
- this.displayOccurrenceAndDensity = displayOccurrenceAndDensity;
- }
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- String specy = (String)value;
- //JCheckBox comboBox = new JCheckBox();
-
- String stringValue = null;
- /*if (displayOccurrenceAndDensity) {
- stringValue = "<html>" + specy.getName() + " <span style='font-size:85%;color:gray;'>(X=44, Y=21)</span><html>";
- }
- else {*/
- stringValue = specy;
- //}
- //comboBox.setText(stringValue);
-
- return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus);
- }
-
-}
Added: 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 (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -0,0 +1,77 @@
+/*
+ * #%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);
+ }
+
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,58 +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 java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JList;
-
-/**
- * Basic list renderer.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SpecyListRenderer extends DefaultListCellRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4329272863520663978L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- String specy = (String)value;
- //String stringValue = specy.getName();
-
- //JCheckBox checkBox = new JCheckBox(stringValue);
- //checkBox.setSelected(isSelected);
- return super.getListCellRendererComponent(list, specy, index, isSelected, cellHasFocus);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,91 +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 Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.ui.selection;
-
-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.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);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,101 +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 java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
-import fr.ifremer.coser.bean.Selection;
-import fr.ifremer.coser.services.ProjectService;
-
-/**
- * Model pour combo box contenant la liste des années définies dans le projet.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class YearComboBoxModel extends AbstractListModel implements ComboBoxModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 9172638630862188715L;
-
- protected SelectionDetailsView view;
-
- protected List<Integer> years;
-
- protected Object selectedItem;
-
- public YearComboBoxModel(SelectionDetailsView view) {
- super();
- this.view = view;
- }
-
- protected List<Integer> getYear() {
- if (years == null) {
- Selection selection = view.getContextValue(Selection.class);
- ProjectService service = view.getContextValue(ProjectService.class);
- years = service.getProjectYears(selection);
- }
- return years;
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- return getYear().size();
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public Object getElementAt(int index) {
- return getYear().get(index);
- }
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
- public void setSelectedItem(Object anItem) {
- selectedItem = anItem;
- }
-
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
- @Override
- public Object getSelectedItem() {
- return selectedItem;
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,84 +0,0 @@
-/*
- * #%L
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.ui.selection;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-import fr.ifremer.coser.ui.util.CoserListModel;
-
-/**
- * Model contenant la liste des noms de zone (utilisé dans le detail de selection).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class ZoneListModel extends AbstractListModel implements CoserListModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8155676616312843132L;
-
- protected List<String> zones;
-
- public List<String> getZones() {
- return zones;
- }
-
- public void setZones(List<String> zones) {
- this.zones = zones;
- fireContentsChanged(this, 0, zones.size());
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
- if (zones != null) {
- size = zones.size();
- }
- return size;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public Object getElementAt(int index) {
- return zones.get(index);
- }
-
- /*
- * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object)
- */
- @Override
- public int indexOf(Object element) {
- return zones.indexOf(element);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,56 +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 java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JList;
-
-/**
- * Renderer de la liste des nom de zone.
- * (pas forcement utile avec des String).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class ZoneListRenderer extends DefaultListCellRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4329272863520663978L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- String zone = (String)value;
-
- return super.getListCellRendererComponent(list, zone, index, isSelected, cellHasFocus);
- }
-}
Added: 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 (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -0,0 +1,127 @@
+/*
+ * #%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;
+
+ 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 double getOccurrence(String specy) {
+ List<String> years = (List<String>)occurrence.getSemantic(1);
+ double result = occurrence.getValue(specy, years.get(0));
+ return result;
+ }
+
+ public double getDensity(String specy) {
+ return 6.0;
+ }
+
+ /*
+ * @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);
+ }
+ }
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -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 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/SpecyListTestModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -1,112 +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;
-
-/**
- * Test list model.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SpecyListTestModel 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) {
-
- // il le fait surrement deux fois, mais
- // sans ca, la mise à jour des 4 listes en meme tps ne fonctionne pas
-
- //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/SpecyTypesListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -0,0 +1,92 @@
+/*
+ * #%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 Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-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);
+ }
+}
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java (from rev 106, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * Coser :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.selection.model;
+
+import java.util.List;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+import fr.ifremer.coser.bean.Selection;
+import fr.ifremer.coser.services.ProjectService;
+import fr.ifremer.coser.ui.selection.SelectionDetailsView;
+
+/**
+ * Model pour combo box contenant la liste des années définies dans le projet.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class YearComboBoxModel extends AbstractListModel implements ComboBoxModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 9172638630862188715L;
+
+ protected SelectionDetailsView view;
+
+ protected List<Integer> years;
+
+ protected Object selectedItem;
+
+ public YearComboBoxModel(SelectionDetailsView view) {
+ super();
+ this.view = view;
+ }
+
+ protected List<Integer> getYear() {
+ if (years == null) {
+ Selection selection = view.getContextValue(Selection.class);
+ ProjectService service = view.getContextValue(ProjectService.class);
+ years = service.getProjectYears(selection);
+ }
+ return years;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return getYear().size();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return getYear().get(index);
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedItem = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedItem;
+ }
+}
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java 2010-11-10 16:47:00 UTC (rev 202)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.selection.model;
+
+import java.util.List;
+
+import javax.swing.AbstractListModel;
+
+import fr.ifremer.coser.ui.util.CoserListModel;
+
+/**
+ * Model contenant la liste des noms de zone (utilisé dans le detail de selection).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ZoneListModel extends AbstractListModel implements CoserListModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8155676616312843132L;
+
+ protected List<String> zones;
+
+ public List<String> getZones() {
+ return zones;
+ }
+
+ public void setZones(List<String> zones) {
+ this.zones = zones;
+ fireContentsChanged(this, 0, zones.size());
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int size = 0;
+ if (zones != null) {
+ size = zones.size();
+ }
+ return size;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return zones.get(index);
+ }
+
+ /*
+ * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object)
+ */
+ @Override
+ public int indexOf(Object element) {
+ return zones.indexOf(element);
+ }
+}
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-10 16:47:00 UTC (rev 202)
@@ -116,6 +116,7 @@
coser.ui.selection.invalidFusionName=Selection fusion name not found in referential \!
coser.ui.selection.maturitySpecies=L4 \: Species with maturity
coser.ui.selection.occurenceDensitySpecies=L2 \: Filtered species
+coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html>
coser.ui.selection.saveError=Save error
coser.ui.selection.sizeAllYearSpecies=L3 \: Species with size all year
coser.ui.selection.speciesMenuFusion=Merge
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 14:06:17 UTC (rev 201)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 16:47:00 UTC (rev 202)
@@ -116,6 +116,7 @@
coser.ui.selection.invalidFusionName=Le nom de fusion choisit n'est pas pr\u00E9sent de le r\u00E9f\u00E9rentiel \!
coser.ui.selection.maturitySpecies=L4 \: Esp\u00E8ces avec maturit\u00E9
coser.ui.selection.occurenceDensitySpecies=L2 \: Esp\u00E8ces filtr\u00E9es
+coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html>
coser.ui.selection.saveError=Erreur de sauvegarde
coser.ui.selection.sizeAllYearSpecies=L3 \: Esp\u00E8ces avec taille pour toutes les ann\u00E9es
coser.ui.selection.speciesMenuFusion=Fusion
1
0
r201 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 14:06:17 +0000 (Wed, 10 Nov 2010)
New Revision: 201
Log:
Fix selectAll / unselectAll options
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java 2010-11-10 13:57:56 UTC (rev 200)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java 2010-11-10 14:06:17 UTC (rev 201)
@@ -35,8 +35,6 @@
import jaxx.runtime.swing.OneClicListSelectionModel;
import org.apache.commons.lang.NotImplementedException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Model de selection fonctionnant avec les intances des objects selectionnée
@@ -113,7 +111,8 @@
*/
@Override
public void contentsChanged(ListDataEvent e) {
- clearSelection();
+ // super is mandatory here
+ super.clearSelection();
Iterator<Object> itO = new HashSet<Object>(selectedObjects).iterator();
while (itO.hasNext()) {
@@ -162,4 +161,10 @@
public void fillSelection() {
addSelectionInterval(0, coserListModel.getSize() - 1);
}
+
+ @Override
+ public void clearSelection() {
+ super.clearSelection();
+ registerSelection(0, coserListModel.getSize() - 1);
+ }
}
1
0
r200 - in trunk/coser-ui/src/main/java/fr/ifremer/coser/ui: selection util
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 13:57:56 +0000 (Wed, 10 Nov 2010)
New Revision: 200
Log:
Reimppletation de l'ecoute des selections de list (sans s'ecouter soit meme, c'est plus simple a comprendre)
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
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-11-10 13:05:01 UTC (rev 199)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-10 13:57:56 UTC (rev 200)
@@ -29,6 +29,9 @@
import fr.ifremer.coser.ui.selection.model.SpecyListTestModel;
import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+ // le modele de la liste est allimenté par la selection de la précédente liste
+ // la selection est mise à jour par la modification du model de la liste
+
void $afterCompleteSetup() {
// modification (all species -> all species list)
selectionAllSpeciesList.addListSelectionListener(selectionOccurenceDensityListModel);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java 2010-11-10 13:05:01 UTC (rev 199)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java 2010-11-10 13:57:56 UTC (rev 200)
@@ -31,8 +31,6 @@
import javax.swing.ListSelectionModel;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import jaxx.runtime.swing.OneClicListSelectionModel;
@@ -45,9 +43,6 @@
* et non par indices.
* Etend {@link OneClicListSelectionModel} pour sélectionner par simple clic.
*
- * Implemente {@link ListSelectionListener} pour que la selection que la liste
- * courante sauvegarde les instances des objets correspondants aux indices selectionnés.
- *
* Implemente {@link ListDataListener} pour que la selection apres changement
* des données reste la même au niveau des objets (sinon, les indices
* ne correspondent pas au données précédent le changement.
@@ -58,10 +53,8 @@
* Last update : $Date$
* By : $Author$
*/
-public class CoserListSelectionModel extends OneClicListSelectionModel implements ListDataListener, ListSelectionListener {
+public class CoserListSelectionModel extends OneClicListSelectionModel implements ListDataListener {
- private static final Log log = LogFactory.getLog(CoserListSelectionModel.class);
-
/** Selection objects. */
protected Set<Object> selectedObjects;
@@ -78,11 +71,6 @@
super(delegate, coserListModel);
this.coserListModel = coserListModel;
selectedObjects = new HashSet<Object>();
-
- // pour que la selection que la liste courante
- // sauvegarde les instances des objets correspondants
- // aux indices selectionnés.
- addListSelectionListener(this);
}
/**
@@ -95,7 +83,13 @@
if (objects != null) {
selectedObjects.addAll(objects);
}
- contentsChanged(null);
+ setValueIsAdjusting(true);
+ try {
+ contentsChanged(null);
+ }
+ finally {
+ setValueIsAdjusting(false);
+ }
}
/*
@@ -121,9 +115,7 @@
public void contentsChanged(ListDataEvent e) {
clearSelection();
- setValueIsAdjusting(true);
-
- Iterator<Object> itO = selectedObjects.iterator();
+ Iterator<Object> itO = new HashSet<Object>(selectedObjects).iterator();
while (itO.hasNext()) {
Object o = itO.next();
int index = coserListModel.indexOf(o);
@@ -138,32 +130,29 @@
itO.remove();
}*/
}
-
- setValueIsAdjusting(false);
}
- /*
- * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
- */
@Override
- public void valueChanged(ListSelectionEvent e) {
+ public void setSelectionInterval(int index0, int index1) {
+ super.setSelectionInterval(index0, index1);
+ registerSelection(index0, index1);
+ }
- // ne fonctionne pas si c'est fait seulement quand
- // IsAdjusting est a true.
+ @Override
+ public void addSelectionInterval(int index0, int index1) {
+ super.addSelectionInterval(index0, index1);
+ registerSelection(index0, index1);
+ }
- if (!e.getValueIsAdjusting()) {
- int first = e.getFirstIndex();
- int last = e.getLastIndex();
-
- for (int i = first ; i <= last ; ++i) {
- Object o = coserListModel.getElementAt(i);
- if (isSelectedIndex(i)) {
- selectedObjects.add(o);
- }
- else {
- selectedObjects.remove(o);
- }
+ protected void registerSelection(int index0, int index1) {
+ for (int i = index0 ; i <= index1 ; ++i) {
+ Object o = coserListModel.getElementAt(i);
+ if (isSelectedIndex(i)) {
+ selectedObjects.add(o);
}
+ else {
+ selectedObjects.remove(o);
+ }
}
}
1
0
r199 - trunk/coser-business/src/test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 13:05:01 +0000 (Wed, 10 Nov 2010)
New Revision: 199
Log:
Fix test
Modified:
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 12:58:40 UTC (rev 198)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 13:05:01 UTC (rev 199)
@@ -266,7 +266,7 @@
Assert.assertEquals(25, selection.getCatch().size());
Assert.assertEquals(30, selection.getLength().size());
- project = projectService.mergeSpecies(project, selection, "COSER_SPECIES_MERGE", "COSER_SPECIES1", "COSER_SPECIES2");
+ project = projectService.mergeSpecies(project, selection, "COSER_SPECIES_MERGE", null, "COSER_SPECIES1", "COSER_SPECIES2");
Assert.assertEquals(19, selection.getCatch().size());
Assert.assertEquals(29, selection.getLength().size());
1
0
r198 - in trunk: coser-business/src/main/java/fr/ifremer/coser/bean coser-business/src/main/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/java/fr/ifremer/coser/ui/project coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model coser-ui/src/main/java/fr/ifremer/coser/ui/util
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 12:58:40 +0000 (Wed, 10 Nov 2010)
New Revision: 198
Log:
Rechargement complet des selections, refactoring
Added:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
Removed:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Specy.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListSelectionModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListTestModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/TypeSpecyListModel.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
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
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Specy.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Specy.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Specy.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,93 +0,0 @@
-/*
- * #%L
- * Coser :: Business
- *
- * $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 Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.bean;
-
-/**
- * Specy.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class Specy extends AbstractEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -9161753536468850648L;
-
- protected String name;
-
- protected int x;
-
- protected double y;
-
- public Specy() {
- super();
- }
-
- /**
- * @param name
- * @param x
- * @param y
- */
- public Specy(String name, int x, int y) {
- this();
- this.name = name;
- this.x = x;
- this.y = y;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- getPropertyChangeSupport().firePropertyChange("name", old, this.name);
- }
-
- public int getX() {
- return x;
- }
-
- public void setX(int x) {
- int old = this.x;
- this.x = x;
- getPropertyChangeSupport().firePropertyChange("x", old, this.name);
- }
-
- public double getY() {
- return y;
- }
-
- public void setY(double y) {
- double old = this.y;
- this.y = y;
- getPropertyChangeSupport().firePropertyChange("y", old, this.name);
- }
-}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1234,11 +1234,12 @@
* @param project project
* @param selection selection
* @param newSpecyName 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... speciesNames) throws CoserBusinessException {
+ public Project mergeSpecies(Project project, Selection selection, String newSpecyName, String comment, String... speciesNames) throws CoserBusinessException {
if (!isSpecyNameExist(project, newSpecyName)) {
throw new CoserBusinessException(_("Specy %s doesn't exist in referential", newSpecyName));
@@ -1247,6 +1248,7 @@
MergeSpeciesCommand command = new MergeSpeciesCommand();
command.setNewSpecyName(newSpecyName);
command.setSpeciesNames(speciesNames);
+ command.setComment(comment);
commandService.doAction(command, project, selection);
return project;
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -128,7 +128,10 @@
*/
protected void setMainComponent(Component component) {
view.getMainViewContent().removeAll();
- view.getMainViewContent().add(component, BorderLayout.CENTER);
+ if (component != null) {
+ view.getMainViewContent().add(component, BorderLayout.CENTER);
+ }
+ view.getMainViewContent().repaint();
view.getMainViewContent().validate();
}
@@ -302,49 +305,21 @@
* @param projectView view
*/
public void loadProject(final ProjectOpenView projectView) {
-
- final String projectName = (String)projectView.getProjectsComboBox().getSelectedItem();
- SwingWorker<Project, Void> task = new SwingWorker<Project, Void>() {
- long before = System.currentTimeMillis();
-
- @Override
- protected Project doInBackground() {
- projectView.getLoadingProgressBar().setVisible(true);
- ProjectService projectService = projectView.getContextValue(ProjectService.class);
- Project project = null;
- try {
- Project p = projectService.openProject(projectName);
- project = p;
- } catch (CoserBusinessException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't open project", ex);
- }
- JOptionPane.showMessageDialog(projectView, ex.getMessage(), _("coser.ui.project.openError"),
- JOptionPane.ERROR_MESSAGE);
- projectView.getLoadingProgressBar().setVisible(false);
- }
- return project;
+ final String projectName = (String)projectView.getProjectsComboBox().getSelectedItem();
+ ProjectService projectService = projectView.getContextValue(ProjectService.class);
+ try {
+ Project project = projectService.openProject(projectName);
+ projectLoaded(project);
+ //showControlView();
+ setMainComponent(null);
+ } catch (CoserBusinessException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't open project", ex);
}
-
- @Override
- protected void done() {
- if (log.isInfoEnabled()) {
- long after = System.currentTimeMillis();
- log.info("Project reloaded in " + (after-before) + "ms");
- }
- try {
- Project project = get();
- if (project != null) {
- projectLoaded(project);
- showControlView();
- }
- } catch (Exception ex) {
- throw new CoserException("Can't create project", ex);
- }
- }
- };
- task.execute();
+ JOptionPane.showMessageDialog(projectView, ex.getMessage(), _("coser.ui.project.openError"),
+ JOptionPane.ERROR_MESSAGE);
+ }
}
/**
@@ -448,10 +423,12 @@
// basé sur un hack, car ici, on ne sais pas ce que contient
// le panel principal
// attention, c'est du big hack ;)
- Component comp = view.getMainViewContent().getComponent(0);
- if (comp instanceof ControlView) {
- ControlView controlView = (ControlView)comp;
- result = controlView.getHandler().checkValidationModelErrors(controlView);
+ if (view.getMainViewContent().getComponentCount() > 0) {
+ Component comp = view.getMainViewContent().getComponent(0);
+ if (comp instanceof ControlView) {
+ ControlView controlView = (ControlView)comp;
+ result = controlView.getHandler().checkValidationModelErrors(controlView);
+ }
}
return result;
@@ -468,16 +445,19 @@
Project project = view.getContextValue(Project.class);
Selection selection = project.getSelections().get(selectionName);
try {
- projectService.loadSelectionData(project, selection);
-
+ project = projectService.loadSelectionData(project, selection);
view.setContextValue(selection);
SelectionView selectionView = new SelectionView(view);
selectionView.setSelection(selection);
+
// fix, binding not working ?
selectionView.getSelectionDetailsTab().getValidatorSelection().setBean(selection);
- selectionView.setHandler(new SelectionHandler());
+ SelectionHandler handler = new SelectionHandler();
+ selectionView.setHandler(handler);
+ handler.reloadSelection(selectionView);
+
File file = new File("/home/chatellier/tmp/coser/zones.png");
selectionView.getSelectionDetailsTab().getZonesMap().setImage(file);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2010-11-10 12:58:40 UTC (rev 198)
@@ -43,11 +43,6 @@
onActionPerformed="getHandler().loadProject(this)" />
</cell>
</row>
- <row>
- <cell weightx="1" fill="horizontal" columns="2">
- <JProgressBar id="loadingProgressBar" indeterminate="true" visible="false" />
- </cell>
- </row>
</Table>
</cell>
</row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 12:58:40 UTC (rev 198)
@@ -24,6 +24,11 @@
-->
<Table>
+ <script><![CDATA[
+ import fr.ifremer.coser.ui.selection.model.SpecyListTestModel;
+ import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+ ]]></script>
+
<SelectionHandler id="handler" javaBean="null" />
<Boolean id="creationState" javaBean="false" />
@@ -35,7 +40,7 @@
<BeanValidator id='validatorSelection' bean='selection'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"
errorTableModel="errorsTableModel">
- <field name="name" component="selectionDetailsSelectionNameField" />
+ <field name="name" component="detailsSelectionNameField" />
</BeanValidator>
<row>
@@ -46,11 +51,11 @@
<JLabel text="coser.ui.selection.details.name" />
</cell>
<cell weightx="1" fill="horizontal" columns="3">
- <JTextField id="selectionDetailsSelectionNameField" text="{getSelection().getName()}"
+ <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}"
enabled="{isCreationState()}"/>
- <javax.swing.text.Document javaBean="selectionDetailsSelectionNameField.getDocument()"
- onInsertUpdate='getSelection().setName(selectionDetailsSelectionNameField.getText())'
- onRemoveUpdate='getSelection().setName(selectionDetailsSelectionNameField.getText())' />
+ <javax.swing.text.Document javaBean="detailsSelectionNameField.getDocument()"
+ onInsertUpdate='getSelection().setName(detailsSelectionNameField.getText())'
+ onRemoveUpdate='getSelection().setName(detailsSelectionNameField.getText())' />
</cell>
</row>
<row>
@@ -59,11 +64,11 @@
</cell>
<cell weightx="1" fill="horizontal" columns="3">
<JScrollPane>
- <JTextArea id="selectionDetailsDescription" text="{getSelection().getDescription()}" rows="3" />
+ <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3" />
</JScrollPane>
- <javax.swing.text.Document javaBean="selectionDetailsDescription.getDocument()"
- onInsertUpdate='getSelection().setDescription(selectionDetailsDescription.getText())'
- onRemoveUpdate='getSelection().setDescription(selectionDetailsDescription.getText())' />
+ <javax.swing.text.Document javaBean="detailsDescription.getDocument()"
+ onInsertUpdate='getSelection().setDescription(detailsDescription.getText())'
+ onRemoveUpdate='getSelection().setDescription(detailsDescription.getText())' />
</cell>
</row>
<row>
@@ -72,18 +77,18 @@
</cell>
<cell weightx="1" fill="horizontal">
<YearComboBoxModel id="beginYearComboBoxModel" constructorParams="this" />
- <JComboBox id="selectionDetailsBeginYearField"
+ <JComboBox id="beginYearComboBox"
model="{beginYearComboBoxModel}"
- onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setBeginDate((Integer)selectionDetailsBeginYearField.getSelectedItem())" />
+ onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setBeginDate((Integer)beginYearComboBox.getSelectedItem())" />
</cell>
<cell anchor="west">
<JLabel text="coser.ui.selection.details.endDate" />
</cell>
<cell weightx="1" fill="horizontal">
<YearComboBoxModel id="endYearComboBoxModel" constructorParams="this" />
- <JComboBox id="selectionDetailsEndYearField"
+ <JComboBox id="endYearComboBox"
model="{endYearComboBoxModel}"
- onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setEndDate((Integer)selectionDetailsEndYearField.getSelectedItem())" />
+ onActionPerformed="getHandler().updateSelectionDateData(this, event); getSelection().setEndDate((Integer)endYearComboBox.getSelectedItem())" />
</cell>
</row>
<row>
@@ -98,12 +103,12 @@
<row>
<cell weighty="2" fill="both" columns="4">
<JScrollPane>
- <SelectionZoneListModel id="selectionZoneModel" />
- <JList id="zoneList" model="{selectionZoneModel}"
- cellRenderer="{new SelectionZoneListRenderer()}"
- enabled="{selectionDetailsBeginYearField.getSelectedItem() != null && selectionDetailsEndYearField.getSelectedItem() != null}"
- selectionModel="{new OneClicListSelectionModel(zoneList.getSelectionModel(), selectionZoneModel)}"
- onValueChanged="getHandler().zoneListChanged(this);"/>
+ <ZoneListModel id="zoneListModel" />
+ <JList id="zoneList" model="{zoneListModel}"
+ cellRenderer="{new ZoneListRenderer()}"
+ enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}"
+ selectionModel="{new CoserListSelectionModel(zoneList.getSelectionModel(), zoneListModel)}"
+ onValueChanged="getHandler().zoneListChanged(this, event);"/>
</JScrollPane>
</cell>
</row>
@@ -122,22 +127,24 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="2">
<JScrollPane>
- <TypeSpecyListModel id="typeSpecyModel" constructorParams="this" />
+ <SpecyTypesListModel id="typeSpecyModel" constructorParams="this" />
<JList id="typeSpecyList" model="{typeSpecyModel}"
- selectionModel="{new OneClicListSelectionModel(typeSpecyList.getSelectionModel(), typeSpecyModel)}"
- onValueChanged="getHandler().typeSpecyListChanged(this)"/>
+ enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}"
+ selectionModel="{new CoserListSelectionModel(typeSpecyList.getSelectionModel(), typeSpecyModel)}"
+ onValueChanged="getHandler().typeSpecyListChanged(this, event)"/>
</JScrollPane>
</cell>
</row>
<row>
<cell weighty="2" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="specyListModel" />
+ <fr.ifremer.coser.ui.selection.model.SpecyListTestModel id="specyListModel" />
<JList id="specyList" model="{specyListModel}"
cellRenderer="{new SpecyListRenderer()}"
+ enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}"
onMouseClicked="getHandler().showSpeciesContextMenu(this, event)"
- selectionModel="{new OneClicListSelectionModel(specyList.getSelectionModel(), specyListModel)}"
- onValueChanged="getHandler().specyListChanged(this)"/>
+ selectionModel="{new CoserListSelectionModel(specyList.getSelectionModel(), specyListModel)}"
+ onValueChanged="getHandler().specyListChanged(this, event)"/>
<ListSelectionModel id="specyListSelectionModel" javaBean="specyList.getSelectionModel()" />
</JScrollPane>
</cell>
@@ -148,7 +155,10 @@
<row>
<cell weighty="1" fill="both" columns="4">
<JScrollPane>
- <JXTextArea constructorParams='_("coser.ui.selection.details.comment")' rows="3" />
+ <JXTextArea id="detailsComment" constructorParams='_("coser.ui.selection.details.comment")' rows="3" />
+ <javax.swing.text.Document javaBean="detailsComment.getDocument()"
+ onInsertUpdate='getSelection().setComment(detailsComment.getText())'
+ onRemoveUpdate='getSelection().setComment(detailsComment.getText())' />
</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-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -25,6 +25,7 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@@ -34,6 +35,8 @@
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
import jaxx.runtime.JAXXUtil;
@@ -45,8 +48,8 @@
import fr.ifremer.coser.CoserException;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Selection;
-import fr.ifremer.coser.bean.Specy;
import fr.ifremer.coser.services.ProjectService;
+import fr.ifremer.coser.ui.util.CoserListSelectionModel;
/**
* Selection handler.
@@ -62,6 +65,68 @@
private static final Log log = LogFactory.getLog(SelectionHandler.class);
/**
+ * Appelé sur un changement d'onglet dans l'interface de sélection.
+ *
+ * @param view view
+ * @param event change event
+ */
+ public void selectionTabChanged(SelectionView view, ChangeEvent event) {
+
+ // selected tab is Lists
+ Component selectedComponent = view.getSelectedComponent();
+ if (selectedComponent instanceof SelectionListsView) {
+ SelectionListsView selectionListsView = (SelectionListsView)selectedComponent;
+
+ if (log.isDebugEnabled()) {
+ log.debug("List details tab selected");
+ }
+
+ Selection selection = view.getContextValue(Selection.class);
+
+ // si la selection n'est pas la même que que celle de la sélection
+ // on met à jour la liste de "Toutes les especes" (L1)
+
+ List<String> currentList = selectionListsView.getSelectionAllSpeciesListModel().getSpecies();
+ List<String> selectionSpecyList = selection.getSpecies();
+
+ if (!selectionSpecyList.equals(currentList)) {
+ selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpecyList);
+ ((CoserListSelectionModel)selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection();
+ }
+ }
+ }
+
+ /**
+ * Recharge la selection en valorisant les différentes listes.
+ *
+ * Fait ici, car sinon, les evenements ne se déclenchent pas au même
+ * moment.
+ *
+ * @param view view to fill
+ */
+ public void reloadSelection(SelectionView view) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Reloading selection...");
+ }
+
+ Selection selection = view.getSelection();
+
+ // fill details view
+ SelectionDetailsView detailView = view.getSelectionDetailsTab();
+ detailView.getBeginYearComboBox().setSelectedItem(selection.getBeginDate());
+ detailView.getEndYearComboBox().setSelectedItem(selection.getEndDate());
+ // "typeSpecies" before other, more performant
+ ((CoserListSelectionModel)detailView.getTypeSpecyList().getSelectionModel()).setSelectedObjects(selection.getFilterSpecyTypes());
+ ((CoserListSelectionModel)detailView.getZoneList().getSelectionModel()).setSelectedObjects(selection.getZones());
+ ((CoserListSelectionModel)detailView.getSpecyList().getSelectionModel()).setSelectedObjects(selection.getSpecies());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Selection reloaded.");
+ }
+ }
+
+ /**
* Rafraichit la liste des zones suite à la selection des dates.
*
* @param view view
@@ -72,8 +137,8 @@
Selection selection = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
- Integer beginYear = (Integer)view.getSelectionDetailsBeginYearField().getSelectedItem();
- Integer endYear = (Integer)view.getSelectionDetailsEndYearField().getSelectedItem();
+ Integer beginYear = (Integer)view.getBeginYearComboBox().getSelectedItem();
+ Integer endYear = (Integer)view.getEndYearComboBox().getSelectedItem();
// il est possible que l'evenement fasse suite a une seule des selections
if (beginYear != null && endYear != null) {
@@ -81,7 +146,7 @@
log.debug("Refreshing zones list");
}
List<String> zones = projectService.getProjectZone(selection, beginYear, endYear);
- view.getSelectionZoneModel().setZones(zones);
+ view.getZoneListModel().setZones(zones);
}
}
@@ -89,58 +154,61 @@
* Appellé lorsque la selection de la liste des zones a changé.
*
* @param view view
+ * @param event event
*/
- public void zoneListChanged(SelectionDetailsView view) {
- Selection selection = view.getContextValue(Selection.class);
+ public void zoneListChanged(SelectionDetailsView view, ListSelectionEvent event) {
- // get selected zones as list
- Object[] selectedZones = view.getZoneList().getSelectedValues();
- List<String> zones = new ArrayList<String>(selectedZones.length);
- for (Object selectedZone : selectedZones) {
- zones.add((String)selectedZone);
+ // reload is slow without it
+ if (!event.getValueIsAdjusting()) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Zone list selection changed, updating species list");
+ }
+
+ Selection selection = view.getContextValue(Selection.class);
+
+ // get selected zones as list
+ Object[] selectedZones = view.getZoneList().getSelectedValues();
+ List<String> zones = new ArrayList<String>(selectedZones.length);
+ for (Object selectedZone : selectedZones) {
+ zones.add((String)selectedZone);
+ }
+ selection.setZones(zones);
+
+ updateSelectionSpecies(view);
}
- selection.setZones(zones);
-
- updateSelectionSpecies(view);
}
/**
* Appelé lorsque la selection de la liste des types.
*
* @param view view
+ * @param event event
*/
- public void typeSpecyListChanged(SelectionDetailsView view) {
- Selection selection = view.getContextValue(Selection.class);
+ public void typeSpecyListChanged(SelectionDetailsView view, ListSelectionEvent event) {
+
+ // reload is slow without it
+ if (!event.getValueIsAdjusting()) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Specy type selection changed, updating species list");
+ }
- // get selected specy types
- Object[] selectedSpecyTypes = view.getTypeSpecyList().getSelectedValues();
- List<String> specyTypes = new ArrayList<String>();
- for (Object selectedSpecyType : selectedSpecyTypes) {
- specyTypes.add((String)selectedSpecyType);
+ Selection selection = view.getContextValue(Selection.class);
+
+ // get selected specy types
+ Object[] selectedSpecyTypes = view.getTypeSpecyList().getSelectedValues();
+ List<String> specyTypes = new ArrayList<String>();
+ for (Object selectedSpecyType : selectedSpecyTypes) {
+ specyTypes.add((String)selectedSpecyType);
+ }
+ selection.setFilterSpecyTypes(specyTypes);
+
+ updateSelectionSpecies(view);
}
- selection.setFilterSpecyTypes(specyTypes);
-
- updateSelectionSpecies(view);
}
/**
- * Appelé lorsque la selection de la liste des especes change.
- *
- * @param view
- */
- public void specyListChanged(SelectionDetailsView view) {
- Selection selection = view.getContextValue(Selection.class);
-
- // get selected species
- Object[] selectedSpecies = view.getSpecyList().getSelectedValues();
- List<String> species= new ArrayList<String>();
- for (Object selectedSpecy : selectedSpecies) {
- species.add((String)selectedSpecy);
- }
- selection.setSpecies(species);
- }
-
- /**
* Rafraichit la liste des especes avec les dates sélectionnées
* et les zones selectionnées ET filtrées par la liste
* des type d'especes.
@@ -150,6 +218,11 @@
* @param view view
*/
protected void updateSelectionSpecies(SelectionDetailsView view) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Updating species list");
+ }
+
Project project = view.getContextValue(Project.class);
Selection selection = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -164,17 +237,43 @@
specyTypes.add((String)selectedSpecyType);
}
- Integer beginYear = (Integer)view.getSelectionDetailsBeginYearField().getSelectedItem();
- Integer endYear = (Integer)view.getSelectionDetailsEndYearField().getSelectedItem();
+ Integer beginYear = (Integer)view.getBeginYearComboBox().getSelectedItem();
+ Integer endYear = (Integer)view.getEndYearComboBox().getSelectedItem();
// il est possible que l'evenement fasse suite a une seule des selections
if (beginYear != null && endYear != null && zones != null) {
List<String> species = projectService.getProjectSpecies(project, selection, zones, beginYear, endYear, specyTypes);
- view.getSpecyListModel().setSpecy(species);
+ view.getSpecyListModel().setSpecies(species);
}
}
/**
+ * Appelé lorsque la selection de la liste des especes change.
+ *
+ * @param view view
+ * @param event event
+ */
+ public void specyListChanged(SelectionDetailsView view, ListSelectionEvent event) {
+
+ if (!event.getValueIsAdjusting()) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Species selection changed, updating registered species");
+ }
+
+ Selection selection = view.getContextValue(Selection.class);
+
+ // get selected species
+ Object[] selectedSpecies = view.getSpecyList().getSelectedValues();
+ List<String> species= new ArrayList<String>();
+ for (Object selectedSpecy : selectedSpecies) {
+ species.add((String)selectedSpecy);
+ }
+ selection.setSpecies(species);
+ }
+ }
+
+ /**
* Affiche un menu contextuel lors du clic (droit) sur la liste des especes.
*
* @param view view
@@ -291,7 +390,7 @@
Project project = view.getContextValue(Project.class);
Selection seletion = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
-
+
boolean newSpecyExist = projectService.isSpecyNameExist(project, newSpecyName);
if (!newSpecyExist) {
JOptionPane.showMessageDialog(view, _("coser.ui.selection.invalidFusionName"),
@@ -303,10 +402,10 @@
Object[] selectedSpecies = parent.getSpecyList().getSelectedValues();
String[] specyNames = new String[selectedSpecies.length];
for (int i = 0 ; i < selectedSpecies.length ; ++i) {
- Specy selectedSpecy = (Specy)selectedSpecies[i];
- specyNames[i] = selectedSpecy.getName();
+ String selectedSpecy = (String)selectedSpecies[i];
+ specyNames[i] = selectedSpecy;
}
-
+
try {
projectService.mergeSpecies(project, seletion, newSpecyName, comment, specyNames);
}
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-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-10 12:58:40 UTC (rev 198)
@@ -26,16 +26,19 @@
<SelectionHandler id="handler" javaBean="null" />
<script><![CDATA[
+ import fr.ifremer.coser.ui.selection.model.SpecyListTestModel;
+ import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+
void $afterCompleteSetup() {
// modification (all species -> all species list)
selectionAllSpeciesList.addListSelectionListener(selectionOccurenceDensityListModel);
- selectionOccurenceDensityListModel.addListDataListener((SpecyListSelectionModel)selectionOccurenceDensityList.getSelectionModel());
+ selectionOccurenceDensityListModel.addListDataListener((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel());
selectionOccurenceDensityList.addListSelectionListener(selectionSizeAllYearListModel);
- selectionSizeAllYearListModel.addListDataListener((SpecyListSelectionModel)selectionSizeAllYearList.getSelectionModel());
+ selectionSizeAllYearListModel.addListDataListener((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel());
selectionSizeAllYearList.addListSelectionListener(selectionMaturityListModel);
- selectionMaturityListModel.addListDataListener((SpecyListSelectionModel)selectionMaturityList.getSelectionModel());
+ selectionMaturityListModel.addListDataListener((CoserListSelectionModel)selectionMaturityList.getSelectionModel());
}
]]></script>
@@ -76,69 +79,70 @@
<row>
<cell weighty="1" weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionAllSpeciesListModel" javaBean="new fr.ifremer.coser.ui.selection.SpecyListTestModel()" />
+ <SpecyListTestModel id="selectionAllSpeciesListModel" />
<JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}"
- cellRenderer="{new fr.ifremer.coser.ui.selection.SpecyListCheckBoxRenderer()}"
- selectionModel="{new SpecyListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}"/>
+ cellRenderer="{new SpecyListCheckBoxRenderer()}"
+ selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}"
+ enabled="false" />
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionOccurenceDensityListModel" javaBean="new fr.ifremer.coser.ui.selection.SpecyListTestModel()" />
+ <SpecyListTestModel id="selectionOccurenceDensityListModel" />
<JList id="selectionOccurenceDensityList" model="{selectionOccurenceDensityListModel}"
- cellRenderer="{new fr.ifremer.coser.ui.selection.SpecyListCheckBoxRenderer(true)}"
- selectionModel="{new SpecyListSelectionModel(selectionOccurenceDensityList.getSelectionModel(), selectionOccurenceDensityListModel)}"/>
+ cellRenderer="{new SpecyListCheckBoxRenderer(true)}"
+ selectionModel="{new CoserListSelectionModel(selectionOccurenceDensityList.getSelectionModel(), selectionOccurenceDensityListModel)}"/>
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionSizeAllYearListModel" javaBean="new fr.ifremer.coser.ui.selection.SpecyListTestModel()" />
+ <SpecyListTestModel id="selectionSizeAllYearListModel" />
<JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}"
- cellRenderer="{new fr.ifremer.coser.ui.selection.SpecyListCheckBoxRenderer()}"
- selectionModel="{new SpecyListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}"/>
+ cellRenderer="{new SpecyListCheckBoxRenderer()}"
+ selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}"/>
</JScrollPane>
</cell>
<cell weightx="1" fill="both" columns="2">
<JScrollPane>
- <SpecyListTestModel id="selectionMaturityListModel" javaBean="new fr.ifremer.coser.ui.selection.SpecyListTestModel()" />
+ <SpecyListTestModel id="selectionMaturityListModel" />
<JList id="selectionMaturityList" model="{selectionMaturityListModel}"
- cellRenderer="{new fr.ifremer.coser.ui.selection.SpecyListCheckBoxRenderer()}"
- selectionModel="{new SpecyListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}"/>
+ cellRenderer="{new SpecyListCheckBoxRenderer()}"
+ selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}"/>
</JScrollPane>
</cell>
</row>
<row>
<cell fill="horizontal" weightx="1">
- <JButton text='coser.ui.common.selectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionAllSpeciesList.getSelectionModel()).fillSelection()"/>
+ <JButton text='coser.ui.common.selectAll.short' enabled="false"
+ onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).fillSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
- <JButton text='coser.ui.common.unselectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionAllSpeciesList.getSelectionModel()).clearSelection()"/>
+ <JButton text='coser.ui.common.unselectAll.short' enabled="false"
+ onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).clearSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.selectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).fillSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).fillSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.unselectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).clearSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).clearSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.selectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionSizeAllYearList.getSelectionModel()).fillSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).fillSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.unselectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionSizeAllYearList.getSelectionModel()).clearSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).clearSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.selectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionMaturityList.getSelectionModel()).fillSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).fillSelection()"/>
</cell>
<cell fill="horizontal" weightx="1">
<JButton text='coser.ui.common.unselectAll.short'
- onActionPerformed="((SpecyListSelectionModel)selectionMaturityList.getSelectionModel()).clearSelection()"/>
+ onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).clearSelection()"/>
</cell>
</row>
<row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx 2010-11-10 12:58:40 UTC (rev 198)
@@ -30,12 +30,22 @@
<SelectionHandler id="handler" javaBean="null" />
<script><![CDATA[
void $afterCompleteSetup() {
- // modification (species -> all species list)
+ /*// modification (species -> all species list)
SpecyListTestModel model = getSelectionListsView().getSelectionAllSpeciesListModel();
getSelectionDetailsTab().getSpecyList().addListSelectionListener(model);
+ ((SpecyListSelectionModel)getSelectionDetailsTab().getSpecyList().getSelectionModel()).fillSelection();
// FIXME add common interface to species models
//getSelectionDetailsTab().getSpecyList().getModel().addListDataListener((SpecyListSelectionModel)getSelectionDetailsTab().getSpecyList().getSelectionModel());
+ */
+
+ addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent event) {
+ if (getHandler() != null) {
+ getHandler().selectionTabChanged(SelectionView.this, event);
+ }
+ }
+ });
}
]]></script>
<tab title="coser.ui.selection.tab.details">
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListModel.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,74 +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;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-/**
- * Model contenant la liste des noms de zone (utilsé dans le detail de selection).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SelectionZoneListModel extends AbstractListModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8155676616312843132L;
-
- protected List<String> zones;
-
- public List<String> getZones() {
- return zones;
- }
-
- public void setZones(List<String> zones) {
- this.zones = zones;
- fireContentsChanged(this, 0, zones.size());
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
- if (zones != null) {
- size = zones.size();
- }
- return size;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public Object getElementAt(int index) {
- return zones.get(index);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListRenderer.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListRenderer.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,56 +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 java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JList;
-
-/**
- * Renderer de la liste des nom de zone.
- * (pas forcement utile avec des String).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SelectionZoneListRenderer extends DefaultListCellRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4329272863520663978L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- String zone = (String)value;
-
- return super.getListCellRendererComponent(list, zone, index, isSelected, cellHasFocus);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListSelectionModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListSelectionModel.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListSelectionModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,141 +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;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import jaxx.runtime.swing.OneClicListSelectionModel;
-
-import org.apache.commons.lang.NotImplementedException;
-
-import fr.ifremer.coser.bean.Specy;
-
-/**
- * Model de selection de la liste des especes.
- * (ecoute un autre Model de list, et ecoute sa propre selection).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SpecyListSelectionModel extends OneClicListSelectionModel implements ListDataListener, ListSelectionListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4379088046119691748L;
-
- protected Set<Object> selectedObjects;
- protected SpecyListTestModel specyListModel;
-
- /**
- * @param delegate
- * @param model
- */
- public SpecyListSelectionModel(ListSelectionModel delegate, SpecyListTestModel model) {
- super(delegate, model);
- specyListModel = model;
- selectedObjects = new HashSet<Object>();
- addListSelectionListener(this);
- }
-
- /*
- * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
- */
- @Override
- public void intervalAdded(ListDataEvent e) {
- throw new NotImplementedException("Not yet implemented");
- }
-
- /*
- * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
- */
- @Override
- public void intervalRemoved(ListDataEvent e) {
- throw new NotImplementedException("Not yet implemented");
- }
-
- /*
- * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
- */
- @Override
- public void contentsChanged(ListDataEvent e) {
- clearSelection();
-
- Iterator<Object> itO = selectedObjects.iterator();
- while (itO.hasNext()) {
- Object o = itO.next();
- int index = specyListModel.getIndexOf(o);
-
- if (index >= 0) {
- addSelectionInterval(index, index);
- }
-
- // a voir, mais si on le remove, avec les evenements multiples
- // on pert toutes la selection
- /*else {
- itO.remove();
- }*/
- }
- }
-
- /*
- * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
- */
- @Override
- public void valueChanged(ListSelectionEvent e) {
-
- // ne fonctionne pas si c'est fait seulement quand
- // IsAdjusting est a true.
-
- if (e.getValueIsAdjusting()) {
- int first = e.getFirstIndex();
- int last = e.getLastIndex();
-
- for (int i = first ; i <= last ; ++i) {
- Object o = specyListModel.getElementAt(i);
- if (isSelectedIndex(i)) {
- selectedObjects.add(o);
- System.out.println(((Specy)o).getName() + " as selected");
- }
- else {
- selectedObjects.remove(o);
- System.out.println(((Specy)o).getName() + " as unselected");
- }
- }
- }
- }
-
- public void fillSelection() {
- addSelectionInterval(0, specyListModel.getSize() - 1);
- }
-}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListTestModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListTestModel.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListTestModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,101 +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 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;
-
-/**
- * Test list model.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SpecyListTestModel extends AbstractListModel implements ListSelectionListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4769109927915812519L;
-
- protected List<String> species = new ArrayList<String>();
-
- public void setSpecy(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);
- }
-
- public int getIndexOf(Object o) {
- return species.indexOf(o);
- }
-
- /*
- * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
- */
- @Override
- public void valueChanged(ListSelectionEvent event) {
-
- // il le fait surrement deux fois, mais
- // sans ca, la mise à jour des 4 listes en meme tps ne fonctionne pas
-
- //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/SpecyTypesListModel.java (from rev 168, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/TypeSpecyListModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,91 @@
+/*
+ * #%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 Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.selection;
+
+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.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);
+ }
+}
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/TypeSpecyListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/TypeSpecyListModel.java 2010-11-10 12:36:59 UTC (rev 197)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/TypeSpecyListModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -1,82 +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 Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.ui.selection;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.services.ProjectService;
-
-/**
- * Affiche la liste des types d'especes définie dans le projet.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TypeSpecyListModel extends AbstractListModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 441910182067909029L;
-
- protected SelectionDetailsView view;
-
- protected List<String> types;
-
- public TypeSpecyListModel(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);
- }
-}
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java (from rev 86, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.selection;
+
+import java.util.List;
+
+import javax.swing.AbstractListModel;
+
+import fr.ifremer.coser.ui.util.CoserListModel;
+
+/**
+ * Model contenant la liste des noms de zone (utilisé dans le detail de selection).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ZoneListModel extends AbstractListModel implements CoserListModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8155676616312843132L;
+
+ protected List<String> zones;
+
+ public List<String> getZones() {
+ return zones;
+ }
+
+ public void setZones(List<String> zones) {
+ this.zones = zones;
+ fireContentsChanged(this, 0, zones.size());
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int size = 0;
+ if (zones != null) {
+ size = zones.size();
+ }
+ return size;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return zones.get(index);
+ }
+
+ /*
+ * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object)
+ */
+ @Override
+ public int indexOf(Object element) {
+ return zones.indexOf(element);
+ }
+}
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java (from rev 86, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionZoneListRenderer.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,56 @@
+/*
+ * #%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.DefaultListCellRenderer;
+import javax.swing.JList;
+
+/**
+ * Renderer de la liste des nom de zone.
+ * (pas forcement utile avec des String).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ZoneListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 4329272863520663978L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ String zone = (String)value;
+
+ return super.getListCellRendererComponent(list, zone, index, isSelected, cellHasFocus);
+ }
+}
Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java (from rev 174, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListTestModel.java)
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,112 @@
+/*
+ * #%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;
+
+/**
+ * Test list model.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SpecyListTestModel 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) {
+
+ // il le fait surrement deux fois, mais
+ // sans ca, la mise à jour des 4 listes en meme tps ne fonctionne pas
+
+ //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);
+ //}
+ }
+}
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,49 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.util;
+
+import javax.swing.ListModel;
+
+/**
+ * Interface que doivent implementer les modeles de List de coser.
+ * (à ne pas confondre avec les modeles de selection des List).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface CoserListModel extends ListModel {
+
+ /**
+ * Return index of element.
+ *
+ * @param element element to get index
+ * @return index of element
+ */
+ int indexOf(Object element);
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java 2010-11-10 12:58:40 UTC (rev 198)
@@ -0,0 +1,176 @@
+/*
+ * #%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.util;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import jaxx.runtime.swing.OneClicListSelectionModel;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Model de selection fonctionnant avec les intances des objects selectionnée
+ * et non par indices.
+ * Etend {@link OneClicListSelectionModel} pour sélectionner par simple clic.
+ *
+ * Implemente {@link ListSelectionListener} pour que la selection que la liste
+ * courante sauvegarde les instances des objets correspondants aux indices selectionnés.
+ *
+ * Implemente {@link ListDataListener} pour que la selection apres changement
+ * des données reste la même au niveau des objets (sinon, les indices
+ * ne correspondent pas au données précédent le changement.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class CoserListSelectionModel extends OneClicListSelectionModel implements ListDataListener, ListSelectionListener {
+
+ private static final Log log = LogFactory.getLog(CoserListSelectionModel.class);
+
+ /** Selection objects. */
+ protected Set<Object> selectedObjects;
+
+ /** List model. */
+ protected CoserListModel coserListModel;
+
+ /**
+ * Constuctor.
+ *
+ * @param delegate
+ * @param coserListModel
+ */
+ public CoserListSelectionModel(ListSelectionModel delegate, CoserListModel coserListModel) {
+ super(delegate, coserListModel);
+ this.coserListModel = coserListModel;
+ selectedObjects = new HashSet<Object>();
+
+ // pour que la selection que la liste courante
+ // sauvegarde les instances des objets correspondants
+ // aux indices selectionnés.
+ addListSelectionListener(this);
+ }
+
+ /**
+ * Replace selection.
+ *
+ * @param objects new selected objects
+ */
+ public void setSelectedObjects(Collection<?> objects) {
+ selectedObjects.clear();
+ if (objects != null) {
+ selectedObjects.addAll(objects);
+ }
+ contentsChanged(null);
+ }
+
+ /*
+ * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
+ */
+ @Override
+ public void intervalAdded(ListDataEvent e) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ /*
+ * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
+ */
+ @Override
+ public void intervalRemoved(ListDataEvent e) {
+ throw new NotImplementedException("Not yet implemented");
+ }
+
+ /*
+ * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
+ */
+ @Override
+ public void contentsChanged(ListDataEvent e) {
+ clearSelection();
+
+ setValueIsAdjusting(true);
+
+ Iterator<Object> itO = selectedObjects.iterator();
+ while (itO.hasNext()) {
+ Object o = itO.next();
+ int index = coserListModel.indexOf(o);
+
+ if (index >= 0) {
+ addSelectionInterval(index, index);
+ }
+
+ // a voir, mais si on le remove, avec les evenements multiples
+ // on pert toutes la selection
+ /*else {
+ itO.remove();
+ }*/
+ }
+
+ setValueIsAdjusting(false);
+ }
+
+ /*
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ */
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+
+ // ne fonctionne pas si c'est fait seulement quand
+ // IsAdjusting est a true.
+
+ if (!e.getValueIsAdjusting()) {
+ int first = e.getFirstIndex();
+ int last = e.getLastIndex();
+
+ for (int i = first ; i <= last ; ++i) {
+ Object o = coserListModel.getElementAt(i);
+ if (isSelectedIndex(i)) {
+ selectedObjects.add(o);
+ }
+ else {
+ selectedObjects.remove(o);
+ }
+ }
+ }
+ }
+
+ /**
+ * Fill selection.
+ */
+ public void fillSelection() {
+ addSelectionInterval(0, coserListModel.getSize() - 1);
+ }
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r197 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
by chatellier@users.labs.libre-entreprise.org 10 Nov '10
10 Nov '10
Author: chatellier
Date: 2010-11-10 12:36:59 +0000 (Wed, 10 Nov 2010)
New Revision: 197
Log:
Remove size (session restore bug with it)
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-09 15:35:01 UTC (rev 196)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-10 12:36:59 UTC (rev 197)
@@ -22,8 +22,8 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<JFrame title="coser.ui.mainview.title" width="780" height="540"
- layout="{new BorderLayout()}" name="mainFrame" onWindowClosing="getHandler().quit()">
+<JFrame title="coser.ui.mainview.title" layout="{new BorderLayout()}"
+ name="mainFrame" onWindowClosing="getHandler().quit()">
<CoserFrameHandler id="handler" javaBean="new CoserFrameHandler(this)" />
1
0
r196 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 09 Nov '10
by chatellier@users.labs.libre-entreprise.org 09 Nov '10
09 Nov '10
Author: chatellier
Date: 2010-11-09 15:35:01 +0000 (Tue, 09 Nov 2010)
New Revision: 196
Log:
Ajout du commentaire de la fusion
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/SpeciesFusionDialog.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-09 15:01:20 UTC (rev 195)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-09 15:35:01 UTC (rev 196)
@@ -199,8 +199,8 @@
speciesFusionDialog.setHandler(SelectionHandler.this);
// pre fill new speci name with first selected specy name
- Specy firstSelected = (Specy)view.getSpecyList().getSelectedValue();
- speciesFusionDialog.getNewSpeciesNameField().setText(firstSelected.getName());
+ String firstSelected = (String)view.getSpecyList().getSelectedValue();
+ speciesFusionDialog.getNewSpeciesNameField().setText(firstSelected);
speciesFusionDialog.setLocationRelativeTo(view);
speciesFusionDialog.setVisible(true);
@@ -284,9 +284,10 @@
public void performMergeSpecies(SpeciesFusionDialog view) {
// TODO echatellier 20101021 attention a ce que la selection
- // ne change pas (la fenetre est modales pour l'instant)
+ // ne change pas (la fenetre est modale pour l'instant)
String newSpecyName = view.getNewSpeciesNameField().getText();
+ String comment = view.getCommentField().getText();
Project project = view.getContextValue(Project.class);
Selection seletion = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -307,7 +308,7 @@
}
try {
- projectService.mergeSpecies(project, seletion, newSpecyName, specyNames);
+ projectService.mergeSpecies(project, seletion, newSpecyName, comment, specyNames);
}
catch (CoserBusinessException ex) {
throw new CoserException("Can't merge species", ex);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx 2010-11-09 15:01:20 UTC (rev 195)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx 2010-11-09 15:35:01 UTC (rev 196)
@@ -44,7 +44,7 @@
</cell>
<cell weightx="2" weighty="1" fill="both" columns="3">
<JScrollPane>
- <JXTextArea constructorParams='_("coser.ui.common.comment")' rows="3" />
+ <JXTextArea id="commentField" constructorParams='_("coser.ui.common.comment")' rows="3" />
</JScrollPane>
</cell>
</row>
1
0
r195 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 09 Nov '10
by chatellier@users.labs.libre-entreprise.org 09 Nov '10
09 Nov '10
Author: chatellier
Date: 2010-11-09 15:01:20 +0000 (Tue, 09 Nov 2010)
New Revision: 195
Log:
Fix NPE and display sampling effort matrix
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/SelectionHandler.java
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-09 14:45:50 UTC (rev 194)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-09 15:01:20 UTC (rev 195)
@@ -116,7 +116,7 @@
</cell>
<cell anchor="east">
<JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpreciesTip"
- onActionPerformed='getDetailDesisionPanelLayout().show(getDetailDesisionPanel(), "SPECIESDATA");' />
+ onActionPerformed='getDetailDesisionPanelLayout().show(getDetailDesisionPanel(), "SPECIESDATA");getHandler().showSamplingEffort(this);' />
</cell>
</row>
<row>
@@ -167,8 +167,7 @@
<JXImageView id="zonesMap" />
</JScrollPane>
<JScrollPane constraints='"SPECIESDATA"'>
- <JTable>
- </JTable>
+ <org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanelEditor" />
</JScrollPane>
</JPanel>
</cell>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-09 14:45:50 UTC (rev 194)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-09 15:01:20 UTC (rev 195)
@@ -39,6 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserException;
@@ -167,7 +168,7 @@
Integer endYear = (Integer)view.getSelectionDetailsEndYearField().getSelectedItem();
// il est possible que l'evenement fasse suite a une seule des selections
- if (beginYear != null && endYear != null) {
+ if (beginYear != null && endYear != null && zones != null) {
List<String> species = projectService.getProjectSpecies(project, selection, zones, beginYear, endYear, specyTypes);
view.getSpecyListModel().setSpecy(species);
}
@@ -315,4 +316,17 @@
view.dispose();
}
}
+
+ /**
+ *
+ */
+ public void showSamplingEffort(SelectionDetailsView view) {
+ Project project = view.getContextValue(Project.class);
+ Selection selection = view.getContextValue(Selection.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+ MatrixND samplingEffort = projectService.getSamplingEffort(project, selection);
+ view.getMatrixPanelEditor().setMatrix(samplingEffort);
+
+ //projectService.getOccurence(project, selection);
+ }
}
1
0