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
.TaxonEditor
;
20 public class ContainerFactory
{
22 public static void createOrUpdateAcceptedTaxonsHomotypicGroup(
23 TaxonEditor taxonEditor
) {
25 if(taxonEditor
.getAcceptedGroup() == null){
26 taxonEditor
.setAcceptedGroup(new AcceptedGroup(taxonEditor
, taxonEditor
.getTaxon().getHomotypicGroup()));
29 taxonEditor
.getAcceptedGroup().redraw(taxonEditor
.getTaxon().getHomotypicGroup());
34 public static void createOrUpdateHeterotypicSynonymyGroups(
35 TaxonEditor taxonEditor
) {
36 List
<HomotypicalSynonymGroup
> retainedGroups
= new ArrayList
<>();
38 List
<HomotypicalSynonymGroup
> heterotypicSynonymGroups
= taxonEditor
.getHeterotypicSynonymGroups();
40 if (heterotypicSynonymGroups
!= null) {
42 for(HomotypicalSynonymGroup group
: heterotypicSynonymGroups
){
43 retainedGroups
.add(group
);
47 for(HomotypicalGroup homotypicalGroup
: taxonEditor
.getTaxon().getHeterotypicSynonymyGroups()){
48 homotypicalGroup
= HibernateProxyHelper
.deproxy(homotypicalGroup
, HomotypicalGroup
.class);
49 HomotypicalSynonymGroup group
= createOrUpdateHeterotypicSynonymyGroup(taxonEditor
, homotypicalGroup
);
51 retainedGroups
.remove(group
);
54 for(HomotypicalSynonymGroup retainedGroup
: retainedGroups
){
55 taxonEditor
.removeGroup(retainedGroup
);
60 public static HomotypicalSynonymGroup
createOrUpdateHeterotypicSynonymyGroup(
61 TaxonEditor taxonEditor
, HomotypicalGroup homotypicalGroup
){
62 HomotypicalSynonymGroup group
= null;
63 if(taxonEditor
.getHomotypicalGroupContainer(homotypicalGroup
) == null){
64 group
= new HomotypicalSynonymGroup(taxonEditor
, homotypicalGroup
);
65 taxonEditor
.addHeterotypicSynonymGroup(group
);
66 if(taxonEditor
.getMisappliedGroup() != null){
67 group
.getControl().moveAbove(taxonEditor
.getMisappliedGroup().getControl());
71 group
= taxonEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
72 group
.redraw(homotypicalGroup
);
78 public static void createOrUpdateMisapplicationsGroup(
79 TaxonEditor taxonEditor
) {
80 MisappliedGroup group
= taxonEditor
.getMisappliedGroup();
81 Taxon taxon
= HibernateProxyHelper
.deproxy(taxonEditor
.getTaxon(), Taxon
.class);
83 if(taxon
.getMisappliedNames(true).isEmpty() && taxon
.getProParteAndPartialSynonyms().isEmpty()){
84 taxonEditor
.removeGroup(group
);
85 taxonEditor
.setMisapplicationsGroup(null);
88 taxonEditor
.setMisapplicationsGroup(new MisappliedGroup(taxonEditor
));
96 public static void setMenuToAllContainers(TaxonEditor taxonEditor
){
97 if (taxonEditor
== null) {
100 if (taxonEditor
.getAcceptedGroup() != null){
101 taxonEditor
.getAcceptedGroup().setMenuToGroup();
103 if (taxonEditor
.getTaxon() != null){
104 for(HomotypicalGroup homotypicalGroup
: taxonEditor
.getTaxon().getHeterotypicSynonymyGroups()){
105 homotypicalGroup
= HibernateProxyHelper
.deproxy(homotypicalGroup
, HomotypicalGroup
.class);
106 HomotypicalSynonymGroup group
= taxonEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
108 group
.setMenuToGroup();
111 if (taxonEditor
.getMisappliedGroup() != null){
112 taxonEditor
.getMisappliedGroup().setMenuToGroup();