f6516ceacb58c31fcb3ccd95c14f8fd07acb024b
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / MisapplicationContainer.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.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.AbstractGroup} object.
32 * @param misappliedName a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
33 */
34 public MisapplicationContainer(TaxonNameEditor editor, AbstractGroup group, Taxon misappliedName) {
35 super(editor, group, 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 setIndent(MISAPPLIEDNAME_INDENT);
48
49 showSec();
50
51 initTextViewer();
52 }
53
54 @Override
55 protected void updateIcon() {
56 setIcon(MISAPPLIEDNAME_ICON);
57 }
58
59 private void showSec() {
60 if (getMisappliedName() == null) {
61 return;
62 }
63
64 if (getMisappliedName().getSec() == null) {
65 setNonEditableInfo("sec. ???", false);
66 } else {
67 String title = getMisappliedName().getSec().getTitleCache();
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 /**
88 * <p>calculateErrors</p>
89 */
90 protected void calculateErrors() {
91 super.calculateErrors();
92
93 nameViewer.setShowSecError(getMisappliedName());
94 }
95
96
97 /** {@inheritDoc} */
98 @Override
99 protected void updateNonEditableInfo() {
100 showSec();
101 }
102
103 }