Project

General

Profile

Download (3.54 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.Set;
13

    
14
import org.eclipse.swt.graphics.Font;
15
import org.eclipse.swt.graphics.Image;
16

    
17
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
18
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
19
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
20
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22
import eu.etaxonomy.taxeditor.editor.EditorUtil;
23
import eu.etaxonomy.taxeditor.preference.Resources;
24

    
25
/**
26
 * <p>SynonymContainer class.</p>
27
 *
28
 * @author p.ciardelli
29
 * @created 13.01.2009
30
 * @version 1.0
31
 */
32
public class SynonymContainer extends AbstractGroupedContainer<Synonym> {
33

    
34
	private int indent = SYNONYM_INDENT;
35
	private Image icon = HETEROTYPIC_SYNONYM_ICON;
36

    
37
	/**
38
	 * <p>Constructor for SynonymContainer.</p>
39
	 *
40
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
41
	 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
42
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
43
	 */
44
	public SynonymContainer(AbstractHomotypicalGroupContainer group, Synonym synonym) {
45
		super(synonym);
46
	}
47
	
48
	public SynonymContainer(AbstractHomotypicalGroupContainer group, Synonym synonym, int indent, Image icon){
49
		super(synonym);
50
		this.indent = indent;
51
		this.icon = icon;
52
	}
53
	
54
	/* (non-Javadoc)
55
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
56
	 */
57
	/** {@inheritDoc} */
58
	@Override
59
	protected void initializeComposite() {
60
		setIsDraggable(true);
61
		setFont(getViewerFont());
62
		
63
		if(getName() == null){
64
			EditorUtil.warn(getClass(), "Synonym with a null name detected. This should never happen.");
65
		}
66
		
67
		initTextViewer();
68
	}
69
	
70
	protected void updateIcon(){
71
		TaxonNameBase name = getName();
72
		
73
		if(! name.getStatus().isEmpty()){
74
			
75
			Set<NomenclaturalStatus> allStatus = name.getStatus();
76
			
77
			for (NomenclaturalStatus status : allStatus){
78
				if(status.getType() != null && (status.getType().equals(NomenclaturalStatusType.INVALID()) || status.getType().equals(NomenclaturalStatusType.NUDUM()))){
79
					setIcon(INVALID_OR_NUDUM_NAME_ICON);
80
					return;
81
				}
82
			}
83
		}
84
		
85
		if (isHomotypic()) {
86
			if(name.isGroupsBasionym()){
87
				setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
88
			}else{
89
				setIcon(HOMOTYPIC_SYNONYM_ICON);
90
			}
91
			
92
			return;
93
		} else{
94
			if(name.isGroupsBasionym()){
95
				setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
96
				return;
97
			}
98
		}	
99
				
100
		setIcon(icon);
101
		
102
	}
103
	
104
	private boolean isHomotypic() {
105
		HomotypicalGroup group = getSynonym().getHomotypicGroup();
106
		return group.equals(getEditor().getTaxon().getHomotypicGroup()); 
107
	}
108
	
109
	/**
110
	 * <p>getSynonym</p>
111
	 *
112
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
113
	 */
114
	public Synonym getSynonym() {
115
		return getTaxonBase();
116
	}
117
		
118

    
119
	/**
120
	 * <p>getViewerFont</p>
121
	 *
122
	 * @return a {@link org.eclipse.swt.graphics.Font} object.
123
	 */
124
	protected Font getViewerFont() {
125
		return EditorUtil.getFont(Resources.SYNONYM_FONT);
126
	}
127

    
128
	/** {@inheritDoc} */
129
	@Override
130
	protected void updateNonEditableInfo() {
131
		// not needed
132
	}
133

    
134
	/* (non-Javadoc)
135
	 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer#updateIndent()
136
	 */
137
	@Override
138
	protected void updateIndent() {		
139
		setIndent(this.indent );
140
	}
141
}
(19-19/19)