Project

General

Profile

Download (1.88 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.editor.name.e4.container;
11

    
12
import java.util.HashSet;
13
import java.util.Set;
14

    
15
import eu.etaxonomy.cdm.model.taxon.Taxon;
16
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonEditor;
17

    
18
/**
19
 * @author pplitzner
20
 * @date Aug 24, 2017
21
 */
22
public class MisappliedGroup extends AbstractGroup{
23

    
24
    protected enum ConceptType {
25
        Misapplication,
26
        Synonym
27
    }
28

    
29

    
30
	public MisappliedGroup(TaxonEditor editor) {
31
		super(editor);
32

    
33
		createContent();
34
	}
35

    
36
	@Override
37
	protected void createContainers() {
38

    
39
		for(Taxon proParteSynonym : getEditor().getTaxon().getAllProParteSynonyms()){
40
            ConceptContainer container = new ConceptContainer(this, proParteSynonym, ConceptType.Synonym);
41
            this.add(container);
42
            container.createContent();
43
        }
44

    
45

    
46
		for(Taxon misapplication : getEditor().getTaxon().getAllMisappliedNames()){
47

    
48
            ConceptContainer container = new ConceptContainer(this, misapplication, ConceptType.Misapplication);
49
            this.add(container);
50
            container.createContent();
51
        }
52
	}
53

    
54
	@Override
55
	public void redraw() {
56
		if(redrawNeeded()){
57
			super.redraw();
58
		}else{
59
		    super.setMenuToGroup();
60
		}
61
	}
62

    
63
	private boolean redrawNeeded() {
64
		Set<Taxon> concepts = getEditor().getTaxon().getMisappliedNames(true);
65
		concepts.addAll(getEditor().getTaxon().getProParteAndPartialSynonyms());
66

    
67
		Set<Taxon> presentConcepts = new HashSet<>();
68

    
69
		for (AbstractGroupedContainer<Taxon> container  : getGroupedContainers()){
70
		    presentConcepts.add(container.getData());
71
		}
72
		return ! (presentConcepts.containsAll(concepts) && concepts.containsAll(presentConcepts));
73
	}
74
}
(9-9/11)