Project

General

Profile

Download (1.84 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.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.TaxonNameEditor;
17

    
18
/**
19
 * <p>MisappliedGroup class.</p>
20
 *
21
 * @author p.ciardelli
22
 * @created 13.01.2009
23
 * @version 1.0
24
 */
25
public class MisappliedGroup extends AbstractGroup{
26

    
27
	/**
28
	 * <p>Constructor for MisappliedGroup.</p>
29
	 *
30
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
31
	 */
32
	public MisappliedGroup(TaxonNameEditor editor) {
33
		super(editor);
34
		
35
		createContent();
36
	}
37

    
38
	/* (non-Javadoc)
39
	 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#createContents()
40
	 */
41
	@Override
42
	protected void createContainers() {
43
		for(Taxon misapplication : getEditor().getTaxon().getMisappliedNames()){
44
			MisapplicationContainer container = new MisapplicationContainer(this, misapplication);
45
			this.add(container);
46
			container.createContent();
47
		}
48
	}
49
	
50
	/* (non-Javadoc)
51
	 * @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup#redraw()
52
	 */
53
	@Override
54
	public void redraw() {
55
		if(redrawNeeded()){
56
			super.redraw();
57
		}
58
	}
59

    
60
	/**
61
	 * @return
62
	 */
63
	private boolean redrawNeeded() {
64
		Set<Taxon> misapplications = getEditor().getTaxon().getMisappliedNames();
65
				
66
		Set<Taxon> presentMisapplication = new HashSet<Taxon>(); 
67
		
68
		for (AbstractGroupedContainer<Taxon> container  : getGroupedContainers()){
69
			presentMisapplication.add(container.getData());
70
		}
71
		return ! (presentMisapplication.containsAll(misapplications) && misapplications.containsAll(presentMisapplication));
72
	}
73
}
(16-16/19)