Project

General

Profile

« Previous | Next » 

Revision 3be6ef3e

Added by Niels Hoffmann over 13 years ago

performed javacscript:fix and worked on documentation

View differences:

taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/SynonymContainer.java
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;
11

  
12
import org.apache.log4j.Logger;
13
import org.eclipse.swt.graphics.Font;
14

  
15
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
16
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
17
import eu.etaxonomy.cdm.model.taxon.Synonym;
18
import eu.etaxonomy.taxeditor.editor.EditorUtil;
19
import eu.etaxonomy.taxeditor.preference.Resources;
20

  
21
/**
22
 * @author p.ciardelli
23
 * @created 13.01.2009
24
 * @version 1.0
25
 */
26
public class SynonymContainer extends AbstractGroupedContainer<Synonym> {
27
	@SuppressWarnings("unused")
28
	private static final Logger logger = Logger
29
			.getLogger(SynonymContainer.class);
30
	
31
	public SynonymContainer(TaxonNameEditor editor, AbstractGroup group, Synonym synonym) {
32
		super(editor, group, synonym);
33
	}
34
	
35
	/* (non-Javadoc)
36
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
37
	 */
38
	@Override
39
	protected void initializeComposite() {
40
		setIsDraggable(true);
41
		setFont(getViewerFont());
42
		setIndent(SYNONYM_INDENT);
43
		
44
		TaxonNameBase name = getSynonym().getName();
45
		
46
		if(name == null){
47
			logger.error("Synonym with a null name detected. This should never happen.");
48
		}
49
		
50
		if (isHomotypic()) {
51
			if (name.isGroupsBasionym()) {
52
				setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
53
			} else {
54
				setIcon(HOMOTYPIC_SYNONYM_ICON);
55
			}	
56
		} else {
57
			if (name.isGroupsBasionym()) {
58
				setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
59
			} else {
60
				setIcon(HETEROTYPIC_SYNONYM_ICON);
61
			}
62
		}
63
		
64
		initTextViewer();
65
	}
66
	
67
	private boolean isHomotypic() {
68
		HomotypicalGroup group = getSynonym().getHomotypicGroup();
69
		return group.equals(editor.getTaxon().getHomotypicGroup()); 
70
	}
71
	
72
	public Synonym getSynonym() {
73
		return getTaxonBase();
74
	}
75
		
76

  
77
	protected Font getViewerFont() {
78
		return EditorUtil.getFont(Resources.SYNONYM_FONT);
79
	}
80

  
81
	@Override
82
	protected void updateNonEditableInfo() {
83
		// not needed
84
	}
85
}
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;
11

  
12
import org.apache.log4j.Logger;
13
import org.eclipse.swt.graphics.Font;
14

  
15
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
16
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
17
import eu.etaxonomy.cdm.model.taxon.Synonym;
18
import eu.etaxonomy.taxeditor.editor.EditorUtil;
19
import eu.etaxonomy.taxeditor.preference.Resources;
20

  
21
/**
22
 * <p>SynonymContainer class.</p>
23
 *
24
 * @author p.ciardelli
25
 * @created 13.01.2009
26
 * @version 1.0
27
 */
28
public class SynonymContainer extends AbstractGroupedContainer<Synonym> {
29
	@SuppressWarnings("unused")
30
	private static final Logger logger = Logger
31
			.getLogger(SynonymContainer.class);
32
	
33
	/**
34
	 * <p>Constructor for SynonymContainer.</p>
35
	 *
36
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
37
	 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.AbstractGroup} object.
38
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
39
	 */
40
	public SynonymContainer(TaxonNameEditor editor, AbstractGroup group, Synonym synonym) {
41
		super(editor, group, synonym);
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
46
	 */
47
	/** {@inheritDoc} */
48
	@Override
49
	protected void initializeComposite() {
50
		setIsDraggable(true);
51
		setFont(getViewerFont());
52
		setIndent(SYNONYM_INDENT);
53
		
54
		TaxonNameBase name = getSynonym().getName();
55
		
56
		if(name == null){
57
			logger.error("Synonym with a null name detected. This should never happen.");
58
		}
59
		
60
		if (isHomotypic()) {
61
			if (name.isGroupsBasionym()) {
62
				setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
63
			} else {
64
				setIcon(HOMOTYPIC_SYNONYM_ICON);
65
			}	
66
		} else {
67
			if (name.isGroupsBasionym()) {
68
				setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON);
69
			} else {
70
				setIcon(HETEROTYPIC_SYNONYM_ICON);
71
			}
72
		}
73
		
74
		initTextViewer();
75
	}
76
	
77
	private boolean isHomotypic() {
78
		HomotypicalGroup group = getSynonym().getHomotypicGroup();
79
		return group.equals(editor.getTaxon().getHomotypicGroup()); 
80
	}
81
	
82
	/**
83
	 * <p>getSynonym</p>
84
	 *
85
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
86
	 */
87
	public Synonym getSynonym() {
88
		return getTaxonBase();
89
	}
90
		
91

  
92
	/**
93
	 * <p>getViewerFont</p>
94
	 *
95
	 * @return a {@link org.eclipse.swt.graphics.Font} object.
96
	 */
97
	protected Font getViewerFont() {
98
		return EditorUtil.getFont(Resources.SYNONYM_FONT);
99
	}
100

  
101
	/** {@inheritDoc} */
102
	@Override
103
	protected void updateNonEditableInfo() {
104
		// not needed
105
	}
106
}

Also available in: Unified diff