Project

General

Profile

Download (3.24 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.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.TaxonName;
20
import eu.etaxonomy.cdm.model.taxon.Synonym;
21
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
22
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23
import eu.etaxonomy.taxeditor.model.MessagingUtils;
24
import eu.etaxonomy.taxeditor.preference.Resources;
25

    
26
/**
27
 * <p>SynonymContainer class.</p>
28
 *
29
 * @author p.ciardelli
30
 * @created 13.01.2009
31
 */
32
public class SynonymContainerE4 extends AbstractGroupedContainerE4<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 SynonymContainerE4(AbstractHomotypicalGroupContainerE4 group, Synonym synonym) {
45
		super(group, synonym);
46
	}
47

    
48
	public SynonymContainerE4(AbstractHomotypicalGroupContainerE4 group, Synonym synonym, int indent, Image icon){
49
		super(group, synonym);
50
		this.indent = indent;
51
		this.icon = icon;
52
	}
53

    
54
	@Override
55
	protected void initializeComposite() {
56
		setIsDraggable(true);
57
		setFont(getViewerFont());
58

    
59
		if(getName() == null){
60
			MessagingUtils.warn(getClass(), Messages.SynonymContainer_SYNONYM_NULL_NAME);
61
		}
62

    
63
		initTextViewer();
64
	}
65

    
66
	@Override
67
    protected void updateIcon(){
68
		TaxonName name = getName();
69

    
70

    
71
		if(! name.getStatus().isEmpty()){
72

    
73
			Set<NomenclaturalStatus> allStatus = name.getStatus();
74

    
75
			for (NomenclaturalStatus status : allStatus){
76
				if(status.getType() != null && (status.getType().isInvalidType())){
77
					setIcon(INVALID_OR_NUDUM_NAME_ICON);
78
					return;
79
				}
80
			}
81
		}
82

    
83
		if (isHomotypic()) {
84
			if(name.isGroupsBasionym()){
85
				setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
86
			}else{
87
				setIcon(HOMOTYPIC_SYNONYM_ICON);
88
			}
89

    
90
			return;
91
		} else{
92
			if(name.isGroupsBasionym()){
93
				setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
94
				return;
95
			}
96
		}
97

    
98
		setIcon(icon);
99

    
100
	}
101

    
102
	private boolean isHomotypic() {
103
		HomotypicalGroup group = getSynonym().getHomotypicGroup();
104
		return group.equals(getEditor().getTaxon().getHomotypicGroup());
105
	}
106

    
107
	/**
108
	 * <p>getSynonym</p>
109
	 *
110
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
111
	 */
112
	public Synonym getSynonym() {
113
		return getTaxonBase();
114
	}
115

    
116

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

    
127
	@Override
128
	protected void updateNonEditableInfo() {
129
		// not needed
130
	}
131

    
132
	@Override
133
	protected void updateIndent() {
134
		setIndent(this.indent );
135
	}
136
}
(11-11/11)