4 package eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.container
;
6 import java
.util
.ArrayList
;
9 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
10 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
11 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
12 import eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.TaxonNameEditorE4
;
20 public class ContainerFactoryE4
{
22 public static void createOrUpdateAcceptedTaxonsHomotypicGroup(
23 TaxonNameEditorE4 taxonNameEditor
) {
25 if(taxonNameEditor
.getAcceptedGroup() == null){
26 taxonNameEditor
.setAcceptedGroup(new AcceptedGroupE4(taxonNameEditor
, taxonNameEditor
.getTaxon().getHomotypicGroup()));
29 taxonNameEditor
.getAcceptedGroup().redraw(taxonNameEditor
.getTaxon().getHomotypicGroup());
34 public static void createOrUpdateHeterotypicSynonymyGroups(
35 TaxonNameEditorE4 taxonNameEditor
) {
36 List
<HomotypicalSynonymGroupE4
> retainedGroups
= new ArrayList
<>();
38 List
<HomotypicalSynonymGroupE4
> heterotypicSynonymGroups
= taxonNameEditor
.getHeterotypicSynonymGroups();
40 if (heterotypicSynonymGroups
!= null) {
42 for(HomotypicalSynonymGroupE4 group
: heterotypicSynonymGroups
){
43 retainedGroups
.add(group
);
47 for(HomotypicalGroup homotypicalGroup
: taxonNameEditor
.getTaxon().getHeterotypicSynonymyGroups()){
48 homotypicalGroup
= HibernateProxyHelper
.deproxy(homotypicalGroup
, HomotypicalGroup
.class);
49 HomotypicalSynonymGroupE4 group
= createOrUpdateHeterotypicSynonymyGroup(taxonNameEditor
, homotypicalGroup
);
51 retainedGroups
.remove(group
);
54 for(HomotypicalSynonymGroupE4 retainedGroup
: retainedGroups
){
55 taxonNameEditor
.removeGroup(retainedGroup
);
60 public static HomotypicalSynonymGroupE4
createOrUpdateHeterotypicSynonymyGroup(
61 TaxonNameEditorE4 taxonNameEditor
, HomotypicalGroup homotypicalGroup
){
62 HomotypicalSynonymGroupE4 group
= null;
63 if(taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
) == null){
64 group
= new HomotypicalSynonymGroupE4(taxonNameEditor
, homotypicalGroup
);
65 taxonNameEditor
.addHeterotypicSynonymGroup(group
);
66 if(taxonNameEditor
.getMisappliedGroup() != null){
67 group
.getControl().moveAbove(taxonNameEditor
.getMisappliedGroup().getControl());
71 group
= taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
72 group
.redraw(homotypicalGroup
);
78 public static void createOrUpdateMisapplicationsGroup(
79 TaxonNameEditorE4 taxonNameEditor
) {
80 MisappliedGroupE4 group
= taxonNameEditor
.getMisappliedGroup();
81 Taxon taxon
= HibernateProxyHelper
.deproxy(taxonNameEditor
.getTaxon(), Taxon
.class);
83 if(taxon
.getMisappliedNames(true).isEmpty() && taxon
.getProParteAndPartialSynonyms().isEmpty()){
84 taxonNameEditor
.removeGroup(group
);
85 taxonNameEditor
.setMisapplicationsGroup(null);
88 taxonNameEditor
.setMisapplicationsGroup(new MisappliedGroupE4(taxonNameEditor
));
96 public static void setMenuToAllContainers(TaxonNameEditorE4 taxonNameEditor
){
97 if (taxonNameEditor
== null) {
100 if (taxonNameEditor
.getAcceptedGroup() != null){
101 taxonNameEditor
.getAcceptedGroup().setMenuToGroup();
103 if (taxonNameEditor
.getTaxon() != null){
104 for(HomotypicalGroup homotypicalGroup
: taxonNameEditor
.getTaxon().getHeterotypicSynonymyGroups()){
105 homotypicalGroup
= HibernateProxyHelper
.deproxy(homotypicalGroup
, HomotypicalGroup
.class);
106 HomotypicalSynonymGroupE4 group
= taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
108 group
.setMenuToGroup();
111 if (taxonNameEditor
.getMisappliedGroup() != null){
112 taxonNameEditor
.getMisappliedGroup().setMenuToGroup();