Project

General

Profile

Download (2 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.TaxonNameEditorE4;
17

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

    
26
	public MisappliedGroupE4(TaxonNameEditorE4 editor) {
27
		super(editor);
28

    
29
		createContent();
30
	}
31

    
32
	@Override
33
	protected void createContainers() {
34

    
35
		for(Taxon misapplication : getEditor().getTaxon().getAllProParteSynonyms()){
36
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, false);
37
            this.add(container);
38
            container.createContent();
39
        }
40
		for(Taxon invalidDes : getEditor().getTaxon().getInvalidDesignations()){
41

    
42
            ConceptContainerE4 container = new ConceptContainerE4(this, invalidDes, true);
43
            this.add(container);
44
            container.createContent();
45
        }
46

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

    
49
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, true);
50
            this.add(container);
51
            container.createContent();
52
        }
53
	}
54

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

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

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

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