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().getProParteAndPartialSynonyms()){
|
36
|
ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, false);
|
37
|
this.add(container);
|
38
|
container.createContent();
|
39
|
}
|
40
|
for(Taxon misapplication : getEditor().getTaxon().getMisappliedNames(true)){
|
41
|
|
42
|
ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, true);
|
43
|
this.add(container);
|
44
|
container.createContent();
|
45
|
}
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public void redraw() {
|
50
|
if(redrawNeeded()){
|
51
|
super.redraw();
|
52
|
}
|
53
|
}
|
54
|
|
55
|
private boolean redrawNeeded() {
|
56
|
Set<Taxon> concepts = getEditor().getTaxon().getMisappliedNames(true);
|
57
|
concepts.addAll(getEditor().getTaxon().getProParteAndPartialSynonyms());
|
58
|
|
59
|
Set<Taxon> presentConcepts = new HashSet<>();
|
60
|
|
61
|
for (AbstractGroupedContainerE4<Taxon> container : getGroupedContainers()){
|
62
|
presentConcepts.add(container.getData());
|
63
|
}
|
64
|
return ! (presentConcepts.containsAll(concepts) && concepts.containsAll(presentConcepts));
|
65
|
}
|
66
|
}
|