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
.container
;
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
.editor
.l10n
.Messages
;
19 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
20 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
23 * <p>ConceptContainer class.</p>
29 public class ConceptContainer
extends AbstractGroupedContainer
<Taxon
> {
31 private final TaxonRelationshipType relationshipType
;
34 private ConceptContainer(TaxonNameEditor editor
, AbstractGroup group
,
35 Taxon relatedTaxon
, TaxonRelationshipType relationshipType
,
36 boolean acceptedTaxonIsFromTaxon
) {
39 // FIXME the acceptedTaxonIsFromTaxon is never used and
40 // I can't remember what is was used for in the first place
42 this.relationshipType
= relationshipType
;
43 showRelationshipType();
47 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
51 protected void initializeComposite() {
54 setFont(getViewerFont());
62 protected void updateIcon() {
63 setIcon(CONCEPT_ICON
);
66 private void showRelationshipType() {
67 setNonEditableInfo(relationshipType
.getLabel(), true);
70 private void showSec() {
71 if (getTaxonBase() == null) {
75 if (getTaxonBase().getSec() == null) {
76 setNonEditableInfo("sec. ???", false); //$NON-NLS-1$
78 setNonEditableInfo("sec. " + getTaxonBase().getSec().getTitleCache(), false); //$NON-NLS-1$
83 * <p>getNewInstance</p>
85 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
86 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup} object.
87 * @param relationship a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationship} object.
88 * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.ConceptContainer} object.
90 public static ConceptContainer
getNewInstance(TaxonNameEditor editor
, AbstractGroup group
, TaxonRelationship relationship
){
92 TaxonRelationshipType relationshipType
= relationship
.getType();
94 if (relationship
.getToTaxon().equals(editor
.getTaxon())) {
95 return new ConceptContainer (editor
, group
,
96 relationship
.getFromTaxon(), relationshipType
, false);
98 return new ConceptContainer (editor
, group
,
99 relationship
.getToTaxon(), relationshipType
, true);
104 * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#getViewerFont()
108 protected Font
getViewerFont() {
109 return EditorUtil
.getFont(Resources
.CONCEPT_FONT
);
113 * <p>getRelatedTaxon</p>
115 * @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
117 public Taxon
getRelatedTaxon() {
118 return getTaxonBase();
122 * @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer#showAnnotations()
125 public void showAnnotations() {
126 if(getData().getSec() == null){
127 getNameViewer().addAnnotation(
128 new EditorAnnotation(0, Messages
.ConceptContainer_SEC_REQUIRED
));
130 super.showAnnotations();
135 protected void updateNonEditableInfo() {
137 showRelationshipType();
141 * @see eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer#updateIndent()
144 protected void updateIndent() {
145 setIndent(CONCEPT_INDENT
);