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
.ui
.section
.name
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.graphics
.Color
;
15 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
17 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
18 import eu
.etaxonomy
.taxeditor
.preference
.NameDetailsConfigurator
;
19 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermComboElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.LabelElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AbstractReferencedEntityElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
29 * <p>NameRelationshipDetailElement class.</p>
32 * @created Mar 18, 2010
34 public class NameRelationshipDetailElement
extends AbstractReferencedEntityElement
<NameRelationship
>{
36 private RuleConsideredElement ruleConsidered
;
37 private EntitySelectionElement
<?
> selection_toName
;
38 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
39 private LabelElement label
;
42 * <p>Constructor for NameRelationshipDetailElement.</p>
44 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
45 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
46 * @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
47 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
50 public NameRelationshipDetailElement(CdmFormFactory cdmFormFactory
,
51 AbstractFormSection formElement
,
52 NameRelationship entity
, SelectionListener removeListener
, int style
) {
53 super(cdmFormFactory
, formElement
, entity
, removeListener
, style
);
57 public void createControls(ICdmFormElement element
, int style
) {
58 NameDetailsConfigurator config
= PreferencesUtil
.getPreferredNameDetailsConfiguration();
59 label
= formFactory
.createLabel(element
, null);
60 if (config
== null || config
.isNameRelationsRuleConsideredActivated()){
61 ruleConsidered
= formFactory
.createRuleConsideredElement(
62 element
, "Rule Considered", config
== null
63 || config
.isNameRelationsRuleConsideredCodeEditionActivated(), style
);
65 super.createControls(element
, style
);
69 public void setEntity(NameRelationship entity
) {
70 String text
= entity
.getFromName().getTitleCache() + " is " + entity
.getType().getLabel() + " " + entity
.getToName().getTitleCache();
73 if (ruleConsidered
!= null){
74 ruleConsidered
.setElement(entity
);
76 super.setEntity(entity
);
80 public void handleEvent(Object eventSource
) {
81 if(eventSource
== combo_relationshipType
){
82 getEntity().setType(combo_relationshipType
.getSelection());
84 else if(eventSource
== selection_toName
){
85 MessagingUtils
.error(getClass(), "No API call available.", null);
87 else if(eventSource
== selection_reference
){
88 getEntity().setCitation(selection_reference
.getSelection());
90 else if(eventSource
== text_referenceDetail
){
91 getEntity().setCitationMicroReference(text_referenceDetail
.getText());
96 public void setBackground(Color color
) {
98 label
.setBackground(color
);
100 super.setBackground(color
);