Project

General

Profile

Download (3 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
import eu.etaxonomy.taxeditor.singlesource.editor.name.container.EditorAnnotationFacade;
20

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

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

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

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

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

    
114

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

    
123
}
(15-15/19)