Tutti-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
February 2016
- 2 participants
- 182 discussions
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New change to branch feature/ajout_option_ne_pas_lire_unite in repository tutti.
See http://git.codelutin.com/tutti.git
at 00496c3 Permettre de ne pas lire les unités l'option est désactivée (See #7948)
This branch includes the following new commits:
new b740291 Ajout de l'option dans la configuration pour dicter ou non les unités (See #7948)
new 00496c3 Permettre de ne pas lire les unités l'option est désactivée (See #7948)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.
Detailed log of new commits:
commit 00496c336effa82c3e78146bcda80eb51110c46e
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Wed Feb 3 17:00:09 2016 +0100
Permettre de ne pas lire les unités l'option est désactivée (See #7948)
commit b74029132b289b1d9189aafba1e21b2f452745c0
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Wed Feb 3 16:59:18 2016 +0100
Ajout de l'option dans la configuration pour dicter ou non les unités (See #7948)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
2
This is an automated email from the git hooks/post-receive script.
New change to branch feature/7944-2 in repository tutti.
See http://git.codelutin.com/tutti.git
from 06c55a4 rtp.a en double au lieu de float pour la précision (refs #7944)
new aa0ac85 reset the row list when the editor is initialised (fixes #7944)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.
Detailed log of new commits:
commit aa0ac85435e5ff1bde279367529b5d9326d65e3f
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Feb 3 14:52:18 2016 +0100
reset the row list when the editor is initialised (fixes #7944)
Summary of changes:
.../fr/ifremer/tutti/ui/swing/content/protocol/rtp/RtpEditorUIModel.java | 1 +
1 file changed, 1 insertion(+)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
1
This is an automated email from the git hooks/post-receive script.
New change to branch feature/7944-2 in repository tutti.
See http://git.codelutin.com/tutti.git
at 06c55a4 rtp.a en double au lieu de float pour la précision (refs #7944)
This branch includes the following new commits:
new 06c55a4 rtp.a en double au lieu de float pour la précision (refs #7944)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.
Detailed log of new commits:
commit 06c55a4e0b8705113185eafd3c2b16fc8d6823f4
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Feb 3 14:37:12 2016 +0100
rtp.a en double au lieu de float pour la précision (refs #7944)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
1
This is an automated email from the git hooks/post-receive script.
New change to branch feature/6592-2 in repository tutti.
See http://git.codelutin.com/tutti.git
at 09eafe8 ajout du poids total melag importé et saisi dans le commentaire du lot (fixes #6592)
This branch includes the following new commits:
new 09eafe8 ajout du poids total melag importé et saisi dans le commentaire du lot (fixes #6592)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.
Detailed log of new commits:
commit 09eafe8fc2e3454f2f40485932def0693085b69f
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Feb 3 12:21:26 2016 +0100
ajout du poids total melag importé et saisi dans le commentaire du lot (fixes #6592)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
1
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New change to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
discards 32a93e0 desactivation des boutons d'ajout et de suppression des strates à l'ouverture de l'écran (refs #7929)
discards 2beea6e activation ou non des boutons d'ajout et de suppresion des strates (refs #7929)
discards 3be1d33 - utilisation directement du modele du protocol - ajout d'une popup de menu pour surrpimer et renommer les zones (refs #7929)
discards 6ca90c6 utilisation de fromEntity et toEntity au lieu de fromBean et toBean
discards b99cb29 tri des noeuds + i18n (refs #7929)
discards 38b5700 - ajout de la suppression de zone - probleme de rechargement de l'arbre quand on cache la racine - sélection de la zone créée (refs #7929)
discards 0f29ae8 on pousse les zones dans le modele de protocole (peut etre faire l'inverse...) (refs #7929)
discards 08c08a6 sauvegarde du protocol (refs #7929)
discards ede2fb2 ajout des icones + tri des noeuds dans les arbres (refs #7929)
discards 00cd88d suprpession des sous strates d'une zone (refs #7929)
discards c009f80 ajout des listeners sur les strates et sous strates (refs #7929)
discards 8f112f8 création des modeles de strates et sous strates (refs #7929)
discards f259b29 creation de zones + déplacement des noeuds (refs #7929)
discards 48ded36 noeuds + renderer + modeles d'arbre + modele de zone (refs #7929)
discards fc7dabe mise a jour suite aux modifs du modele + appel des oncloseui des sous-ui (refs #7929)
discards 9ae2970 ajout des strates et sous strates au modèle (refs #7929)
discards 267fd13 ajout de l'onglet d'édition des zone (refs #7929)
discards dedff13 ajout des zones au protocole (refs #7929)
discards 595843d use java 1.8
adds 320a3a0 Trim update url, because of haw theroy... (See #7946)
adds 3a73396 Merge branch 'feature/7946' into 'develop'
new be26619 use java 1.8
new cb089af ajout des zones au protocole (refs #7929)
new c175e1d ajout de l'onglet d'édition des zone (refs #7929)
new 553538e ajout des strates et sous strates au modèle (refs #7929)
new 7a82e95 mise a jour suite aux modifs du modele + appel des oncloseui des sous-ui (refs #7929)
new ee33a64 noeuds + renderer + modeles d'arbre + modele de zone (refs #7929)
new 0ff5002 creation de zones + déplacement des noeuds (refs #7929)
new ea86043 création des modeles de strates et sous strates (refs #7929)
new 3cbf075 ajout des listeners sur les strates et sous strates (refs #7929)
new 2f86084 suprpession des sous strates d'une zone (refs #7929)
new c1770b6 ajout des icones + tri des noeuds dans les arbres (refs #7929)
new 64396f9 sauvegarde du protocol (refs #7929)
new 48ee1cf on pousse les zones dans le modele de protocole (peut etre faire l'inverse...) (refs #7929)
new b5d8711 - ajout de la suppression de zone - probleme de rechargement de l'arbre quand on cache la racine - sélection de la zone créée (refs #7929)
new a437aed tri des noeuds + i18n (refs #7929)
new 098b663 utilisation de fromEntity et toEntity au lieu de fromBean et toBean
new e7fd65a - utilisation directement du modele du protocol - ajout d'une popup de menu pour surrpimer et renommer les zones (refs #7929)
new 119818a activation ou non des boutons d'ajout et de suppresion des strates (refs #7929)
new a96d18f desactivation des boutons d'ajout et de suppression des strates à l'ouverture de l'écran (refs #7929)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (32a93e0)
\
N -- N -- N refs/heads/feature/7929_editeur_de_zone (a96d18f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omits" are not gone; other references still
refer to them. Any revisions marked "discards" are gone forever.
The 19 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.
Detailed log of new commits:
commit a96d18ff71d6f71f8c3d23dabc8e929a619b4358
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Feb 3 11:05:50 2016 +0100
desactivation des boutons d'ajout et de suppression des strates à l'ouverture de l'écran (refs #7929)
commit 119818a13e446de273c79eed7116ab0410a910d5
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Feb 3 10:46:33 2016 +0100
activation ou non des boutons d'ajout et de suppresion des strates (refs #7929)
commit e7fd65aa77e3448775ccc6348b28452bdd0241cc
Author: Kevin Morin <morin(a)codelutin.com>
Date: Tue Feb 2 19:10:52 2016 +0100
- utilisation directement du modele du protocol
- ajout d'une popup de menu pour surrpimer et renommer les zones (refs #7929)
commit 098b663940cb314765a5be5a4469be2b2fa909cc
Author: Kevin Morin <morin(a)codelutin.com>
Date: Tue Feb 2 15:54:09 2016 +0100
utilisation de fromEntity et toEntity au lieu de fromBean et toBean
commit a437aed7070ad5b8370872afe22554cdee8d0e14
Author: Kevin Morin <morin(a)codelutin.com>
Date: Tue Feb 2 14:36:07 2016 +0100
tri des noeuds + i18n (refs #7929)
commit b5d8711c0fb79b98858ff7436b8ea0eea552d245
Author: Kevin Morin <morin(a)codelutin.com>
Date: Mon Feb 1 19:09:05 2016 +0100
- ajout de la suppression de zone
- probleme de rechargement de l'arbre quand on cache la racine
- sélection de la zone créée (refs #7929)
commit 48ee1cfebc5f8314475040567a55afe268f51928
Author: Kevin Morin <morin(a)codelutin.com>
Date: Fri Jan 29 17:35:38 2016 +0100
on pousse les zones dans le modele de protocole (peut etre faire l'inverse...) (refs #7929)
commit 64396f97ee982f248d402a765c74ca1440b30d26
Author: Kevin Morin <morin(a)codelutin.com>
Date: Fri Jan 29 17:12:06 2016 +0100
sauvegarde du protocol (refs #7929)
commit c1770b68bdadd49ee0c46a779aab22fd2d081d7b
Author: Kevin Morin <morin(a)codelutin.com>
Date: Fri Jan 29 14:49:39 2016 +0100
ajout des icones + tri des noeuds dans les arbres (refs #7929)
commit 2f86084d3917f753b6f2f3453228af6b1a88318d
Author: Kevin Morin <morin(a)codelutin.com>
Date: Fri Jan 29 11:34:43 2016 +0100
suprpession des sous strates d'une zone (refs #7929)
commit 3cbf075d1be41de84bd93df0f1031b40de2ec92a
Author: Kevin Morin <morin(a)codelutin.com>
Date: Thu Jan 28 19:22:03 2016 +0100
ajout des listeners sur les strates et sous strates (refs #7929)
commit ea86043f569ce4557f2cfff793e4e9ac1cb0230e
Author: Kevin Morin <morin(a)codelutin.com>
Date: Thu Jan 28 19:21:56 2016 +0100
création des modeles de strates et sous strates (refs #7929)
commit 0ff5002e3a03ae359d36f5bd04981d817e5c1990
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:39:17 2016 +0100
creation de zones + déplacement des noeuds (refs #7929)
commit ee33a6433136cb43cb42f46093c8d941cfd452a7
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:38:05 2016 +0100
noeuds + renderer + modeles d'arbre + modele de zone (refs #7929)
commit 7a82e9504cde295068df51bf9a1f4e81140fa957
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:37:01 2016 +0100
mise a jour suite aux modifs du modele + appel des oncloseui des sous-ui (refs #7929)
commit 553538eacb36c4da27722fc604c34b2c46a3a386
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:35:31 2016 +0100
ajout des strates et sous strates au modèle (refs #7929)
commit c175e1d3a00958464221bc56bea4fafb9db07348
Author: Kevin Morin <morin(a)codelutin.com>
Date: Mon Jan 25 11:23:25 2016 +0100
ajout de l'onglet d'édition des zone (refs #7929)
commit cb089af19dca490f53adc3d5d4790145df880e13
Author: Kevin Morin <morin(a)codelutin.com>
Date: Mon Jan 25 11:22:53 2016 +0100
ajout des zones au protocole (refs #7929)
commit be26619afdfe3a0a3baaac8ad850cbb257c30ae0
Author: Kevin Morin <morin(a)codelutin.com>
Date: Mon Jan 25 11:22:00 2016 +0100
use java 1.8
Summary of changes:
.../src/main/java/fr/ifremer/tutti/TuttiConfiguration.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
11
09/19: ajout des listeners sur les strates et sous strates (refs #7929)
by codelutin.com scm 03 Feb '16
by codelutin.com scm 03 Feb '16
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New commit to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
commit 3cbf075d1be41de84bd93df0f1031b40de2ec92a
Author: Kevin Morin <morin(a)codelutin.com>
Date: Thu Jan 28 19:22:03 2016 +0100
ajout des listeners sur les strates et sous strates (refs #7929)
---
.../swing/content/protocol/zones/ZoneEditorUI.jaxx | 1 +
.../protocol/zones/ZoneEditorUIHandler.java | 136 +++++++++++++----
.../content/protocol/zones/ZoneEditorUIModel.java | 165 ++++++++++++---------
.../protocol/zones/actions/AddStratasAction.java | 51 +++++--
.../protocol/zones/actions/CreateZoneAction.java | 10 +-
.../zones/actions/RemoveStratasAction.java | 58 +++++++-
.../resources/i18n/tutti-ui-swing_fr_FR.properties | 2 +-
7 files changed, 299 insertions(+), 124 deletions(-)
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
index 29fdd33..18129bb 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
@@ -3,6 +3,7 @@
implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<ZoneEditorUIModel, ZoneEditorUIHandler>'>
<import>
+ fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.ZoneEditorTreeCellRenderer
fr.ifremer.tutti.ui.swing.util.TuttiUI
fr.ifremer.tutti.ui.swing.util.TuttiUIUtil
</import>
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
index 31147ea..80a630c 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
@@ -3,13 +3,16 @@ package fr.ifremer.tutti.ui.swing.content.protocol.zones;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.protocol.Strata;
-import fr.ifremer.tutti.persistence.entities.protocol.Stratas;
import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
-import fr.ifremer.tutti.persistence.entities.protocol.SubStratas;
import fr.ifremer.tutti.persistence.entities.protocol.Zone;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocations;
import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.ZoneUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.StratasTreeModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.ZonesTreeModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
@@ -22,6 +25,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
@@ -38,16 +42,76 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
@Override
public void propertyChange(PropertyChangeEvent evt) {
+
ZoneUIModel zone = (ZoneUIModel) evt.getSource();
- Collection<Strata> stratas = (Collection<Strata>) evt.getNewValue();
- if (log.isInfoEnabled()) {
- log.info("stratas " + stratas);
- }
+ Collection<StrataUIModel> newStratas = (Collection<StrataUIModel>) evt.getNewValue();
+ Collection<StrataUIModel> oldStratas = (Collection<StrataUIModel>) evt.getOldValue();
+
+ Collection<StrataUIModel> stratasToAdd = new ArrayList<>(newStratas);
+ stratasToAdd.removeAll(oldStratas);
+
+ Collection<StrataUIModel> stratasToRemove = new ArrayList<>(oldStratas);
+ stratasToRemove.removeAll(newStratas);
+
+ stratasToRemove.forEach(strata -> strata.removePropertyChangeListener(StrataUIModel.PROPERTY_SUBSTRATA,
+ zoneSubStratasChangeListener));
+ stratasToAdd.forEach(strata -> strata.addPropertyChangeListener(StrataUIModel.PROPERTY_SUBSTRATA,
+ zoneSubStratasChangeListener));
+
+ ZonesTreeModel zonesTreeModel = (ZonesTreeModel) getUI().getZonesTree().getModel();
+ zonesTreeModel.updateStratas(zone, stratasToAdd, stratasToRemove);
+ zonesTreeModel.reload();
+ }
+ };
+
+ protected final PropertyChangeListener zoneSubStratasChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ StrataUIModel strata = (StrataUIModel) evt.getSource();
+
+ Collection<SubStrataUIModel> newSubStratas = (Collection<SubStrataUIModel>) evt.getNewValue();
+ Collection<SubStrataUIModel> oldSubStratas = (Collection<SubStrataUIModel>) evt.getOldValue();
+
+ Collection<SubStrataUIModel> subStratasToAdd = new ArrayList<>(newSubStratas);
+ subStratasToAdd.removeAll(oldSubStratas);
+
+ Collection<SubStrataUIModel> subStratasToRemove = new ArrayList<>(oldSubStratas);
+ subStratasToRemove.removeAll(newSubStratas);
ZonesTreeModel zonesTreeModel = (ZonesTreeModel) getUI().getZonesTree().getModel();
- zonesTreeModel.setStratas(zone, stratas);
+ zonesTreeModel.updateSubStratas(strata, subStratasToAdd, subStratasToRemove);
zonesTreeModel.reload();
+
+ }
+ };
+
+ protected final PropertyChangeListener availableSubStratasChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ StrataUIModel strata = (StrataUIModel) evt.getSource();
+
+ Collection<SubStrataUIModel> newSubStratas = (Collection<SubStrataUIModel>) evt.getNewValue();
+ Collection<SubStrataUIModel> oldSubStratas = (Collection<SubStrataUIModel>) evt.getOldValue();
+
+ Collection<SubStrataUIModel> subStratasToAdd = new ArrayList<>(newSubStratas);
+ subStratasToAdd.removeAll(oldSubStratas);
+
+ Collection<SubStrataUIModel> subStratasToRemove = new ArrayList<>(oldSubStratas);
+ subStratasToRemove.removeAll(newSubStratas);
+
+ if (log.isInfoEnabled()) {
+ log.info("substrata to remove : " + subStratasToRemove);
+ }
+
+ StratasTreeModel stratasTreeModel = (StratasTreeModel) getUI().getAvailableStratasTree().getModel();
+ stratasTreeModel.updateSubStratas(strata, subStratasToAdd, subStratasToRemove);
+ stratasTreeModel.reload();
+
}
};
@@ -72,23 +136,24 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
updateZonesTreeModel(zonesToAdd, zonesToRemove);
- zonesToRemove.forEach(zone -> zone.removePropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
- stratasChangeListener));
- zonesToAdd.forEach(zone -> zone.addPropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
- stratasChangeListener));
});
- getModel().addPropertyChangeListener(ZoneEditorUIModel.PROPERTY_AVAILABLE_STRATAS,
- evt -> {
+ getModel().addPropertyChangeListener(ZoneEditorUIModel.PROPERTY_AVAILABLE_STRATAS, evt -> {
- List<Strata> oldAvailableStratas = (List<Strata>) evt.getOldValue();
+ Collection<StrataUIModel> oldAvailableStratas = (Collection<StrataUIModel>) evt.getOldValue();
+ if (log.isInfoEnabled()) {
+ log.info("oldAvailableStratas " + oldAvailableStratas);
+ }
- List<Strata> newAvailableStratas = (List<Strata> ) evt.getNewValue();
+ Collection<StrataUIModel> newAvailableStratas = (Collection<StrataUIModel> ) evt.getNewValue();
+ if (log.isInfoEnabled()) {
+ log.info("newAvailableStratas " + newAvailableStratas);
+ }
- Collection<Strata> stratasToAdd = new ArrayList<>(newAvailableStratas);
+ Collection<StrataUIModel> stratasToAdd = new ArrayList<>(newAvailableStratas);
stratasToAdd.removeAll(oldAvailableStratas);
- Collection<Strata> stratasToRemove = new ArrayList<>(oldAvailableStratas);
+ Collection<StrataUIModel> stratasToRemove = new ArrayList<>(oldAvailableStratas);
stratasToRemove.removeAll(newAvailableStratas);
updateAvailableStratasTreeModel(stratasToAdd, stratasToRemove);
@@ -160,22 +225,19 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
programStratasAndSubstratas.remove(strataLocation, subStrataLocation));
});
- List<Strata> availableStratas = new ArrayList<>();
+ Collection<StrataUIModel> availableStratas = new ArrayList<>();
programStratasAndSubstratas.keySet().forEach(strataLocation -> {
- Strata strata = Stratas.newStrata();
- strata.setLocation(strataLocation);
+ StrataUIModel strata = new StrataUIModel(strataLocation);
- List<SubStrata> subStratas = programStratasAndSubstratas.get(strataLocation)
- .stream()
- .map(subStrataLocation -> {
- SubStrata subStrata = SubStratas.newSubStrata();
- subStrata.setLocation(subStrataLocation);
- return subStrata;
- })
- .collect(Collectors.toList());
+ Collection<TuttiLocation> subStrataLocations = new HashSet<>(programStratasAndSubstratas.get(strataLocation));
+ subStrataLocations.remove(null);
+ List<SubStrata> subStratas = subStrataLocations.stream()
+ .map(subStrataLocation -> new SubStrataUIModel(subStrataLocation))
+ .collect(Collectors.toList());
strata.setSubstrata(subStratas);
+ availableStratas.add(strata);
});
getModel().setAvailableStratas(availableStratas);
@@ -198,11 +260,16 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
zonesTreeModel.addZones(zonesToAdd);
+ zonesToRemove.forEach(zone -> zone.removePropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
+ stratasChangeListener));
+ zonesToAdd.forEach(zone -> zone.addPropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
+ stratasChangeListener));
+
zonesTreeModel.reload();
}
- protected void updateAvailableStratasTreeModel(Collection<Strata> stratasToAdd,
- Collection<Strata> stratasToRemove) {
+ protected void updateAvailableStratasTreeModel(Collection<StrataUIModel> stratasToAdd,
+ Collection<StrataUIModel> stratasToRemove) {
JTree availableStratasTree = getUI().getAvailableStratasTree();
StratasTreeModel availableStratasTreeModel = (StratasTreeModel) availableStratasTree.getModel();
@@ -211,6 +278,15 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
availableStratasTreeModel.addStratas(stratasToAdd);
+ if (log.isInfoEnabled()) {
+ log.info("add ppcl to " + stratasToAdd);
+ }
+
+ stratasToRemove.forEach(strata -> strata.removePropertyChangeListener(StrataUIModel.PROPERTY_SUBSTRATA,
+ availableSubStratasChangeListener));
+ stratasToAdd.forEach(strata -> strata.addPropertyChangeListener(StrataUIModel.PROPERTY_SUBSTRATA,
+ availableSubStratasChangeListener));
+
availableStratasTreeModel.reload();
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
index c212888..dc98b25 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
@@ -2,7 +2,9 @@ package fr.ifremer.tutti.ui.swing.content.protocol.zones;
import fr.ifremer.tutti.persistence.entities.protocol.Strata;
import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.ZoneUIModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
@@ -26,97 +28,60 @@ public class ZoneEditorUIModel extends AbstractSerializableBean {
public static final String PROPERTY_ZONES = "zones";
- protected Map<SubStrata, Strata> strataBySubstrata;
+ protected final Map<SubStrata, StrataUIModel> strataBySubstrata = new HashMap<>();
- protected final List<Strata> availableStratas = new ArrayList<>();
+ protected final List<StrataUIModel> availableStratas = new ArrayList<>();
protected final List<ZoneUIModel> zones = new ArrayList<>();
- public List<Strata> getAvailableStratas() {
+ public List<StrataUIModel> getAvailableStratas() {
return availableStratas;
}
- public void setAvailableStratas(List<Strata> availableStratas) {
+ public void setAvailableStratas(Collection<StrataUIModel> availableStratas) {
this.availableStratas.clear();
addAllAvailableStratas(availableStratas);
- strataBySubstrata = new HashMap<>();
- for (Strata strata : availableStratas) {
- for (SubStrata substrata : strata.getSubstrata()) {
- strataBySubstrata.put(substrata, strata);
- }
- }
+ strataBySubstrata.clear();
+ updateStrataBySubStrata(availableStratas);
}
- public void addAllAvailableStratas(List<Strata> availableStratas) {
+ public void addAllAvailableStratas(Collection<StrataUIModel> availableStratas) {
Object oldValue = copyAvailableStratas();
this.availableStratas.addAll(availableStratas);
- firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
- }
-
- public void addAvailableStratas(Collection<TuttiLocation> stratasAndSubStratas) {
-
-// Object oldValue = copyAvailableStratas();
-//
-// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
-// .filter(location -> strataBySubstrata.containsKey(location))
-// .collect(Collectors.toSet());
-//
-// Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
-// stratas.removeAll(substratas);
-//
-// stratas.forEach(strata -> {
-//
-// Collection<TuttiLocation> strataSubstratas =
-// strataBySubstrata.entrySet()
-// .stream()
-// .filter(entry->entry.getValue().equals(strata))
-// .map(Map.Entry::getKey)
-// .collect(Collectors.toSet());
-//
-// substratas.removeAll(strataSubstratas);
-// availableStratas.putAll(strata, strataSubstratas);
-//
-// });
-//
-// substratas.forEach(substrata -> {
-// availableStratas.put(strataBySubstrata.get(substrata), substrata);
-// });
-//
-// firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
+ updateStrataBySubStrata(availableStratas);
+ firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, getAvailableStratas());
}
- public void removeAvailableStratas(Collection<Strata> stratas) {
+ public void removeAvailableStratas(Collection<StrataUIModel> stratas) {
Object oldValue = copyAvailableStratas();
availableStratas.removeAll(stratas);
- firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
+ firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, getAvailableStratas());
}
- public void removeAvailableSubStratas(Collection<SubStrata> subStratas, Strata strata) {
-//
-// Object oldValue = copyAvailableStratas();
-//
-// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
-// .filter(location -> strataBySubstrata.containsKey(location))
-// .collect(Collectors.toSet());
-//
-// Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
-// stratas.removeAll(substratas);
-//
-// stratas.forEach(strata -> {
-// availableStratas.removeAll(strata);
-// });
-//
-// substratas.forEach(substrata -> {
-// availableStratas.remove(strataBySubstrata.get(substrata), substrata);
-// });
-//
-// firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
-//
+ public void removeAvailableSubStratas(Collection<SubStrataUIModel> subStratas) {
+ Object oldValue = copyAvailableStratas();
+
+ subStratas.forEach(subStrata -> {
+
+ StrataUIModel strata = strataBySubstrata.get(subStrata);
+ if (log.isInfoEnabled()) {
+ log.info("remove " + subStrata);
+ }
+ strata.removeSubstrata(subStrata);
+
+ if (strata.isSubstrataEmpty()) {
+ availableStratas.remove(strata);
+ }
+
+ });
+
+ firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, getAvailableStratas());
+
}
public List<ZoneUIModel> getZones() {
@@ -142,21 +107,73 @@ public class ZoneEditorUIModel extends AbstractSerializableBean {
firePropertyChange(PROPERTY_ZONES, oldValue, zones);
}
- public void moveStratasToZone(Collection<Strata> stratas, ZoneUIModel zone) {
+ public void moveStratasToZone(Collection<StrataUIModel> stratas, ZoneUIModel zone) {
+ if (log.isInfoEnabled()) {
+ log.info("stratas " + stratas);
+ }
+
+ zone.addAllStrata(new ArrayList<>(stratas));
removeAvailableStratas(stratas);
+ }
+ public void removeStratasFromZone(Collection<StrataUIModel> stratas) {
if (log.isInfoEnabled()) {
log.info("stratas " + stratas);
}
-// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
-// .filter(location -> strataBySubstrata.containsKey(location))
-// .collect(Collectors.toSet());
+ stratas.forEach(strata -> strata.getZone().removeStrata(strata));
+ addAllAvailableStratas(stratas);
+ }
+
+ public void moveSubStratasToZone(Collection<SubStrataUIModel> subStratas, ZoneUIModel zone) {
+ if (log.isInfoEnabled()) {
+ log.info("substrats " + subStratas);
+ }
+
+ subStratas.forEach(subStrata -> {
+ StrataUIModel strata = strataBySubstrata.get(subStrata);
+
+ Strata zoneStrata = zone.getStrata(strata);
+
+ if (zoneStrata == null) {
+ zoneStrata = new StrataUIModel(strata.getLocation());
+ zone.addStrata(zoneStrata);
+ }
+
+ zoneStrata.addSubstrata(subStrata);
+
+ });
+
+ removeAvailableSubStratas(subStratas);
+
+ }
+
+ public void removeSubStratasFromZone(Collection<SubStrataUIModel> subStratas) {
+ if (log.isInfoEnabled()) {
+ log.info("subStratas " + subStratas);
+ }
+
+ subStratas.forEach(subStrata -> {
+ StrataUIModel strata = strataBySubstrata.get(subStrata);
+
+ //TODO remove substrata from zone
+// StrataUIModel zoneStrata =
+// strata.removeSubstrata(subStrata);
+// strata.getZone().removeStrata(strata)
- zone.addAllStrata(stratas);
+ strata.addSubstrata(subStrata);
+ });
}
- protected List<Strata> copyAvailableStratas() {
+ protected List<StrataUIModel> copyAvailableStratas() {
return new ArrayList<>(availableStratas);
}
+
+ protected void updateStrataBySubStrata(Collection<StrataUIModel> availableStratas) {
+ for (StrataUIModel strata : availableStratas) {
+ for (SubStrata substrata : strata.getSubstrata()) {
+ strataBySubstrata.put(substrata, strata);
+ }
+ }
+ }
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
index 1392528..b7930e7 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
@@ -1,18 +1,23 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones.actions;
-import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneEditorUI;
-import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel;
-import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.ZoneNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.ZoneUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.StrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.SubStrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.ZoneNode;
import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author Kevin Morin (Code Lutin)
@@ -38,20 +43,40 @@ public class AddStratasAction extends SimpleActionSupport<ZoneEditorUI> {
ZoneNode zoneNode = (ZoneNode) selectedZonePath.getLastPathComponent();
ZoneUIModel selectedZone = zoneNode.getZone();
- Set<Strata> locationsToAdd = new HashSet<>();
+ Set<StrataUIModel> stratasToAdd = new HashSet<>();
+ Set<SubStrataUIModel> subStratasToAdd = new HashSet<>();
for (TreePath treePath : selectedStratas) {
-//FIXME
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
- Strata location = (Strata) node.getUserObject();
-// if (log.isInfoEnabled()) {
-// log.info("add location " + location.getLabel());
-// }
- locationsToAdd.add(location);
+
+ Object node = treePath.getLastPathComponent();
+
+ if (node instanceof StrataNode) {
+
+ StrataUIModel strata = ((StrataNode) node).getStrata();
+ if (log.isInfoEnabled()) {
+ log.info("add strata " + strata.getLabel());
+ }
+ stratasToAdd.add(strata);
+
+ } else if (node instanceof SubStrataNode) {
+ SubStrataUIModel subStrata = ((SubStrataNode) node).getSubstrata();
+ if (log.isInfoEnabled()) {
+ log.info("add subtrata " + subStrata.getLabel());
+ }
+ subStratasToAdd.add(subStrata);
+ }
}
- zoneEditorUI.getModel().moveStratasToZone(locationsToAdd, selectedZone);
+ Collection<SubStrata> alreadyAddedSubStratas = stratasToAdd.stream()
+ .map(strata->strata.getSubstrata())
+ .flatMap(c -> c.stream())
+ .collect(Collectors.toSet());
+
+ subStratasToAdd.removeAll(alreadyAddedSubStratas);
+
+ zoneEditorUI.getModel().moveStratasToZone(stratasToAdd, selectedZone);
+ zoneEditorUI.getModel().moveSubStratasToZone(subStratasToAdd, selectedZone);
}
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java
index af2c00b..9be290a 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java
@@ -1,7 +1,7 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones.actions;
import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneEditorUI;
-import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.ZoneUIModel;
import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport;
import javax.swing.JOptionPane;
@@ -23,8 +23,10 @@ public class CreateZoneAction extends SimpleActionSupport<ZoneEditorUI> {
String zoneLabel = JOptionPane.showInputDialog(t("tutti.zoneEditor.createZone.message"));
- ZoneUIModel zone = new ZoneUIModel();
- zone.setLabel(zoneLabel);
- zoneEditorUI.getModel().addZone(zone);
+ if (zoneLabel != null) {
+ ZoneUIModel zone = new ZoneUIModel();
+ zone.setLabel(zoneLabel);
+ zoneEditorUI.getModel().addZone(zone);
+ }
}
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
index 041c64b..582d278 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
@@ -1,9 +1,21 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones.actions;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneEditorUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.StrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.SubStrataNode;
import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
-import javax.swing.tree.DefaultTreeModel;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author Kevin Morin (Code Lutin)
@@ -11,12 +23,54 @@ import javax.swing.tree.DefaultTreeModel;
*/
public class RemoveStratasAction extends SimpleActionSupport<ZoneEditorUI> {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(RemoveStratasAction.class);
+
public RemoveStratasAction(ZoneEditorUI zoneEditorUI) {
super(zoneEditorUI);
}
@Override
protected void onActionPerformed(ZoneEditorUI zoneEditorUI) {
- ((DefaultTreeModel) zoneEditorUI.getAvailableStratasTree().getModel()).reload();
+
+ JTree availableStratasTree = zoneEditorUI.getAvailableStratasTree();
+
+ JTree zonesTree = zoneEditorUI.getZonesTree();
+ TreePath[] selectedStratas = zonesTree.getSelectionPaths();
+
+ Set<StrataUIModel> stratasToRemove = new HashSet<>();
+ Set<SubStrataUIModel> subStratasToRemove = new HashSet<>();
+
+ for (TreePath treePath : selectedStratas) {
+
+ Object node = treePath.getLastPathComponent();
+
+ if (node instanceof StrataNode) {
+
+ StrataUIModel strata = ((StrataNode) node).getStrata();
+ if (log.isInfoEnabled()) {
+ log.info("add strata " + strata.getLabel());
+ }
+ stratasToRemove.add(strata);
+
+ } else if (node instanceof SubStrataNode) {
+ SubStrataUIModel subStrata = ((SubStrataNode) node).getSubstrata();
+ if (log.isInfoEnabled()) {
+ log.info("add subtrata " + subStrata.getLabel());
+ }
+ subStratasToRemove.add(subStrata);
+ }
+
+ }
+
+ Collection<SubStrata> alreadyRemovedSubStratas = stratasToRemove.stream()
+ .map(strata->strata.getSubstrata())
+ .flatMap(c -> c.stream())
+ .collect(Collectors.toSet());
+
+ subStratasToRemove.removeAll(alreadyRemovedSubStratas);
+
+ zoneEditorUI.getModel().removeStratasFromZone(stratasToRemove);
+ zoneEditorUI.getModel().removeSubStratasFromZone(subStratasToRemove);
}
}
diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
index 7e8bc0e..91180c9 100644
--- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
+++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
@@ -2174,4 +2174,4 @@ tutti.vesselUseFeatureTable.action.removeCaracteristic.tip=Supprimer la caracté
tutti.vesselUseFeatureTable.table.header.key=Caractéristique
tutti.vesselUseFeatureTable.table.header.value=Valeur
tutti.vesselUseFeatureTable.title=Autres paramètres
-tutti.zoneEditor.createZone.message=
+tutti.zoneEditor.createZone.message=Libellé de la nouvelle zone
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New commit to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
commit 0ff5002e3a03ae359d36f5bd04981d817e5c1990
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:39:17 2016 +0100
creation de zones + déplacement des noeuds (refs #7929)
---
.../swing/content/protocol/zones/ZoneEditorUI.jaxx | 22 +-
.../swing/content/protocol/zones/ZoneEditorUI.jcss | 8 +
.../protocol/zones/ZoneEditorUIHandler.java | 238 +++++++++++++--------
.../content/protocol/zones/ZoneEditorUIModel.java | 157 ++++++++------
.../protocol/zones/actions/AddStratasAction.java | 29 ++-
.../protocol/zones/actions/CreateZoneAction.java | 30 +++
.../zones/actions/RemoveStratasAction.java | 2 +-
.../resources/i18n/tutti-ui-swing_en_GB.properties | 1 +
.../resources/i18n/tutti-ui-swing_fr_FR.properties | 1 +
9 files changed, 323 insertions(+), 165 deletions(-)
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
index ae21d09..29fdd33 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jaxx
@@ -19,10 +19,24 @@
<ZoneEditorUIModel id='model' javaBean='new ZoneEditorUIModel()'/>
<row>
+ <cell>
+ <JToolBar id="zonesTreeToolBar">
+ <JButton id="createZone"/>
+ </JToolBar>
+ </cell>
+ <cell>
+ <JLabel/>
+ </cell>
+ <cell>
+ <JToolBar id="availableStratasTreeToolBar">
+ </JToolBar>
+ </cell>
+ </row>
+ <row>
<cell weightx='0.5' weighty='1' fill='both'>
- <JScrollPane onFocusGained='zoneTree.requestFocus()'>
+ <JScrollPane onFocusGained='zonesTree.requestFocus()'>
<!-- List of the zones -->
- <JTree id='zoneTree'/>
+ <JTree id='zonesTree'/>
<!--onFocusGained='handler.selectFirstRowIfNoSelection(event)'-->
<!--onMouseClicked='handler.onUniverseListClicked(event)'-->
<!--onKeyPressed='handler.onKeyPressedOnUniverseList(event)'-->
@@ -37,9 +51,9 @@
</cell>
<cell weightx='0.5' weighty='1' fill='both'>
- <JScrollPane onFocusGained='availableStratas.requestFocus()'>
+ <JScrollPane onFocusGained='availableStratasTree.requestFocus()'>
<!-- List of the available stratas and substratas -->
- <JTree id='availableStratas' onValueChanged="availableStratas.expandPath(event.getNewLeadSelectionPath())"/>
+ <JTree id='availableStratasTree' onValueChanged="availableStratasTree.expandPath(event.getNewLeadSelectionPath())"/>
<!--onFocusGained='handler.selectFirstRowIfNoSelection(event)'-->
<!--onMouseClicked='handler.onSelectedListClicked(event)'-->
<!--onKeyPressed='handler.onKeyPressedOnSelectedList(event)'/>-->
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jcss b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jcss
index f6b30e7..8c336fa 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jcss
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUI.jcss
@@ -4,14 +4,22 @@ JTree {
scrollsOnExpand: true;
rootVisible: false;
showsRootHandles: false;
+ cellRenderer: {new ZoneEditorTreeCellRenderer()};
+}
+
+#createZone {
+ actionIcon: add;
+ _simpleAction: {fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.CreateZoneAction.class};
}
#addButton {
text: "<<";
+ enabled: {zonesTree.getSelectionCount() == 1};
_simpleAction: {fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.AddStratasAction.class};
}
#removeButton {
text: ">>";
+ enabled: {zonesTree.getSelectionCount() >= 1};
_simpleAction: {fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.RemoveStratasAction.class};
}
\ No newline at end of file
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
index f46342a..31147ea 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIHandler.java
@@ -1,7 +1,14 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones;
+import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.Stratas;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStratas;
+import fr.ifremer.tutti.persistence.entities.protocol.Zone;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocations;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -10,15 +17,13 @@ import org.apache.commons.logging.LogFactory;
import javax.swing.JComponent;
import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
-import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* @author Kevin Morin (Code Lutin)
@@ -29,127 +34,184 @@ public class ZoneEditorUIHandler extends AbstractTuttiUIHandler<ZoneEditorUIMode
/** Logger. */
private static final Log log = LogFactory.getLog(ZoneEditorUIHandler.class);
+ protected final PropertyChangeListener stratasChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ ZoneUIModel zone = (ZoneUIModel) evt.getSource();
+ Collection<Strata> stratas = (Collection<Strata>) evt.getNewValue();
+
+ if (log.isInfoEnabled()) {
+ log.info("stratas " + stratas);
+ }
+
+ ZonesTreeModel zonesTreeModel = (ZonesTreeModel) getUI().getZonesTree().getModel();
+ zonesTreeModel.setStratas(zone, stratas);
+ zonesTreeModel.reload();
+ }
+ };
+
@Override
public void afterInit(ZoneEditorUI zoneEditorUI) {
initUI(zoneEditorUI);
- getModel().addPropertyChangeListener(ZoneEditorUIModel.PROPERTY_AVAILABLE_STRATAS,
+ // init models
+
+ getModel().addPropertyChangeListener(ZoneEditorUIModel.PROPERTY_ZONES,
evt -> {
- Multimap<TuttiLocation, TuttiLocation> oldAvailableStratas =
- (Multimap<TuttiLocation, TuttiLocation>) evt.getOldValue();
+ List<ZoneUIModel> newZones = (List<ZoneUIModel>) evt.getNewValue();
+ List<ZoneUIModel> oldZones = (List<ZoneUIModel>) evt.getOldValue();
- Multimap<TuttiLocation, TuttiLocation> newAvailableStratas =
- (Multimap<TuttiLocation, TuttiLocation>) evt.getNewValue();
+ Collection<ZoneUIModel> zonesToAdd = new ArrayList<>(newZones);
+ zonesToAdd.removeAll(oldZones);
- Collection<TuttiLocation> stratasToAdd = new ArrayList<>(newAvailableStratas.keySet());
- stratasToAdd.removeAll(oldAvailableStratas.keySet());
+ Collection<ZoneUIModel> zonesToRemove = new ArrayList<>(oldZones);
+ zonesToRemove.removeAll(newZones);
- Collection<TuttiLocation> stratasToRemove = new ArrayList<>(oldAvailableStratas.keySet());
- stratasToRemove.removeAll(newAvailableStratas.keySet());
+ updateZonesTreeModel(zonesToAdd, zonesToRemove);
- updateTreeModel(newAvailableStratas, oldAvailableStratas, stratasToAdd, stratasToRemove);
+ zonesToRemove.forEach(zone -> zone.removePropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
+ stratasChangeListener));
+ zonesToAdd.forEach(zone -> zone.addPropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
+ stratasChangeListener));
});
- DefaultMutableTreeNode root = new DefaultMutableTreeNode();
-
- TreeModel availableStratasTreeModel = new DefaultTreeModel(root);
-
- JTree availableStratasTree = ui.getAvailableStratas();
- availableStratasTree.setCellRenderer(new DefaultTreeCellRenderer() {
-
- @Override
- public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
- super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
- String text = "test";
- if (value instanceof DefaultMutableTreeNode) {
- Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
- if (userObject instanceof TuttiLocation) {
- text = ((TuttiLocation) userObject).getLabel();
- }
- }
- setText(text);
- return this;
- }
+ getModel().addPropertyChangeListener(ZoneEditorUIModel.PROPERTY_AVAILABLE_STRATAS,
+ evt -> {
+
+ List<Strata> oldAvailableStratas = (List<Strata>) evt.getOldValue();
+
+ List<Strata> newAvailableStratas = (List<Strata> ) evt.getNewValue();
+
+ Collection<Strata> stratasToAdd = new ArrayList<>(newAvailableStratas);
+ stratasToAdd.removeAll(oldAvailableStratas);
+
+ Collection<Strata> stratasToRemove = new ArrayList<>(oldAvailableStratas);
+ stratasToRemove.removeAll(newAvailableStratas);
+
+ updateAvailableStratasTreeModel(stratasToAdd, stratasToRemove);
});
+
+ // init trees
+
+ TreeModel availableStratasTreeModel = new StratasTreeModel();
+ JTree availableStratasTree = ui.getAvailableStratasTree();
availableStratasTree.setModel(availableStratasTreeModel);
- PersistenceService persistenceService = getPersistenceService();
+ TreeModel zonesTreeModel = new ZonesTreeModel();
+ JTree zonesTree = ui.getZonesTree();
+ zonesTree.setModel(zonesTreeModel);
- TuttiLocation programZone = getDataContext().getProgram().getZone();
+ // get data
- Multimap<TuttiLocation, TuttiLocation> programStratasAndSubstratas =
- persistenceService.getAllFishingOperationStratasAndSubstratas(programZone.getId());
+ initModel();
+ }
- getModel().setAvailableStratas(programStratasAndSubstratas);
+ @Override
+ public SwingValidator<ZoneEditorUIModel> getValidator() {
+ return null;
}
- protected void updateTreeModel(Multimap<TuttiLocation, TuttiLocation> newAvailableStratas,
- Multimap<TuttiLocation, TuttiLocation> oldAvailableStratas,
- Collection<TuttiLocation> stratasToAdd,
- Collection<TuttiLocation> stratasToRemove) {
+ @Override
+ protected JComponent getComponentToFocus() {
+ return ui.getZonesTree();
+ }
- if (log.isInfoEnabled()) {
- log.info("updateTrremodle");
- }
+ @Override
+ public void onCloseUI() {
+ getModel().getZones().forEach(zone -> zone.removePropertyChangeListener(ZoneUIModel.PROPERTY_STRATA,
+ stratasChangeListener));
+ }
- JTree availableStratas = getUI().getAvailableStratas();
- DefaultTreeModel availableStratasTreeModel = (DefaultTreeModel) availableStratas.getModel();
- DefaultMutableTreeNode root = (DefaultMutableTreeNode) availableStratasTreeModel.getRoot();
+ protected void initModel() {
+ PersistenceService persistenceService = getPersistenceService();
- Enumeration rootChildren = root.children();
- Collection<DefaultMutableTreeNode> nodesToRemove = new HashSet<>();
- while (rootChildren.hasMoreElements()) {
- DefaultMutableTreeNode strataNode = (DefaultMutableTreeNode) rootChildren.nextElement();
- if (log.isInfoEnabled()) {
- log.info("root child " + ((TuttiLocation) strataNode.getUserObject()).getLabel());
- }
- if (stratasToRemove.contains(strataNode.getUserObject())) {
- if (log.isInfoEnabled()) {
- log.info("remove " + ((TuttiLocation) strataNode.getUserObject()).getLabel());
- }
- nodesToRemove.add(strataNode);
- }
+ TuttiLocation programZone = getDataContext().getProgram().getZone();
+
+ Multimap<TuttiLocation, TuttiLocation> programStratasAndSubstratas =
+ HashMultimap.create(persistenceService.getAllFishingOperationStratasAndSubstratas(programZone.getId()));
+ //FIXME only for tests
+ TuttiLocation test = programStratasAndSubstratas.keySet().iterator().next();
+ for (int i = 0 ; i < 5 ; i++) {
+ TuttiLocation location = TuttiLocations.newTuttiLocation();
+ location.setId(i);
+ location.setLabel("substrata" + i);
+ programStratasAndSubstratas.put(test, location);
}
- nodesToRemove.forEach(strataNode -> root.remove(strataNode));
- stratasToAdd.forEach(strata -> {
+ Collection<Zone> zones = getDataContext().getProtocol().getZone();
+ Collection<Strata> protocolStratas = zones.stream()
+ .map(zone -> zone.getStrata())
+ .flatMap(stratas -> stratas.stream())
+ .collect(Collectors.toSet());
- DefaultMutableTreeNode strataNode = new DefaultMutableTreeNode(strata, true);
- root.add(strataNode);
+ protocolStratas.forEach(strata -> {
- if (log.isInfoEnabled()) {
- log.info("add strata node " + strata.getLabel());
- }
+ TuttiLocation strataLocation = strata.getLocation();
+
+ Collection<TuttiLocation> subStrataLocations = strata.getSubstrata()
+ .stream()
+ .map(subStrata -> subStrata.getLocation())
+ .collect(Collectors.toSet());
- newAvailableStratas.get(strata).forEach(substrata -> {
+ subStrataLocations.forEach(subStrataLocation ->
+ programStratasAndSubstratas.remove(strataLocation, subStrataLocation));
+ });
+
+ List<Strata> availableStratas = new ArrayList<>();
+ programStratasAndSubstratas.keySet().forEach(strataLocation -> {
- if (substrata != null) {
- DefaultMutableTreeNode subStrataNode = new DefaultMutableTreeNode(substrata, false);
- strataNode.add(subStrataNode);
- log.info("add substrata node " + substrata.getLabel());
- }
+ Strata strata = Stratas.newStrata();
+ strata.setLocation(strataLocation);
- });
+ List<SubStrata> subStratas = programStratasAndSubstratas.get(strataLocation)
+ .stream()
+ .map(subStrataLocation -> {
+ SubStrata subStrata = SubStratas.newSubStrata();
+ subStrata.setLocation(subStrataLocation);
+ return subStrata;
+ })
+ .collect(Collectors.toList());
+ strata.setSubstrata(subStratas);
});
- availableStratasTreeModel.reload();
- }
+ getModel().setAvailableStratas(availableStratas);
- @Override
- public SwingValidator<ZoneEditorUIModel> getValidator() {
- return null;
+ List<ZoneUIModel> zoneModels = zones.stream()
+ .map(zone -> {
+ ZoneUIModel zoneUIModel = new ZoneUIModel();
+ zoneUIModel.fromEntity(zone);
+ return zoneUIModel;
+ })
+ .collect(Collectors.toList());
+ getModel().setZones(zoneModels);
}
- @Override
- protected JComponent getComponentToFocus() {
- return ui.getZoneTree();
+ protected void updateZonesTreeModel(Collection<ZoneUIModel> zonesToAdd, Collection<ZoneUIModel> zonesToRemove) {
+ JTree zonesTree = getUI().getZonesTree();
+ ZonesTreeModel zonesTreeModel = (ZonesTreeModel) zonesTree.getModel();
+
+ zonesTreeModel.removeZones(zonesToRemove);
+
+ zonesTreeModel.addZones(zonesToAdd);
+
+ zonesTreeModel.reload();
}
- @Override
- public void onCloseUI() {
+ protected void updateAvailableStratasTreeModel(Collection<Strata> stratasToAdd,
+ Collection<Strata> stratasToRemove) {
+
+ JTree availableStratasTree = getUI().getAvailableStratasTree();
+ StratasTreeModel availableStratasTreeModel = (StratasTreeModel) availableStratasTree.getModel();
+
+ availableStratasTreeModel.removeStratas(stratasToRemove);
+ availableStratasTreeModel.addStratas(stratasToAdd);
+
+ availableStratasTreeModel.reload();
}
+
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
index 9645011..c212888 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorUIModel.java
@@ -1,8 +1,7 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.entities.protocol.Zone;
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -11,10 +10,8 @@ import org.jdesktop.beans.AbstractSerializableBean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
/**
* @author Kevin Morin (Code Lutin)
@@ -29,101 +26,137 @@ public class ZoneEditorUIModel extends AbstractSerializableBean {
public static final String PROPERTY_ZONES = "zones";
- protected Map<TuttiLocation, TuttiLocation> strataBySubstrata;
+ protected Map<SubStrata, Strata> strataBySubstrata;
- protected final Multimap<TuttiLocation, TuttiLocation> availableStratas = HashMultimap.create();
+ protected final List<Strata> availableStratas = new ArrayList<>();
- protected final List<Zone> zones = new ArrayList<>();
+ protected final List<ZoneUIModel> zones = new ArrayList<>();
- public Multimap<TuttiLocation, TuttiLocation> getAvailableStratas() {
+ public List<Strata> getAvailableStratas() {
return availableStratas;
}
- public void setAvailableStratas(Multimap<TuttiLocation, TuttiLocation> availableStratas) {
+ public void setAvailableStratas(List<Strata> availableStratas) {
this.availableStratas.clear();
addAllAvailableStratas(availableStratas);
strataBySubstrata = new HashMap<>();
- for (TuttiLocation stratas : availableStratas.keySet()) {
- for (TuttiLocation substratas : availableStratas.get(stratas)) {
- strataBySubstrata.put(substratas, stratas);
+ for (Strata strata : availableStratas) {
+ for (SubStrata substrata : strata.getSubstrata()) {
+ strataBySubstrata.put(substrata, strata);
}
}
}
- public void addAllAvailableStratas(Multimap<TuttiLocation, TuttiLocation> availableStratas) {
+ public void addAllAvailableStratas(List<Strata> availableStratas) {
Object oldValue = copyAvailableStratas();
- this.availableStratas.putAll(availableStratas);
+ this.availableStratas.addAll(availableStratas);
firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
}
public void addAvailableStratas(Collection<TuttiLocation> stratasAndSubStratas) {
- Object oldValue = copyAvailableStratas();
-
- Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
- .filter(location -> strataBySubstrata.containsKey(location))
- .collect(Collectors.toSet());
-
- Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
- stratas.removeAll(substratas);
-
- stratas.forEach(strata -> {
-
- Collection<TuttiLocation> strataSubstratas =
- strataBySubstrata.entrySet()
- .stream()
- .filter(entry->entry.getValue().equals(strata))
- .map(Map.Entry::getKey)
- .collect(Collectors.toSet());
-
- substratas.removeAll(strataSubstratas);
- availableStratas.putAll(strata, strataSubstratas);
-
- });
-
- substratas.forEach(substrata -> {
- availableStratas.put(strataBySubstrata.get(substrata), substrata);
- });
-
- firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
+// Object oldValue = copyAvailableStratas();
+//
+// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
+// .filter(location -> strataBySubstrata.containsKey(location))
+// .collect(Collectors.toSet());
+//
+// Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
+// stratas.removeAll(substratas);
+//
+// stratas.forEach(strata -> {
+//
+// Collection<TuttiLocation> strataSubstratas =
+// strataBySubstrata.entrySet()
+// .stream()
+// .filter(entry->entry.getValue().equals(strata))
+// .map(Map.Entry::getKey)
+// .collect(Collectors.toSet());
+//
+// substratas.removeAll(strataSubstratas);
+// availableStratas.putAll(strata, strataSubstratas);
+//
+// });
+//
+// substratas.forEach(substrata -> {
+// availableStratas.put(strataBySubstrata.get(substrata), substrata);
+// });
+//
+// firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
}
- public void removeAvailableStratas(Collection<TuttiLocation> stratasAndSubStratas) {
+ public void removeAvailableStratas(Collection<Strata> stratas) {
Object oldValue = copyAvailableStratas();
- Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
- .filter(location -> strataBySubstrata.containsKey(location))
- .collect(Collectors.toSet());
-
- Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
- stratas.removeAll(substratas);
-
- stratas.forEach(strata -> {
- availableStratas.removeAll(strata);
- });
-
- substratas.forEach(substrata -> {
- availableStratas.remove(strataBySubstrata.get(substrata), substrata);
- });
+ availableStratas.removeAll(stratas);
firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
}
- public List<Zone> getZones() {
+ public void removeAvailableSubStratas(Collection<SubStrata> subStratas, Strata strata) {
+//
+// Object oldValue = copyAvailableStratas();
+//
+// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
+// .filter(location -> strataBySubstrata.containsKey(location))
+// .collect(Collectors.toSet());
+//
+// Collection<TuttiLocation> stratas = new HashSet<>(stratasAndSubStratas);
+// stratas.removeAll(substratas);
+//
+// stratas.forEach(strata -> {
+// availableStratas.removeAll(strata);
+// });
+//
+// substratas.forEach(substrata -> {
+// availableStratas.remove(strataBySubstrata.get(substrata), substrata);
+// });
+//
+// firePropertyChange(PROPERTY_AVAILABLE_STRATAS, oldValue, availableStratas);
+//
+ }
+
+ public List<ZoneUIModel> getZones() {
return zones;
}
- public void setZones(List<Zone> zones) {
+ public void setZones(List<ZoneUIModel> zones) {
Object oldValue = getZones();
this.zones.clear();
this.zones.addAll(zones);
firePropertyChange(PROPERTY_ZONES, oldValue, zones);
}
- protected Multimap<TuttiLocation, TuttiLocation> copyAvailableStratas() {
- return HashMultimap.create(availableStratas);
+ public void addZone(ZoneUIModel zone) {
+ Object oldValue = new ArrayList<>(getZones());
+ zones.add(zone);
+ firePropertyChange(PROPERTY_ZONES, oldValue, zones);
+ }
+
+ public void removeZone(ZoneUIModel zone) {
+ Object oldValue = new ArrayList<>(getZones());
+ zones.remove(zone);
+ firePropertyChange(PROPERTY_ZONES, oldValue, zones);
+ }
+
+ public void moveStratasToZone(Collection<Strata> stratas, ZoneUIModel zone) {
+ removeAvailableStratas(stratas);
+
+ if (log.isInfoEnabled()) {
+ log.info("stratas " + stratas);
+ }
+
+// Collection<TuttiLocation> substratas = stratasAndSubStratas.stream()
+// .filter(location -> strataBySubstrata.containsKey(location))
+// .collect(Collectors.toSet());
+
+ zone.addAllStrata(stratas);
+ }
+
+ protected List<Strata> copyAvailableStratas() {
+ return new ArrayList<>(availableStratas);
}
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
index 75ddcb5..1392528 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/AddStratasAction.java
@@ -1,7 +1,9 @@
package fr.ifremer.tutti.ui.swing.content.protocol.zones.actions;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneEditorUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.ZoneNode;
import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -28,21 +30,28 @@ public class AddStratasAction extends SimpleActionSupport<ZoneEditorUI> {
@Override
protected void onActionPerformed(ZoneEditorUI zoneEditorUI) {
- JTree availableStratasTree = zoneEditorUI.getAvailableStratas();
- TreePath[] selectionPaths = availableStratasTree.getSelectionPaths();
+ JTree availableStratasTree = zoneEditorUI.getAvailableStratasTree();
+ TreePath[] selectedStratas = availableStratasTree.getSelectionPaths();
- Set<TuttiLocation> locationsToAdd = new HashSet<>();
+ JTree zonesTree = zoneEditorUI.getZonesTree();
+ TreePath selectedZonePath = zonesTree.getSelectionPath();
+ ZoneNode zoneNode = (ZoneNode) selectedZonePath.getLastPathComponent();
+ ZoneUIModel selectedZone = zoneNode.getZone();
- for (TreePath treePath : selectionPaths) {
+ Set<Strata> locationsToAdd = new HashSet<>();
+
+ for (TreePath treePath : selectedStratas) {
+//FIXME
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
- TuttiLocation location = (TuttiLocation) node.getUserObject();
- if (log.isInfoEnabled()) {
- log.info("add location " + location.getLabel());
- }
+ Strata location = (Strata) node.getUserObject();
+// if (log.isInfoEnabled()) {
+// log.info("add location " + location.getLabel());
+// }
locationsToAdd.add(location);
+
}
- zoneEditorUI.getModel().removeAvailableStratas(locationsToAdd);
+ zoneEditorUI.getModel().moveStratasToZone(locationsToAdd, selectedZone);
}
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java
new file mode 100644
index 0000000..af2c00b
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/CreateZoneAction.java
@@ -0,0 +1,30 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones.actions;
+
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneEditorUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel;
+import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport;
+
+import javax.swing.JOptionPane;
+
+import static org.nuiton.i18n.I18n.t;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class CreateZoneAction extends SimpleActionSupport<ZoneEditorUI> {
+
+ public CreateZoneAction(ZoneEditorUI zoneEditorUI) {
+ super(zoneEditorUI);
+ }
+
+ @Override
+ protected void onActionPerformed(ZoneEditorUI zoneEditorUI) {
+
+ String zoneLabel = JOptionPane.showInputDialog(t("tutti.zoneEditor.createZone.message"));
+
+ ZoneUIModel zone = new ZoneUIModel();
+ zone.setLabel(zoneLabel);
+ zoneEditorUI.getModel().addZone(zone);
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
index 4c7390f..041c64b 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/actions/RemoveStratasAction.java
@@ -17,6 +17,6 @@ public class RemoveStratasAction extends SimpleActionSupport<ZoneEditorUI> {
@Override
protected void onActionPerformed(ZoneEditorUI zoneEditorUI) {
- ((DefaultTreeModel) zoneEditorUI.getAvailableStratas().getModel()).reload();
+ ((DefaultTreeModel) zoneEditorUI.getAvailableStratasTree().getModel()).reload();
}
}
diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
index 73beba0..f058c04 100644
--- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
+++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
@@ -2344,3 +2344,4 @@ tutti.vesselUseFeatureTable.action.removeCaracteristic.tip=
tutti.vesselUseFeatureTable.table.header.key=
tutti.vesselUseFeatureTable.table.header.value=
tutti.vesselUseFeatureTable.title=
+tutti.zoneEditor.createZone.message=
diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
index c6500ff..7e8bc0e 100644
--- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
+++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
@@ -2174,3 +2174,4 @@ tutti.vesselUseFeatureTable.action.removeCaracteristic.tip=Supprimer la caracté
tutti.vesselUseFeatureTable.table.header.key=Caractéristique
tutti.vesselUseFeatureTable.table.header.value=Valeur
tutti.vesselUseFeatureTable.title=Autres paramètres
+tutti.zoneEditor.createZone.message=
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
06/19: noeuds + renderer + modeles d'arbre + modele de zone (refs #7929)
by codelutin.com scm 03 Feb '16
by codelutin.com scm 03 Feb '16
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New commit to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
commit ee33a6433136cb43cb42f46093c8d941cfd452a7
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:38:05 2016 +0100
noeuds + renderer + modeles d'arbre + modele de zone (refs #7929)
---
.../content/protocol/zones/StratasTreeModel.java | 123 +++++++++++++++++++
.../protocol/zones/ZoneEditorTreeCellRenderer.java | 45 +++++++
.../swing/content/protocol/zones/ZoneUIModel.java | 136 +++++++++++++++++++++
.../content/protocol/zones/ZonesTreeModel.java | 98 +++++++++++++++
.../content/protocol/zones/nodes/StrataNode.java | 20 +++
.../protocol/zones/nodes/SubStrataNode.java | 20 +++
.../content/protocol/zones/nodes/ZoneNode.java | 20 +++
7 files changed, 462 insertions(+)
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/StratasTreeModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/StratasTreeModel.java
new file mode 100644
index 0000000..4a17b0f
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/StratasTreeModel.java
@@ -0,0 +1,123 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones;
+
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.StrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.SubStrataNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class StratasTreeModel extends DefaultTreeModel {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(StratasTreeModel.class);
+
+ public StratasTreeModel() {
+ super(new DefaultMutableTreeNode());
+ }
+
+ public void removeStratas(Collection<Strata> stratasToRemove) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ Enumeration rootChildren = root.children();
+ Collection<DefaultMutableTreeNode> nodesToRemove = new HashSet<>();
+
+ while (rootChildren.hasMoreElements()) {
+
+ StrataNode strataNode = (StrataNode) rootChildren.nextElement();
+
+ if (stratasToRemove.contains(strataNode.getStrata())) {
+ nodesToRemove.add(strataNode);
+ }
+ }
+
+ nodesToRemove.forEach(strataNode ->removeNodeFromParent(strataNode));
+
+ }
+
+// public void removeSubStratas(Collection<Strata> subStratasToRemove) {
+//
+// DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+//
+// Enumeration rootChildren = root.children();
+// Collection<DefaultMutableTreeNode> nodesToRemove = new HashSet<>();
+//
+// while (rootChildren.hasMoreElements()) {
+//
+// StrataNode strataNode = (StrataNode) rootChildren.nextElement();
+//
+// if (stratasToRemove.contains(strataNode.getStrata())) {
+// nodesToRemove.add(strataNode);
+// }
+// }
+//
+// nodesToRemove.forEach(strataNode ->removeNodeFromParent(strataNode));
+//
+// }
+
+ public void addStratas(Collection<Strata> stratasToAdd) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ stratasToAdd.forEach(strata -> {
+
+ StrataNode strataNode = new StrataNode(strata);
+ insertNodeInto(strataNode, root, root.getChildCount());
+
+ strata.getSubstrata().forEach(substrata -> {
+
+ if (substrata != null) {
+ SubStrataNode subStrataNode = new SubStrataNode(substrata);
+ insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount());
+ }
+
+ });
+
+ });
+
+ }
+
+ public void addSubStratas(Collection<SubStrata> subStratas, Strata strata) {
+
+ StrataNode strataNode = findStrataNode(strata);
+
+ subStratas.forEach(substrata -> {
+
+ if (substrata != null) {
+ SubStrataNode subStrataNode = new SubStrataNode(substrata);
+ insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount());
+ }
+
+ });
+
+ }
+
+ protected StrataNode findStrataNode(Strata strata) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ Enumeration rootChildren = root.children();
+
+ StrataNode strataNode = null;
+
+ while (strataNode == null && rootChildren.hasMoreElements()) {
+ StrataNode nextNode = (StrataNode) rootChildren.nextElement();
+ if (strata.equals(nextNode.getStrata())) {
+ strataNode = nextNode;
+ }
+ }
+
+ return strataNode;
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorTreeCellRenderer.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorTreeCellRenderer.java
new file mode 100644
index 0000000..a319e9e
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorTreeCellRenderer.java
@@ -0,0 +1,45 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones;
+
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
+import fr.ifremer.tutti.persistence.entities.protocol.Zone;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.StrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.SubStrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.ZoneNode;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.Component;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class ZoneEditorTreeCellRenderer extends DefaultTreeCellRenderer {
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+
+ super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+
+ String text = "";
+
+ if (value instanceof StrataNode) {
+ Strata strata = ((StrataNode) value).getStrata();
+ text = strata.getLocation().getLabel();
+
+ } else if (value instanceof SubStrataNode) {
+ SubStrata substrata = ((SubStrataNode) value).getSubstrata();
+ text = substrata.getLocation().getLabel();
+
+ } else if (value instanceof ZoneNode) {
+ Zone zone = ((ZoneNode) value).getZone();
+ text = zone.getLabel();
+ }
+
+ setText(text);
+
+ return this;
+ }
+
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneUIModel.java
new file mode 100644
index 0000000..e01af7e
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneUIModel.java
@@ -0,0 +1,136 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones;
+
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.persistence.entities.protocol.Zone;
+import fr.ifremer.tutti.persistence.entities.protocol.Zones;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> implements Zone {
+
+ protected final Zone delegate = Zones.newZone();
+
+ protected static Binder<ZoneUIModel, Zone> toBeanBinder = BinderFactory.newBinder(ZoneUIModel.class, Zone.class);
+
+ protected static Binder<Zone, ZoneUIModel> fromBeanBinder = BinderFactory.newBinder(Zone.class, ZoneUIModel.class);
+
+ public ZoneUIModel() {
+ super(fromBeanBinder, toBeanBinder);
+ }
+
+ @Override
+ public void addAllStrata(Collection<Strata> strata) {
+ Object oldValue = new HashSet<>(getStrata());
+ delegate.addAllStrata(strata);
+ firePropertyChanged(PROPERTY_STRATA, oldValue, strata);
+ }
+
+ @Override
+ public void addStrata(Strata strata) {
+ Object oldValue = new HashSet<>(getStrata());
+ delegate.addStrata(strata);
+ firePropertyChanged(PROPERTY_STRATA, oldValue, strata);
+ }
+
+ @Override
+ public boolean containsAllStrata(Collection<Strata> strata) {
+ return delegate.containsAllStrata(strata);
+ }
+
+ @Override
+ public boolean containsStrata(Strata strata) {
+ return delegate.containsStrata(strata);
+ }
+
+ @Override
+ public String getLabel() {
+ return delegate.getLabel();
+ }
+
+ @Override
+ public Collection<Strata> getStrata() {
+ return delegate.getStrata();
+ }
+
+ @Override
+ public Strata getStrata(int index) {
+ return delegate.getStrata(index);
+ }
+
+ @Override
+ public boolean isStrataEmpty() {
+ return delegate.isStrataEmpty();
+ }
+
+ @Override
+ public boolean removeAllStrata(Collection<Strata> strata) {
+ Object oldValue = new HashSet<>(getStrata());
+ boolean result = delegate.removeAllStrata(strata);
+ firePropertyChanged(PROPERTY_STRATA, oldValue, strata);
+ return result;
+ }
+
+ @Override
+ public boolean removeStrata(Strata strata) {
+ Object oldValue = new HashSet<>(getStrata());
+ boolean result = delegate.removeStrata(strata);
+ firePropertyChanged(PROPERTY_STRATA, oldValue, strata);
+ return result;
+ }
+
+ @Override
+ public void setLabel(String label) {
+ Object oldValue = getLabel();
+ delegate.setLabel(label);
+ firePropertyChanged(PROPERTY_LABEL, oldValue, label);
+ }
+
+ @Override
+ public void setStrata(Collection<Strata> strata) {
+ Object oldValue = new HashSet<>(getStrata());
+ delegate.setStrata(strata);
+ firePropertyChanged(PROPERTY_STRATA, oldValue, strata);
+ }
+
+ @Override
+ public int sizeStrata() {
+ return delegate.sizeStrata();
+ }
+
+ @Override
+ public void setId(String id) {
+ Object oldValue = getId();
+ delegate.setId(id);
+ firePropertyChanged(PROPERTY_ID, oldValue, id);
+ }
+
+ @Override
+ public void setId(Integer id) {
+ Object oldValue = getId();
+ delegate.setId(id);
+ firePropertyChanged(PROPERTY_ID, oldValue, id);
+ }
+
+ @Override
+ public Integer getIdAsInt() {
+ return delegate.getIdAsInt();
+ }
+
+ @Override
+ public String getId() {
+ return delegate.getId();
+ }
+
+ @Override
+ protected Zone newEntity() {
+ return Zones.newZone();
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZonesTreeModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZonesTreeModel.java
new file mode 100644
index 0000000..b2d3e19
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZonesTreeModel.java
@@ -0,0 +1,98 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones;
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.StrataNode;
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes.ZoneNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class ZonesTreeModel extends DefaultTreeModel {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ZonesTreeModel.class);
+
+ public ZonesTreeModel() {
+ super(new DefaultMutableTreeNode());
+ }
+
+ public void removeZones(Collection<ZoneUIModel> zonesToRemove) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ Enumeration rootChildren = root.children();
+ Collection<DefaultMutableTreeNode> nodesToRemove = new HashSet<>();
+
+ while (rootChildren.hasMoreElements()) {
+
+ ZoneNode zoneNode = (ZoneNode) rootChildren.nextElement();
+
+ if (zonesToRemove.contains(zoneNode.getZone())) {
+ nodesToRemove.add(zoneNode);
+ }
+ }
+
+ nodesToRemove.forEach(zoneNode ->removeNodeFromParent(zoneNode));
+ }
+
+ public void addZones(Collection<ZoneUIModel> zonesToAdd) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ zonesToAdd.forEach(zone -> {
+
+ ZoneNode zoneNode = new ZoneNode(zone);
+ insertNodeInto(zoneNode, root, root.getChildCount());
+
+ });
+ }
+
+ public void setStratas(ZoneUIModel zone, Collection<Strata> stratas) {
+
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
+
+ Enumeration rootChildren = root.children();
+
+ ZoneNode zoneNode = null;
+
+ while (zoneNode == null && rootChildren.hasMoreElements()) {
+ ZoneNode nextNode = (ZoneNode) rootChildren.nextElement();
+ if (zone.equals(nextNode.getZone())) {
+ zoneNode = nextNode;
+ }
+ }
+
+ Preconditions.checkNotNull(zoneNode);
+
+ for (Strata strata : stratas) {
+
+ StrataNode strataNode = new StrataNode(strata);
+
+ if (log.isInfoEnabled()) {
+ log.info("add strata " + strata.getLocation().getLabel());
+ }
+
+ insertNodeInto(strataNode, zoneNode, zoneNode.getChildCount());
+
+// newAvailableStratas.get(strata).forEach(substrata -> {
+//
+// if (substrata != null) {
+// SubStrataNode subStrataNode = new SubStrataNode(substrata);
+// insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount());
+// }
+//
+// });
+
+ }
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/StrataNode.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/StrataNode.java
new file mode 100644
index 0000000..87255bc
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/StrataNode.java
@@ -0,0 +1,20 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes;
+
+import fr.ifremer.tutti.persistence.entities.protocol.Strata;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class StrataNode extends DefaultMutableTreeNode {
+
+ public StrataNode(Strata strata) {
+ super(strata, true);
+ }
+
+ public Strata getStrata() {
+ return (Strata) userObject;
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/SubStrataNode.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/SubStrataNode.java
new file mode 100644
index 0000000..0cc705d
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/SubStrataNode.java
@@ -0,0 +1,20 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes;
+
+import fr.ifremer.tutti.persistence.entities.protocol.SubStrata;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class SubStrataNode extends DefaultMutableTreeNode {
+
+ public SubStrataNode(SubStrata substrata) {
+ super(substrata, false);
+ }
+
+ public SubStrata getSubstrata() {
+ return (SubStrata) userObject;
+ }
+}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/ZoneNode.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/ZoneNode.java
new file mode 100644
index 0000000..8406978
--- /dev/null
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/ZoneNode.java
@@ -0,0 +1,20 @@
+package fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes;
+
+import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 4.5
+ */
+public class ZoneNode extends DefaultMutableTreeNode {
+
+ public ZoneNode(ZoneUIModel zone) {
+ super(zone, true);
+ }
+
+ public ZoneUIModel getZone() {
+ return (ZoneUIModel) userObject;
+ }
+}
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
05/19: mise a jour suite aux modifs du modele + appel des oncloseui des sous-ui (refs #7929)
by codelutin.com scm 03 Feb '16
by codelutin.com scm 03 Feb '16
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New commit to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
commit 7a82e9504cde295068df51bf9a1f4e81140fa957
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:37:01 2016 +0100
mise a jour suite aux modifs du modele + appel des oncloseui des sous-ui (refs #7929)
---
.../content/protocol/EditProtocolUIHandler.java | 3 ++
.../content/protocol/EditProtocolUIModel.java | 44 +++++++++++-----------
.../content/protocol/rtp/RtpEditorUIModel.java | 4 +-
3 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
index c92afd3..f6c14e6 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
@@ -810,6 +810,9 @@ public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUI
clearValidators();
ui.getTabPanel().setSelectedIndex(0);
+ closeUI(ui.getRtpEditorUI());
+ closeUI(ui.getZoneEditor());
+
}
@Override
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
index 73391ad..04d6188 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
@@ -780,58 +780,58 @@ public class EditProtocolUIModel extends AbstractTuttiBeanUIModel<TuttiProtocol,
}
@Override
- public Collection<Zone> getZones() {
- return editObject.getZones();
+ public Collection<Zone> getZone() {
+ return editObject.getZone();
}
@Override
- public void setZones(Collection<Zone> zones) {
- editObject.setZones(zones);
+ public void setZone(Collection<Zone> zones) {
+ editObject.setZone(zones);
}
@Override
- public Zone getZones(int index) {
- return editObject.getZones(index);
+ public Zone getZone(int index) {
+ return editObject.getZone(index);
}
@Override
- public boolean isZonesEmpty() {
- return editObject.isZonesEmpty();
+ public boolean isZoneEmpty() {
+ return editObject.isZoneEmpty();
}
@Override
- public int sizeZones() {
- return editObject.sizeZones();
+ public int sizeZone() {
+ return editObject.sizeZone();
}
@Override
- public void addZones(Zone zone) {
- editObject.addZones(zone);
+ public void addZone(Zone zone) {
+ editObject.addZone(zone);
}
@Override
- public void addAllZones(Collection<Zone> zones) {
- editObject.addAllZones(zones);
+ public void addAllZone(Collection<Zone> zones) {
+ editObject.addAllZone(zones);
}
@Override
- public boolean removeZones(Zone zone) {
- return editObject.removeZones(zone);
+ public boolean removeZone(Zone zone) {
+ return editObject.removeZone(zone);
}
@Override
- public boolean removeAllZones(Collection<Zone> zones) {
- return editObject.removeAllZones(zones);
+ public boolean removeAllZone(Collection<Zone> zones) {
+ return editObject.removeAllZone(zones);
}
@Override
- public boolean containsZones(Zone zone) {
- return editObject.containsZones(zone);
+ public boolean containsZone(Zone zone) {
+ return editObject.containsZone(zone);
}
@Override
- public boolean containsAllZones(Collection<Zone> zones) {
- return editObject.containsAllZones(zones);
+ public boolean containsAllZone(Collection<Zone> zones) {
+ return editObject.containsAllZone(zones);
}
@Override
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/rtp/RtpEditorUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/rtp/RtpEditorUIModel.java
index cc2981b..9a23c9a 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/rtp/RtpEditorUIModel.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/rtp/RtpEditorUIModel.java
@@ -239,7 +239,9 @@ public class RtpEditorUIModel extends AbstractTuttiBeanUIModel<EditProtocolSpeci
}
public void reset() {
- setRowModel(row);
+ if (row >= 0 && row < rows.size()) {
+ setRowModel(row);
+ }
}
public void updateRowRtp() {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
03 Feb '16
This is an automated email from the git hooks/post-receive script.
New commit to branch feature/7929_editeur_de_zone in repository tutti.
See http://git.codelutin.com/tutti.git
commit 553538eacb36c4da27722fc604c34b2c46a3a386
Author: Kevin Morin <morin(a)codelutin.com>
Date: Wed Jan 27 18:35:31 2016 +0100
ajout des strates et sous strates au modèle (refs #7929)
---
.../src/main/xmi/tutti-persistence.zargo | Bin 59842 -> 60824 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/tutti-persistence/src/main/xmi/tutti-persistence.zargo b/tutti-persistence/src/main/xmi/tutti-persistence.zargo
index 88791d2..2edf7d5 100644
Binary files a/tutti-persistence/src/main/xmi/tutti-persistence.zargo and b/tutti-persistence/src/main/xmi/tutti-persistence.zargo differ
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0