2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
;
12 import org
.eclipse
.swt
.graphics
.Font
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
17 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
18 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
21 * <p>ConceptContainer class.</p>
27 public class ConceptContainer
extends AbstractGroupedContainer
<Taxon
> {
29 private TaxonRelationshipType relationshipType
;
32 private ConceptContainer(TaxonNameEditor editor
, AbstractGroup group
,
33 Taxon relatedTaxon
, TaxonRelationshipType relationshipType
,
34 boolean acceptedTaxonIsFromTaxon
) {
35 super(editor
, group
, relatedTaxon
);
37 // FIXME the acceptedTaxonIsFromTaxon is never used and
38 // I can't remember what is was used for in the first place
40 this.relationshipType
= relationshipType
;
41 showRelationshipType();
45 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
49 protected void initializeComposite() {
52 setFont(getViewerFont());
60 protected void updateIcon() {
61 setIcon(CONCEPT_ICON
);
64 private void showRelationshipType() {
65 setNonEditableInfo(relationshipType
.getLabel(), true);
68 private void showSec() {
69 if (getTaxonBase() == null) {
73 if (getTaxonBase().getSec() == null) {
74 setNonEditableInfo("sec. ???", false);
76 setNonEditableInfo("sec. " + getTaxonBase().getSec().getTitleCache(), false);
81 * <p>getNewInstance</p>
83 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
84 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.AbstractGroup} object.
85 * @param relationship a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationship} object.
86 * @return a {@link eu.etaxonomy.taxeditor.editor.name.ConceptContainer} object.
88 public static ConceptContainer
getNewInstance(TaxonNameEditor editor
, AbstractGroup group
, TaxonRelationship relationship
){
90 TaxonRelationshipType relationshipType
= relationship
.getType();
92 if (relationship
.getToTaxon().equals(editor
.getTaxon())) {
93 return new ConceptContainer (editor
, group
,
94 relationship
.getFromTaxon(), relationshipType
, false);
96 return new ConceptContainer (editor
, group
,
97 relationship
.getToTaxon(), relationshipType
, true);
102 * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#getViewerFont()
106 protected Font
getViewerFont() {
107 return EditorUtil
.getFont(Resources
.CONCEPT_FONT
);
111 * <p>getRelatedTaxon</p>
113 * @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
115 public Taxon
getRelatedTaxon() {
116 return getTaxonBase();
120 * <p>calculateErrors</p>
122 protected void calculateErrors() {
123 super.calculateErrors();
125 nameViewer
.setShowSecError(getTaxonBase());
130 protected void updateNonEditableInfo() {
132 showRelationshipType();
136 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer#updateIndent()
139 protected void updateIndent() {
140 setIndent(CONCEPT_INDENT
);