Project

General

Profile

Download (2.68 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 org.eclipse.swt.graphics.Font;
13

    
14
import eu.etaxonomy.cdm.model.taxon.Taxon;
15
import eu.etaxonomy.taxeditor.editor.EditorUtil;
16
import eu.etaxonomy.taxeditor.preference.Resources;
17

    
18
/**
19
 * <p>MisapplicationContainer class.</p>
20
 *
21
 * @author p.ciardelli
22
 * @created 13.01.2009
23
 * @version 1.0
24
 */
25
public class MisapplicationContainer extends AbstractGroupedContainer<Taxon> {
26

    
27
	/**
28
	 * <p>Constructor for MisapplicationContainer.</p>
29
	 *
30
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
31
	 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
32
	 * @param misappliedName a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
33
	 */
34
	public MisapplicationContainer(AbstractGroup group, Taxon misappliedName) {
35
		super(misappliedName);
36
	}
37

    
38

    
39
	/* (non-Javadoc)
40
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
41
	 */
42
	/** {@inheritDoc} */
43
	@Override
44
	protected void initializeComposite() {
45
		setIsDraggable(true);
46
		setFont(getViewerFont());
47

    
48
		showSec();
49

    
50
		initTextViewer();
51
	}
52

    
53
	@Override
54
	protected void updateIcon() {
55
		setIcon(MISAPPLIEDNAME_ICON);
56
	}
57

    
58
	private void showSec() {
59
		if (getMisappliedName() == null) {
60
			return;
61
		}
62

    
63
		if (getMisappliedName().getSec() == null) {
64
			setNonEditableInfo("sec. ???", false);
65
		} else {
66
			String title = getMisappliedName().getSec().getTitleCache();
67
			title = title.replace("&", "&&");
68
			setNonEditableInfo("sec. " + title, false);
69
		}
70
	}
71

    
72
	/**
73
	 * <p>getMisappliedName</p>
74
	 *
75
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
76
	 */
77
	public Taxon getMisappliedName() {
78
		return getTaxonBase();
79
	}
80

    
81
	/** {@inheritDoc} */
82
	@Override
83
	protected Font getViewerFont() {
84
		return EditorUtil.getFont(Resources.MISAPPLIEDNAME_FONT);
85
	}
86

    
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer#showAnnotations()
89
	 */
90
	@Override
91
	public void showAnnotations() {
92
		if(getData().getSec() == null){
93
			getNameViewer().addAnnotation(
94
					new EditorAnnotation(0, "This misapplication requires a sec. reference."));
95
		}
96
		super.showAnnotations();
97
	}
98

    
99

    
100
	/** {@inheritDoc} */
101
	@Override
102
	protected void updateNonEditableInfo() {
103
		showSec();
104
	}
105

    
106

    
107
	/* (non-Javadoc)
108
	 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer#updateIndent()
109
	 */
110
	@Override
111
	protected void updateIndent() {
112
		setIndent(MISAPPLIEDNAME_INDENT);
113
	}
114

    
115
}
(15-15/19)