3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.events
.SelectionListener
;
15 import org
.eclipse
.swt
.graphics
.Color
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
19 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
20 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.LabelElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AbstractReferencedEntityElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
30 * <p>NameRelationshipDetailElement class.</p>
33 * @created Mar 18, 2010
36 public class NameRelationshipDetailElement
extends AbstractReferencedEntityElement
<NameRelationship
>{
38 private TextWithLabelElement text_ruleConsidered
;
39 private EntitySelectionElement selection_toName
;
40 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
41 private LabelElement label
;
44 * <p>Constructor for NameRelationshipDetailElement.</p>
46 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
47 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
48 * @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
49 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
52 public NameRelationshipDetailElement(CdmFormFactory cdmFormFactory
,
53 AbstractFormSection formElement
,
54 NameRelationship entity
, SelectionListener removeListener
, int style
) {
55 super(cdmFormFactory
, formElement
, entity
, removeListener
, style
);
59 * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
63 public void createControls(ICdmFormElement element
, int style
) {
64 label
= formFactory
.createLabel(element
, null);
66 text_ruleConsidered
= formFactory
.createTextWithLabelElement(element
, "Rule Considered", null, SWT
.NULL
);
68 super.createControls(element
, style
);
73 public void setEntity(NameRelationship entity
) {
74 String text
= entity
.getFromName().getTitleCache() + " is " + entity
.getType().getLabel() + " " + entity
.getToName().getTitleCache();
77 text_ruleConsidered
.setText(entity
.getRuleConsidered());
79 super.setEntity(entity
);
84 public void handleEvent(Object eventSource
) {
85 if(eventSource
== combo_relationshipType
){
86 getEntity().setType(combo_relationshipType
.getSelection());
88 else if(eventSource
== selection_toName
){
89 StoreUtil
.error(getClass(), "No API call available.", null);
91 else if(eventSource
== text_ruleConsidered
){
92 getEntity().setRuleConsidered(text_ruleConsidered
.getText());
94 else if(eventSource
== selection_reference
){
95 getEntity().setCitation(selection_reference
.getSelection());
97 else if(eventSource
== text_referenceDetail
){
98 getEntity().setCitationMicroReference(text_referenceDetail
.getText());
104 public void setBackground(Color color
) {
106 label
.setBackground(color
);
107 super.setBackground(color
);