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
.apache
.log4j
.Logger
;
13 import org
.eclipse
.swt
.graphics
.Font
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
17 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
21 import eu
.etaxonomy
.taxeditor
.propertysheet
.name
.ConceptPropertySource
;
28 public class ConceptComposite
extends NameComposite
{
29 private static final Logger logger
= Logger
30 .getLogger(ConceptComposite
.class);
32 private Taxon relatedTaxon
;
33 private TaxonRelationshipType relationshipType
;
38 private boolean acceptedTaxonIsFromTaxon
;
40 private ConceptComposite(TaxonNameEditor editor
, Composite parent
,
41 Taxon relatedTaxon
, TaxonRelationshipType relationshipType
,
42 boolean acceptedTaxonIsFromTaxon
) {
43 super(editor
, parent
, NameComposite
.CONCEPTRELATION
, relatedTaxon
);
45 this.taxon
= editor
.getTaxon();
46 this.relatedTaxon
= relatedTaxon
;
47 this.relationshipType
= relationshipType
;
48 this.acceptedTaxonIsFromTaxon
= acceptedTaxonIsFromTaxon
;
51 setIcon(CONCEPT_ICON
);
52 setFont(getViewerFont());
53 setIndent(CONCEPT_INDENT
);
55 showRelationshipType();
58 initTextViewer(relatedTaxon
);
61 private void showRelationshipType() {
62 setNonEditableInfo(relationshipType
.getLabel());
65 private void showSec() {
66 if (relatedTaxon
== null) {
70 if (relatedTaxon
.getSec() == null) {
71 setNonEditableInfo("sec. ???");
73 setNonEditableInfo("sec. " + relatedTaxon
.getSec().getTitleCache());
77 public static ConceptComposite
getNewInstance(TaxonNameEditor editor
, Composite parent
, TaxonRelationship relationship
){
79 TaxonRelationshipType relationshipType
= relationship
.getType();
81 if (relationship
.getToTaxon().equals(editor
.getTaxon())) {
82 return new ConceptComposite (editor
, parent
,
83 relationship
.getFromTaxon(), relationshipType
, false);
85 return new ConceptComposite (editor
, parent
,
86 relationship
.getToTaxon(), relationshipType
, true);
91 * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#getViewerFont()
94 protected Font
getViewerFont() {
99 * @see eu.etaxonomy.taxeditor.editor.IHasPropertySource#getPropertySource()
102 public IPropertySource
getPropertySource() {
103 return new ConceptPropertySource(relatedTaxon
);
106 public Taxon
getRelatedTaxon() {
110 protected TaxonNameBase
getName() {
111 return relatedTaxon
.getName();
114 protected void calculateErrors() {
115 super.calculateErrors();
117 textViewer
.setShowSecError(relatedTaxon
);
120 public Object
getData () {
121 return getRelatedTaxon();