Project

General

Profile

Download (2.87 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 javax.naming.OperationNotSupportedException;
13

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

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

    
20
/**
21
 * <p>MisapplicationContainer class.</p>
22
 *
23
 * @author p.ciardelli
24
 * @created 13.01.2009
25
 * @version 1.0
26
 */
27
public class MisapplicationContainer extends AbstractGroupedContainer<Taxon> {
28
	
29
	/**
30
	 * <p>Constructor for MisapplicationContainer.</p>
31
	 *
32
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
33
	 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
34
	 * @param misappliedName a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
35
	 */
36
	public MisapplicationContainer(AbstractGroup group, Taxon misappliedName) {
37
		super(misappliedName);
38
	}
39
	
40

    
41
	/* (non-Javadoc)
42
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
43
	 */
44
	/** {@inheritDoc} */
45
	@Override
46
	protected void initializeComposite() {
47
		setIsDraggable(true);
48
		setFont(getViewerFont());
49
		
50
		try {
51
			showSec();
52
		} catch (OperationNotSupportedException e) {
53
		}		
54
		
55
		initTextViewer();
56
	}
57

    
58
	@Override
59
	protected void updateIcon() {
60
		setIcon(MISAPPLIEDNAME_ICON);
61
	}
62
	
63
	private void showSec() throws OperationNotSupportedException {
64
		if (getMisappliedName() == null) {
65
			return;
66
		}
67
		
68
		if (getMisappliedName().getSec() == null) {
69
			setNonEditableInfo("sec. ???", false);
70
		} else {
71
			String title = getMisappliedName().getSec().getTitleCache();
72
			setNonEditableInfo("sec. " + title, false);
73
		}
74
	}
75
	
76
	/**
77
	 * <p>getMisappliedName</p>
78
	 *
79
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
80
	 */
81
	public Taxon getMisappliedName() {
82
		return getTaxonBase();
83
	}
84

    
85
	/** {@inheritDoc} */
86
	@Override
87
	protected Font getViewerFont() {
88
		return EditorUtil.getFont(Resources.MISAPPLIEDNAME_FONT);
89
	}
90
	
91
	/* (non-Javadoc)
92
	 * @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer#showAnnotations()
93
	 */
94
	@Override
95
	public void showAnnotations() {
96
		if(getData().getSec() == null){
97
			getNameViewer().addAnnotation(
98
					new EditorAnnotation(0, "This misapplication requires a sec. reference."));
99
		}
100
		super.showAnnotations();
101
	}
102
	
103

    
104
	/** {@inheritDoc} */
105
	@Override
106
	protected void updateNonEditableInfo() {
107
		try {
108
			showSec();
109
		} catch (OperationNotSupportedException e) {
110
		}
111
	}
112

    
113

    
114
	/* (non-Javadoc)
115
	 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer#updateIndent()
116
	 */
117
	@Override
118
	protected void updateIndent() {
119
		setIndent(MISAPPLIEDNAME_INDENT);
120
	}
121

    
122
}
(15-15/19)