commit 828e0012bde5f63f0f083e2fbddf00723bd0b14e
Author: Katja Luther <k.luther@bgbm.org>
Date:   Tue Jun 29 16:57:14 2021 +0200

    ref #9373: adapt detail elements to enable/disable possibility of toggleable text fields

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java
index 6935552c9..05315a6d2 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java
@@ -48,6 +48,7 @@ public class ToggleableTextElement
 	private final Composite container;
 	private final CacheRelevance relevance;
 
+	private boolean isEnabled = true;
 	//TODO for RL
 	public void setVisible(boolean b) {
 		text_cache.setVisible(b);
@@ -121,13 +122,13 @@ public class ToggleableTextElement
 	        btnToggleProtectTitleCache.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
 	        btnToggleProtectTitleCache.setToolTipText(Messages.ToggleableText_ToolTip_closed);
 	    }
-	   setEnabled(state);
+	    setCacheEnabled(state);
 		this.state = state;
 	}
 
-	@Override
-    public void setEnabled(boolean enabled) {
-		text_cache.setEnabled(enabled);
+
+    public void setCacheEnabled(boolean enabled) {
+        text_cache.setEnabled(enabled);
        	btnToggleProtectTitleCache.setGrayed(enabled);
 		btnToggleProtectTitleCache.setSelection(enabled);
 		Color color = enabled ? null : AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED);
@@ -135,11 +136,22 @@ public class ToggleableTextElement
 		text_cache.setForeground(color);
 	}
 
+    @Override
+    public void setEnabled(boolean isEnabled){
+        this.isEnabled = isEnabled;
+        text_cache.setEnabled(isEnabled);
+        btnToggleProtectTitleCache.setEnabled(isEnabled);
+    }
+
 	@Override
 	public boolean isEnabled() {
-	    return text_cache.isEnabled();
+	    return isEnabled;
 	}
 
+	public boolean isCacheEnabled() {
+        return btnToggleProtectTitleCache.getSelection();
+    }
+
     public CacheRelevance getRelevance() {
         return this.relevance;
     }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralDetailElement.java
index 4762780f4..8a0d23200 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralDetailElement.java
@@ -75,10 +75,7 @@ public class DerivedUnitGeneralDetailElement extends
 				formElement, "Title Cache", entity.getTitleCache(),
 				entity.isProtectedTitleCache(), style);
         //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
-		if(showOnlyDerivedUnitData){
-		    toggleableText_titleCache.setEnabled(false);
-		}
-		else{
+		if(!showOnlyDerivedUnitData){
 		    combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
 		    combo_specorobstype.setSelection(entity.getType());
 		    combo_specorobstype.setEnabled(showSpecimenType);
@@ -127,6 +124,7 @@ public class DerivedUnitGeneralDetailElement extends
 		if (eventSource == toggleableText_titleCache) {
 			getEntity().setTitleCache(toggleableText_titleCache.getText(),
 					toggleableText_titleCache.getState());
+
 		} else if (eventSource == selection_country) {
 			getEntity().setCountry(selection_country.getSelection());
 		} else if (eventSource == languageText_locality) {
@@ -155,9 +153,8 @@ public class DerivedUnitGeneralDetailElement extends
             getEntity().innerDerivedUnit().setPublish(checkIsPublish.getSelection());
         }
 
-		if (eventSource != toggleableText_titleCache) {
-			toggleableText_titleCache.setText(getEntity().getTitleCache());
-		}
+		toggleableText_titleCache.setText(getEntity().getTitleCache());
+
 	}
 
     public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData) {
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitFacadeGeneralDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitFacadeGeneralDetailElement.java
index 6f6d29c68..a8696a903 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitFacadeGeneralDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitFacadeGeneralDetailElement.java
@@ -87,6 +87,7 @@ public class FieldUnitFacadeGeneralDetailElement extends AbstractCdmDetailElemen
     public void handleEvent(Object eventSource) {
         if (eventSource == toggleableText_titleCache) {
             getEntity().setTitleCache(toggleableText_titleCache.getText(), toggleableText_titleCache.getState());
+
         } else if (eventSource == selection_country) {
             getEntity().setCountry(selection_country.getSelection());
         } else if (eventSource == languageText_locality) {
@@ -108,8 +109,7 @@ public class FieldUnitFacadeGeneralDetailElement extends AbstractCdmDetailElemen
             getEntity().innerFieldUnit().setPublish(checkIsPublish.getSelection());
         }
 
-        if (eventSource != toggleableText_titleCache) {
-            toggleableText_titleCache.setText(getEntity().getTitleCache());
-        }
+        toggleableText_titleCache.setText(getEntity().getTitleCache());
+
     }
 }
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
index d53107806..96cd6376f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
@@ -36,6 +36,7 @@ import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement;
 import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 
 /**
@@ -72,7 +73,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
 	private EntitySelectionElement<Reference> selection_inReference;
 	private EntitySelectionElement<Institution> selection_institution;
 	private EnumComboElement<ReferenceType> combo_referenceType;
-
+	private ExternalLinksSection externalLinks;
 	private EntitySelectionElement<Reference> selection_inSeries;
 
     private void registerCacheElements() {
@@ -168,6 +169,13 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
 		}
 
 		createUri(this, entity, SWT.NULL);
+
+//		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
+//        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
+//        externalLinks.setEntity(entity);
+//        externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
+//        externalLinks.setEmptySectionString("No links yet.");
+
 		if(referenceType != null && (!referenceType.equals(ReferenceType.Journal) && !referenceType.equals(ReferenceType.PrintSeries) && !referenceType.equals(ReferenceType.PersonalCommunication))) {
             text_doi = formFactory.createDoiWithLabelElement(formElement, "DOI", entity.getDoi(), style);
         }
@@ -428,12 +436,12 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
 			getEntity().setSeriesPart(text_series.getText());
 		} else if (eventSource == text_title ) {
 			getEntity().setTitle(text_title.getText());
-			if (!toggleable_cache.isEnabled()){
+			if (!toggleable_cache.isCacheEnabled()){
 			    toggleable_cache.setText(getEntity().generateTitle());
 			}
 		} else if (eventSource == text_abbrevTitle ) {
 		    getEntity().setAbbrevTitle(text_abbrevTitle.getText());
-		    if (!toggleableAbbrevCache.isEnabled()){
+		    if (!toggleableAbbrevCache.isCacheEnabled()){
 		        toggleableAbbrevCache.setText(getEntity().generateAbbrevTitle());
 		    }
 		} else if (eventSource == text_uri) {
@@ -444,7 +452,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
 			getEntity().setVolume(text_volume.getText());
 		}else if (eventSource == text_doi) {
             getEntity().setDoi(text_doi.parseText());
-        }else if (eventSource == text_accessed.getController()) {
+        }else if (text_accessed != null && eventSource == text_accessed.getController()) {
             getEntity().setAccessed(text_accessed.getController().getDateTime());
         }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
index f4dec31ae..e3a588f8b 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
@@ -122,7 +122,7 @@ public class TaxonBaseDetailElement extends AbstractIdentifiableEntityDetailElem
 	@Override
 	protected void updateContent() {
 		super.updateContent();
-		toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
+		toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
 		updateCacheRelevance();
 	}
 
