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 from f259b29 creation de zones + déplacement des noeuds (refs #7929) new 8f112f8 création des modeles de strates et sous strates (refs #7929) new c009f80 ajout des listeners sur les strates et sous strates (refs #7929) 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 c009f80feee094d357eee660e214f0fb57aed602 Author: Kevin Morin <morin@codelutin.com> Date: Thu Jan 28 19:22:03 2016 +0100 ajout des listeners sur les strates et sous strates (refs #7929) commit 8f112f8d85b2647687b21892d79071535c7f4caf Author: Kevin Morin <morin@codelutin.com> Date: Thu Jan 28 19:21:56 2016 +0100 création des modeles de strates et sous strates (refs #7929) Summary of changes: .../swing/content/protocol/zones/ZoneEditorUI.jaxx | 1 + .../protocol/zones/ZoneEditorUIHandler.java | 136 +++++++++++--- .../content/protocol/zones/ZoneEditorUIModel.java | 165 +++++++++-------- .../content/protocol/zones/ZonesTreeModel.java | 98 ---------- .../protocol/zones/actions/AddStratasAction.java | 51 ++++-- .../protocol/zones/actions/CreateZoneAction.java | 10 +- .../zones/actions/RemoveStratasAction.java | 58 +++++- .../protocol/zones/models/StrataUIModel.java | 192 ++++++++++++++++++++ .../protocol/zones/models/SubStrataUIModel.java | 108 +++++++++++ .../protocol/zones/{ => models}/ZoneUIModel.java | 44 ++++- .../content/protocol/zones/nodes/StrataNode.java | 20 -- .../protocol/zones/nodes/SubStrataNode.java | 20 -- .../content/protocol/zones/tree/StrataNode.java | 20 ++ .../zones/{ => tree}/StratasTreeModel.java | 75 +++++++- .../content/protocol/zones/tree/SubStrataNode.java | 20 ++ .../{ => tree}/ZoneEditorTreeCellRenderer.java | 16 +- .../protocol/zones/{nodes => tree}/ZoneNode.java | 4 +- .../protocol/zones/tree/ZonesTreeModel.java | 202 +++++++++++++++++++++ .../resources/i18n/tutti-ui-swing_fr_FR.properties | 2 +- 19 files changed, 955 insertions(+), 287 deletions(-) delete mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZonesTreeModel.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/StrataUIModel.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/SubStrataUIModel.java rename tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/{ => models}/ZoneUIModel.java (69%) delete mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/StrataNode.java delete mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/SubStrataNode.java create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/StrataNode.java rename tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/{ => tree}/StratasTreeModel.java (57%) create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/SubStrataNode.java rename tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/{ => tree}/ZoneEditorTreeCellRenderer.java (70%) rename tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/{nodes => tree}/ZoneNode.java (69%) create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZonesTreeModel.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 8f112f8d85b2647687b21892d79071535c7f4caf Author: Kevin Morin <morin@codelutin.com> Date: Thu Jan 28 19:21:56 2016 +0100 création des modeles de strates et sous strates (refs #7929) --- .../content/protocol/zones/ZonesTreeModel.java | 98 ---------- .../protocol/zones/models/StrataUIModel.java | 192 ++++++++++++++++++++ .../protocol/zones/models/SubStrataUIModel.java | 108 +++++++++++ .../protocol/zones/{ => models}/ZoneUIModel.java | 44 ++++- .../content/protocol/zones/nodes/StrataNode.java | 20 -- .../protocol/zones/nodes/SubStrataNode.java | 20 -- .../content/protocol/zones/tree/StrataNode.java | 20 ++ .../zones/{ => tree}/StratasTreeModel.java | 75 +++++++- .../content/protocol/zones/tree/SubStrataNode.java | 20 ++ .../{ => tree}/ZoneEditorTreeCellRenderer.java | 16 +- .../protocol/zones/{nodes => tree}/ZoneNode.java | 4 +- .../protocol/zones/tree/ZonesTreeModel.java | 202 +++++++++++++++++++++ 12 files changed, 656 insertions(+), 163 deletions(-) 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 deleted file mode 100644 index b2d3e19..0000000 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZonesTreeModel.java +++ /dev/null @@ -1,98 +0,0 @@ -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/models/StrataUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/StrataUIModel.java new file mode 100644 index 0000000..e7a09f8 --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/StrataUIModel.java @@ -0,0 +1,192 @@ +package fr.ifremer.tutti.ui.swing.content.protocol.zones.models; + +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.referential.TuttiLocation; +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; +import java.util.Objects; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class StrataUIModel extends AbstractTuttiBeanUIModel<Strata, StrataUIModel> implements Strata { + + public static final String PROPERTY_ZONE = "zone"; + + protected final Strata delegate = Stratas.newStrata(); + + protected ZoneUIModel zone; + + protected static Binder<StrataUIModel, Strata> toBeanBinder = BinderFactory.newBinder(StrataUIModel.class, Strata.class); + + protected static Binder<Strata, StrataUIModel> fromBeanBinder = BinderFactory.newBinder(Strata.class, StrataUIModel.class); + + public StrataUIModel() { + super(fromBeanBinder, toBeanBinder); + } + + public StrataUIModel(TuttiLocation location) { + this(); + setLocation(location); + } + + @Override + public void addAllSubstrata(Collection<SubStrata> substrata) { + Object oldValue = new HashSet<>(getSubstrata()); + delegate.addAllSubstrata(substrata); + firePropertyChanged(PROPERTY_SUBSTRATA, oldValue, getSubstrata()); + } + + @Override + public void addSubstrata(SubStrata substrata) { + Object oldValue = new HashSet<>(getSubstrata()); + delegate.addSubstrata(substrata); + firePropertyChanged(PROPERTY_SUBSTRATA, oldValue, getSubstrata()); + } + + @Override + public boolean containsAllSubstrata(Collection<SubStrata> substrata) { + return delegate.containsAllSubstrata(substrata); + } + + @Override + public boolean containsSubstrata(SubStrata substrata) { + return delegate.containsSubstrata(substrata); + } + + @Override + public TuttiLocation getLocation() { + return delegate.getLocation(); + } + + @Override + public Collection<SubStrata> getSubstrata() { + return delegate.getSubstrata(); + } + + @Override + public SubStrata getSubstrata(int index) { + return delegate.getSubstrata(index); + } + + @Override + public boolean isSubstrataEmpty() { + return delegate.isSubstrataEmpty(); + } + + @Override + public boolean removeAllSubstrata(Collection<SubStrata> substrata) { + Object oldValue = new HashSet<>(getSubstrata()); + boolean result = delegate.removeAllSubstrata(substrata); + firePropertyChanged(PROPERTY_SUBSTRATA, oldValue, getSubstrata()); + return result; + } + + @Override + public boolean removeSubstrata(SubStrata substrata) { + Object oldValue = new HashSet<>(getSubstrata()); + boolean result = delegate.removeSubstrata(substrata); + firePropertyChanged(PROPERTY_SUBSTRATA, oldValue, getSubstrata()); + return result; + } + + @Override + public void setLocation(TuttiLocation location) { + Object oldValue = getLocation(); + delegate.setLocation(location); + firePropertyChanged(PROPERTY_LOCATION, oldValue, getLocation()); + } + + @Override + public void setSubstrata(Collection<SubStrata> substrata) { + Object oldValue = new HashSet<>(getSubstrata()); + delegate.setSubstrata(substrata); + firePropertyChanged(PROPERTY_SUBSTRATA, oldValue, getSubstrata()); + } + + @Override + public int sizeSubstrata() { + return delegate.sizeSubstrata(); + } + + @Override + public String getId() { + return delegate.getId(); + } + + @Override + public Integer getIdAsInt() { + return delegate.getIdAsInt(); + } + + @Override + public void setId(Integer id) { + Object oldValue = getId(); + delegate.setId(id); + firePropertyChanged(PROPERTY_ID, oldValue, getId()); + } + + @Override + public void setId(String id) { + Object oldValue = getId(); + delegate.setId(id); + firePropertyChanged(PROPERTY_ID, oldValue, getId()); + } + + public String getLabel() { + return getLocation() == null ? null : getLocation().getLabel(); + } + + public ZoneUIModel getZone() { + return zone; + } + + public void setZone(ZoneUIModel zone) { + Object oldValue = getZone(); + this.zone = zone; + firePropertyChange(PROPERTY_ZONE, oldValue, zone); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!StrataUIModel.class.equals(obj.getClass())) { + return false; + } + if (getId() != null) { + return getId().equals(((StrataUIModel) obj).getId()); + } + if (getLocation() != null) { + return getLocation().equals(((StrataUIModel) obj).getLocation()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(getId(), getLocation()); + } + + @Override + public String toString() { + return getLabel(); + } + + @Override + protected Strata newEntity() { + return Stratas.newStrata(); + } + +} diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/SubStrataUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/SubStrataUIModel.java new file mode 100644 index 0000000..a57aa4c --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/SubStrataUIModel.java @@ -0,0 +1,108 @@ +package fr.ifremer.tutti.ui.swing.content.protocol.zones.models; + +import fr.ifremer.tutti.persistence.entities.protocol.SubStrata; +import fr.ifremer.tutti.persistence.entities.protocol.SubStratas; +import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.Objects; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class SubStrataUIModel extends AbstractTuttiBeanUIModel<SubStrata, SubStrataUIModel> implements SubStrata { + + protected final SubStrata delegate = SubStratas.newSubStrata(); + + protected static Binder<SubStrataUIModel, SubStrata> toBeanBinder = BinderFactory.newBinder(SubStrataUIModel.class, SubStrata.class); + + protected static Binder<SubStrata, SubStrataUIModel> fromBeanBinder = BinderFactory.newBinder(SubStrata.class, SubStrataUIModel.class); + + public SubStrataUIModel() { + super(fromBeanBinder, toBeanBinder); + } + + public SubStrataUIModel(TuttiLocation location) { + this(); + setLocation(location); + } + + @Override + public TuttiLocation getLocation() { + return delegate.getLocation(); + } + + @Override + public void setLocation(TuttiLocation location) { + Object oldValue = getLocation(); + delegate.setLocation(location); + firePropertyChanged(PROPERTY_LOCATION, oldValue, getLocation()); + } + + @Override + public String getId() { + return delegate.getId(); + } + + @Override + public void setId(Integer id) { + Object oldValue = getId(); + delegate.setId(id); + firePropertyChanged(PROPERTY_ID, oldValue, getId()); + } + + @Override + public void setId(String id) { + Object oldValue = getId(); + delegate.setId(id); + firePropertyChanged(PROPERTY_ID, oldValue, getId()); + } + + @Override + public Integer getIdAsInt() { + return delegate.getIdAsInt(); + } + + public String getLabel() { + return getLocation() == null ? null : getLocation().getLabel(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!StrataUIModel.class.equals(obj.getClass())) { + return false; + } + if (getId() != null) { + return getId().equals(((StrataUIModel) obj).getId()); + } + if (getLocation() != null) { + return getLocation().equals(((StrataUIModel) obj).getLocation()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(getId(), getLocation()); + } + + @Override + public String toString() { + return getLabel(); + } + + @Override + protected SubStrata newEntity() { + return SubStratas.newSubStrata(); + } + +} 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/models/ZoneUIModel.java similarity index 69% rename from tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneUIModel.java rename to tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/models/ZoneUIModel.java index e01af7e..6ff1188 100644 --- 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/models/ZoneUIModel.java @@ -1,4 +1,4 @@ -package fr.ifremer.tutti.ui.swing.content.protocol.zones; +package fr.ifremer.tutti.ui.swing.content.protocol.zones.models; import fr.ifremer.tutti.persistence.entities.protocol.Strata; import fr.ifremer.tutti.persistence.entities.protocol.Zone; @@ -30,14 +30,16 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp public void addAllStrata(Collection<Strata> strata) { Object oldValue = new HashSet<>(getStrata()); delegate.addAllStrata(strata); - firePropertyChanged(PROPERTY_STRATA, oldValue, strata); + updateStrataZone(strata, this); + firePropertyChanged(PROPERTY_STRATA, oldValue, getStrata()); } @Override public void addStrata(Strata strata) { Object oldValue = new HashSet<>(getStrata()); delegate.addStrata(strata); - firePropertyChanged(PROPERTY_STRATA, oldValue, strata); + updateStrataZone(strata, this); + firePropertyChanged(PROPERTY_STRATA, oldValue, getStrata()); } @Override @@ -65,6 +67,14 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp return delegate.getStrata(index); } + /** + * @param strata + * @return the strata from the stratas of the zone which equals the strata in parameters + */ + public Strata getStrata(Strata strata) { + return getStrata().stream().filter(s -> s != null && s.equals(strata)).findFirst().orElse(null); + } + @Override public boolean isStrataEmpty() { return delegate.isStrataEmpty(); @@ -74,7 +84,8 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp public boolean removeAllStrata(Collection<Strata> strata) { Object oldValue = new HashSet<>(getStrata()); boolean result = delegate.removeAllStrata(strata); - firePropertyChanged(PROPERTY_STRATA, oldValue, strata); + updateStrataZone(strata, null); + firePropertyChanged(PROPERTY_STRATA, oldValue, getStrata()); return result; } @@ -82,7 +93,8 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp public boolean removeStrata(Strata strata) { Object oldValue = new HashSet<>(getStrata()); boolean result = delegate.removeStrata(strata); - firePropertyChanged(PROPERTY_STRATA, oldValue, strata); + updateStrataZone(strata, null); + firePropertyChanged(PROPERTY_STRATA, oldValue, getStrata()); return result; } @@ -96,8 +108,10 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp @Override public void setStrata(Collection<Strata> strata) { Object oldValue = new HashSet<>(getStrata()); + updateStrataZone(getStrata(), null); delegate.setStrata(strata); - firePropertyChanged(PROPERTY_STRATA, oldValue, strata); + updateStrataZone(strata, this); + firePropertyChanged(PROPERTY_STRATA, oldValue, getStrata()); } @Override @@ -130,7 +144,25 @@ public class ZoneUIModel extends AbstractTuttiBeanUIModel<Zone, ZoneUIModel> imp } @Override + public String toString() { + return getLabel(); + } + + @Override protected Zone newEntity() { return Zones.newZone(); } + + protected void updateStrataZone(Collection<Strata> stratas, ZoneUIModel zone) { + stratas.stream() + .filter(strata -> strata instanceof StrataUIModel) + .forEach(strata -> ((StrataUIModel) strata).setZone(zone)); + } + + protected void updateStrataZone(Strata strata, ZoneUIModel zone) { + if (strata instanceof StrataUIModel) { + ((StrataUIModel) strata).setZone(zone); + } + } + } 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 deleted file mode 100644 index 87255bc..0000000 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/StrataNode.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 0cc705d..0000000 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/SubStrataNode.java +++ /dev/null @@ -1,20 +0,0 @@ -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/tree/StrataNode.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/StrataNode.java new file mode 100644 index 0000000..c4a4f03 --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/StrataNode.java @@ -0,0 +1,20 @@ +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; + +import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel; + +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class StrataNode extends DefaultMutableTreeNode { + + public StrataNode(StrataUIModel strata) { + super(strata, true); + } + + public StrataUIModel getStrata() { + return (StrataUIModel) userObject; + } +} 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/tree/StratasTreeModel.java similarity index 57% rename from tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/StratasTreeModel.java rename to tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/StratasTreeModel.java index 4a17b0f..b75dd47 100644 --- 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/tree/StratasTreeModel.java @@ -1,9 +1,9 @@ -package fr.ifremer.tutti.ui.swing.content.protocol.zones; +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; -import fr.ifremer.tutti.persistence.entities.protocol.Strata; +import com.google.common.base.Preconditions; 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 fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel; +import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -26,7 +26,7 @@ public class StratasTreeModel extends DefaultTreeModel { super(new DefaultMutableTreeNode()); } - public void removeStratas(Collection<Strata> stratasToRemove) { + public void removeStratas(Collection<StrataUIModel> stratasToRemove) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot(); @@ -66,7 +66,7 @@ public class StratasTreeModel extends DefaultTreeModel { // // } - public void addStratas(Collection<Strata> stratasToAdd) { + public void addStratas(Collection<StrataUIModel> stratasToAdd) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot(); @@ -78,7 +78,7 @@ public class StratasTreeModel extends DefaultTreeModel { strata.getSubstrata().forEach(substrata -> { if (substrata != null) { - SubStrataNode subStrataNode = new SubStrataNode(substrata); + SubStrataNode subStrataNode = new SubStrataNode((SubStrataUIModel) substrata); insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount()); } @@ -88,14 +88,14 @@ public class StratasTreeModel extends DefaultTreeModel { } - public void addSubStratas(Collection<SubStrata> subStratas, Strata strata) { + public void addSubStratas(Collection<SubStrata> subStratas, StrataUIModel strata) { StrataNode strataNode = findStrataNode(strata); subStratas.forEach(substrata -> { if (substrata != null) { - SubStrataNode subStrataNode = new SubStrataNode(substrata); + SubStrataNode subStrataNode = new SubStrataNode((SubStrataUIModel) substrata); insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount()); } @@ -103,7 +103,46 @@ public class StratasTreeModel extends DefaultTreeModel { } - protected StrataNode findStrataNode(Strata strata) { + public void updateSubStratas(StrataUIModel strata, + Collection<SubStrataUIModel> subStratasToAdd, + Collection<SubStrataUIModel> subStratasToRemove) { + + StrataNode strataNode = findStrataNode(strata); + updateSubStratas(strataNode, subStratasToAdd, subStratasToRemove); + + } + + public void updateSubStratas(StrataNode strataNode, + Collection<SubStrataUIModel> subStratasToAdd, + Collection<SubStrataUIModel> subStratasToRemove) { + + Preconditions.checkNotNull(strataNode); + + for (SubStrataUIModel subStrata : subStratasToRemove) { + + SubStrataNode subStrataNode = findSubStrataNode(subStrata, strataNode); + + if (log.isInfoEnabled()) { + log.info("remove subStrata " + subStrata.getLabel()); + } + + removeNodeFromParent(subStrataNode); + } + + for (SubStrataUIModel subStrata : subStratasToAdd) { + + SubStrataNode subStrataNode = new SubStrataNode(subStrata); + + if (log.isInfoEnabled()) { + log.info("add strata " + subStrata.getLabel()); + } + + insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount()); + + } + } + + protected StrataNode findStrataNode(StrataUIModel strata) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot(); @@ -120,4 +159,20 @@ public class StratasTreeModel extends DefaultTreeModel { return strataNode; } + + protected SubStrataNode findSubStrataNode(SubStrataUIModel subStrata, StrataNode strataNode) { + + Enumeration strataChildren = strataNode.children(); + + SubStrataNode subStrataNode = null; + + while (subStrataNode == null && strataChildren.hasMoreElements()) { + SubStrataNode nextNode = (SubStrataNode) strataChildren.nextElement(); + if (subStrata.equals(nextNode.getSubstrata())) { + subStrataNode = nextNode; + } + } + + return subStrataNode; + } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/SubStrataNode.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/SubStrataNode.java new file mode 100644 index 0000000..0ce5a2f --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/SubStrataNode.java @@ -0,0 +1,20 @@ +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; + +import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.SubStrataUIModel; + +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * @author Kevin Morin (Code Lutin) + * @since 4.5 + */ +public class SubStrataNode extends DefaultMutableTreeNode { + + public SubStrataNode(SubStrataUIModel substrata) { + super(substrata, false); + } + + public SubStrataUIModel getSubstrata() { + return (SubStrataUIModel) userObject; + } +} 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/tree/ZoneEditorTreeCellRenderer.java similarity index 70% rename from tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/ZoneEditorTreeCellRenderer.java rename to tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZoneEditorTreeCellRenderer.java index a319e9e..97aad64 100644 --- 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/tree/ZoneEditorTreeCellRenderer.java @@ -1,11 +1,10 @@ -package fr.ifremer.tutti.ui.swing.content.protocol.zones; +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; -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 fr.ifremer.tutti.ui.swing.content.protocol.zones.models.StrataUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; @@ -17,6 +16,9 @@ import java.awt.Component; */ public class ZoneEditorTreeCellRenderer extends DefaultTreeCellRenderer { + /** Logger. */ + private static final Log log = LogFactory.getLog(ZoneEditorTreeCellRenderer.class); + @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { @@ -25,8 +27,8 @@ public class ZoneEditorTreeCellRenderer extends DefaultTreeCellRenderer { String text = ""; if (value instanceof StrataNode) { - Strata strata = ((StrataNode) value).getStrata(); - text = strata.getLocation().getLabel(); + StrataUIModel strata = ((StrataNode) value).getStrata(); + text = strata.getLabel(); } else if (value instanceof SubStrataNode) { SubStrata substrata = ((SubStrataNode) value).getSubstrata(); 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/tree/ZoneNode.java similarity index 69% rename from tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/nodes/ZoneNode.java rename to tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZoneNode.java index 8406978..924fa07 100644 --- 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/tree/ZoneNode.java @@ -1,6 +1,6 @@ -package fr.ifremer.tutti.ui.swing.content.protocol.zones.nodes; +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; -import fr.ifremer.tutti.ui.swing.content.protocol.zones.ZoneUIModel; +import fr.ifremer.tutti.ui.swing.content.protocol.zones.models.ZoneUIModel; import javax.swing.tree.DefaultMutableTreeNode; diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZonesTreeModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZonesTreeModel.java new file mode 100644 index 0000000..3ee80fe --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/zones/tree/ZonesTreeModel.java @@ -0,0 +1,202 @@ +package fr.ifremer.tutti.ui.swing.content.protocol.zones.tree; + +import com.google.common.base.Preconditions; +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 javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @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 updateStratas(ZoneUIModel zone, + Collection<StrataUIModel> stratasToAdd, + Collection<StrataUIModel> stratasToRemove) { + + ZoneNode zoneNode = findZoneNode(zone); + updateStratas(zoneNode, stratasToAdd, stratasToRemove); + } + + public void updateStratas(ZoneNode zoneNode, + Collection<StrataUIModel> stratasToAdd, + Collection<StrataUIModel> stratasToRemove) { + + Preconditions.checkNotNull(zoneNode); + + for (StrataUIModel strata : stratasToRemove) { + + StrataNode strataNode = findStrataNode(strata, zoneNode); + + if (log.isInfoEnabled()) { + log.info("remove strata " + strata.getLabel()); + } + + removeNodeFromParent(strataNode); + } + + for (StrataUIModel strata : stratasToAdd) { + + StrataNode strataNode = new StrataNode(strata); + + if (log.isInfoEnabled()) { + log.info("add strata " + strata.getLabel()); + } + + insertNodeInto(strataNode, zoneNode, zoneNode.getChildCount()); + + Set<SubStrataUIModel> subStratasToAdd = strata.getSubstrata() + .stream() + .map(subStrata -> (SubStrataUIModel) subStrata) + .collect(Collectors.toSet()); + + updateSubStratas(strataNode, subStratasToAdd, Collections.emptySet()); + } + } + + public void updateSubStratas(StrataUIModel strata, + Collection<SubStrataUIModel> subStratasToAdd, + Collection<SubStrataUIModel> subStratasToRemove) { + + StrataNode strataNode = findStrataNode(strata, strata.getZone()); + updateSubStratas(strataNode, subStratasToAdd, subStratasToRemove); + + } + + public void updateSubStratas(StrataNode strataNode, + Collection<SubStrataUIModel> subStratasToAdd, + Collection<SubStrataUIModel> subStratasToRemove) { + + Preconditions.checkNotNull(strataNode); + + for (SubStrataUIModel subStrata : subStratasToRemove) { + + SubStrataNode subStrataNode = findSubStrataNode(subStrata, strataNode); + + if (log.isInfoEnabled()) { + log.info("remove subStrata " + subStrata.getLabel()); + } + + removeNodeFromParent(subStrataNode); + } + + for (SubStrataUIModel subStrata : subStratasToAdd) { + + SubStrataNode subStrataNode = new SubStrataNode(subStrata); + + if (log.isInfoEnabled()) { + log.info("add strata " + subStrata.getLabel()); + } + + insertNodeInto(subStrataNode, strataNode, strataNode.getChildCount()); + + } + } + + protected ZoneNode findZoneNode(ZoneUIModel zone) { + + 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; + } + } + + return zoneNode; + } + + protected StrataNode findStrataNode(StrataUIModel strata, ZoneUIModel zone) { + + ZoneNode zoneNode = findZoneNode(zone); + + return findStrataNode(strata, zoneNode); + } + + protected StrataNode findStrataNode(StrataUIModel strata, ZoneNode zoneNode) { + + Enumeration zoneChildren = zoneNode.children(); + + StrataNode strataNode = null; + + while (strataNode == null && zoneChildren.hasMoreElements()) { + StrataNode nextNode = (StrataNode) zoneChildren.nextElement(); + if (strata.equals(nextNode.getStrata())) { + strataNode = nextNode; + } + } + + return strataNode; + } + + protected SubStrataNode findSubStrataNode(SubStrataUIModel subStrata, StrataNode strataNode) { + + Enumeration strataChildren = strataNode.children(); + + SubStrataNode subStrataNode = null; + + while (subStrataNode == null && strataChildren.hasMoreElements()) { + SubStrataNode nextNode = (SubStrataNode) strataChildren.nextElement(); + if (subStrata.equals(nextNode.getSubstrata())) { + subStrataNode = nextNode; + } + } + + return subStrataNode; + } +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 c009f80feee094d357eee660e214f0fb57aed602 Author: Kevin Morin <morin@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@codelutin.com>.
participants (1)
-
codelutin.com scm