Project

General

Profile

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

    
11
package eu.etaxonomy.taxeditor.editor.name.container;
12

    
13
import java.util.ArrayList;
14
import java.util.List;
15

    
16
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
17
import eu.etaxonomy.cdm.model.taxon.Synonym;
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
20

    
21
/**
22
 * @author n.hoffmann
23
 * @created Jan 21, 2011
24
 * @version 1.0
25
 */
26
public abstract class AbstractHomotypicalGroupContainer extends AbstractGroup {
27

    
28
	private HomotypicalGroup group;
29
	
30
	/**
31
	 * @param editor
32
	 */
33
	public AbstractHomotypicalGroupContainer(TaxonNameEditor editor, HomotypicalGroup group) {
34
		super(editor);
35
		this.group = group;
36

    
37
		createContent();
38
	}
39

    
40
	protected abstract void createSynonymContainer();
41
	
42
	protected List<Synonym> getSynonyms(){
43
		Taxon taxon = getEditor().getTaxon();
44
		return taxon.getSynonymsInGroup(getGroup());
45
//		return getGroup().getSynonymsInGroup(getEditor().getTaxon().getSec());
46
	}
47
	
48
	/**
49
	 * @param group the group to set
50
	 */
51
	public void setGroup(HomotypicalGroup group) {
52
		this.group = group;
53
	}
54

    
55
	public void redraw(HomotypicalGroup homotypicalGroup){
56
		if(redrawNeeded(homotypicalGroup)){
57
			setGroup(homotypicalGroup);
58
			redraw();
59
		}
60
	}
61

    
62
	/**
63
	 * 
64
	 * @param homotypicalGroup
65
	 * @return
66
	 */
67
	protected boolean redrawNeeded(HomotypicalGroup homotypicalGroup) {
68
		//List<Synonym> synonyms = homotypicalGroup.getSynonymsInGroup(getEditor().getTaxon().getSec());
69
				
70
		Taxon taxon = getEditor().getTaxon();
71
		List<Synonym> synonyms = taxon.getSynonymsInGroup(homotypicalGroup);
72
		
73
		List<Synonym> presentSynonyms = new ArrayList<Synonym>();
74
		
75
		for(AbstractGroupedContainer container : getGroupedContainers()){
76
			if(container.getData() instanceof Synonym){
77
				presentSynonyms.add((Synonym) container.getData());
78
			}
79
		}
80
				
81
		boolean result = ! (presentSynonyms.containsAll(synonyms) && synonyms.containsAll(presentSynonyms));
82
		
83
		return result;
84
	}
85
	
86
	/**
87
	 * @return the group
88
	 */
89
	public HomotypicalGroup getGroup() {
90
		return group;
91
	}
92
}
(3-3/19)