Merge branch 'release/5.11.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NameRelationshipDetailElement.java
index 1cd513759b46599eb5df71539c669c2e8a165ad4..b70405da31b62f14593d1cbb2dc9686027ec5fb9 100644 (file)
@@ -9,19 +9,19 @@
 
 package eu.etaxonomy.taxeditor.ui.section.name;
 
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 
 import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.LabelElement;
-import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 
@@ -34,7 +34,7 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  */
 public class NameRelationshipDetailElement extends AbstractReferencedEntityElement<NameRelationship>{
 
-       private TextWithLabelElement text_ruleConsidered;
+       private RuleConsideredElement ruleConsidered;
        private EntitySelectionElement selection_toName;
        private TermComboElement<NameRelationshipType> combo_relationshipType;
        private LabelElement label;
@@ -60,9 +60,12 @@ public class NameRelationshipDetailElement extends AbstractReferencedEntityEleme
        /** {@inheritDoc} */
        @Override
        public void createControls(ICdmFormElement element, int style) {
+           NameDetailsConfigurator config = PreferencesUtil.getPreferredNameDetailsConfiguration();
                label = formFactory.createLabel(element, null);
 
-               text_ruleConsidered = formFactory.createTextWithLabelElement(element, "Rule Considered", null, SWT.NULL);
+               if (config == null || config.isNameRelationsRuleConsideredActivated()){
+                   ruleConsidered = formFactory.createRuleConsideredElement(element, "Rule Considered", config == null || config.isNameRelationsRuleConsideredCodeEditionActivated(), style);
+               }
 
                super.createControls(element, style);
        }
@@ -73,7 +76,9 @@ public class NameRelationshipDetailElement extends AbstractReferencedEntityEleme
                String text = entity.getFromName().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getToName().getTitleCache();
 
                label.setText(text);
-               text_ruleConsidered.setText(entity.getRuleConsidered());
+               if (ruleConsidered != null){
+                   ruleConsidered.setElement(entity);
+               }
 
                super.setEntity(entity);
        }
@@ -81,15 +86,12 @@ public class NameRelationshipDetailElement extends AbstractReferencedEntityEleme
        /** {@inheritDoc} */
        @Override
        public void handleEvent(Object eventSource) {
-               if(eventSource == combo_relationshipType){
+           if(eventSource == combo_relationshipType){
                        getEntity().setType(combo_relationshipType.getSelection());
                }
                else if(eventSource == selection_toName){
                        MessagingUtils.error(getClass(), "No API call available.", null);
                }
-               else if(eventSource == text_ruleConsidered){
-                       getEntity().setRuleConsidered(text_ruleConsidered.getText());
-               }
                else if(eventSource == selection_reference){
                        getEntity().setCitation(selection_reference.getSelection());
                }