Project

General

Profile

Download (3.03 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 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.TaxonEditor} 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(AbstractHomotypicalGroupContainer group, Synonym synonym) {
45
		super(group, synonym);
46
	}
47

    
48
	public SynonymContainerE4(AbstractHomotypicalGroupContainer 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
		if (name.isInvalid()){
71
			setIcon(INVALID_OR_NUDUM_NAME_ICON);
72
			return;
73
		}
74

    
75
		if (isHomotypic()) {
76
			if(name.isGroupsBasionym()){
77
				setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
78
			}else{
79
				setIcon(HOMOTYPIC_SYNONYM_ICON);
80
			}
81

    
82
			return;
83
		} else{
84
			if(name.isGroupsBasionym()){
85
				setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
86
				return;
87
			}
88
		}
89

    
90
		setIcon(icon);
91

    
92
	}
93

    
94
	private boolean isHomotypic() {
95
		HomotypicalGroup group = getSynonym().getHomotypicGroup();
96
		return group.equals(getEditor().getTaxon().getHomotypicGroup());
97
	}
98

    
99
	/**
100
	 * <p>getSynonym</p>
101
	 *
102
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
103
	 */
104
	public Synonym getSynonym() {
105
		return getTaxonBase();
106
	}
107

    
108

    
109
	/**
110
	 * <p>getViewerFont</p>
111
	 *
112
	 * @return a {@link org.eclipse.swt.graphics.Font} object.
113
	 */
114
	@Override
115
    protected Font getViewerFont() {
116
		return AbstractUtility.getFont(Resources.SYNONYM_FONT);
117
	}
118

    
119
	@Override
120
	protected void updateNonEditableInfo() {
121
		// not needed
122
	}
123

    
124
	@Override
125
	protected void updateIndent() {
126
		setIndent(this.indent );
127
	}
128
}
(11-11/11)