ref #9266: restructure nomenclatural source detail element
authorKatja Luther <k.luther@bgbm.org>
Thu, 12 Nov 2020 10:39:53 +0000 (11:39 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 12 Nov 2020 10:39:53 +0000 (11:39 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedNomenclaturalSourceElement.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedSourceElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/NomenclaturalSourceElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/OriginalSourceAdvancedSection.java

index 7ed9b88804c3b62bb3cc27f0387d331f888d149d..b2a0c79802b9710c12631ca8e188ee1819e903d4 100644 (file)
@@ -326,6 +326,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetai
 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedNomenclaturalSourceElement;
 import eu.etaxonomy.taxeditor.ui.section.reference.AdvancedSourceElement;
 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
@@ -1967,6 +1968,12 @@ public class CdmFormFactory extends FormToolkit {
         return element;
     }
 
+    public AdvancedSourceElement createAdvancedNomenclaturalSourceDetailElement(ICdmFormElement parentElement, int style){
+        AdvancedNomenclaturalSourceElement element = new AdvancedNomenclaturalSourceElement(this, parentElement);
+        addAndAdaptElement(parentElement, element);
+        return element;
+    }
+
     public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, String label, int style){
         SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style, label);
         addAndAdaptSection(parentElement, section);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedNomenclaturalSourceElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedNomenclaturalSourceElement.java
new file mode 100755 (executable)
index 0000000..18494ff
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+* Copyright (C) 2020 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.section.reference;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+
+/**
+ * @author k.luther
+ * @since Nov 12, 2020
+ */
+public class AdvancedNomenclaturalSourceElement extends AdvancedSourceElement {
+
+    /**
+     * @param formFactory
+     * @param formElement
+     */
+    public AdvancedNomenclaturalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
+        super(formFactory, formElement);
+        // TODO Auto-generated constructor stub
+    }
+
+    @Override
+    protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
+        Display display = Display.getCurrent();
+        Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+
+
+        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
+            text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
+            text_idNamespace.setBackground(background);
+        }
+        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
+            text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
+            text_idInSource.setBackground(background);
+
+        }
+
+        text_originaleNameString = formFactory.createTextWithLabelElement(
+                formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
+
+        text_originaleNameString.setBackground(background);
+        Label label = formFactory.createEmptyCell(getLayoutComposite());
+    }
+
+}
index e4fd4fcac51e80a1bda5858ddc6aaf1a97bbd748..89177f0518ea8948bc2403888d6ee91364f62ec3 100755 (executable)
@@ -82,7 +82,9 @@ public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSour
     @Override
     public void setEntity(OriginalSourceBase entity) {
         super.setEntity(entity);
-        externalLinks.setEntity(entity);
+        if (externalLinks != null){
+            externalLinks.setEntity(entity);
+        }
     }
 
     public ExternalLinksSection getExternalLinks() {
index 68865addab799eb087cfe29f966afe41ace3accc..038bd62d9ed1ee9aeadcf82315a7d1d34768f52a 100755 (executable)
@@ -8,16 +8,15 @@
 */
 package eu.etaxonomy.taxeditor.ui.section.reference;
 
-import org.eclipse.swt.SWT;
+import org.eclipse.ui.forms.widgets.TableWrapData;
 
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
-import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
 import eu.etaxonomy.cdm.model.name.TaxonName;
+import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -37,7 +36,7 @@ public class NomenclaturalSourceElement extends OriginalSourceElement {
 
     protected EntitySelectionElement<Reference> selection_Ref;
     protected TextWithLabelElement microReference;
-//    protected OriginalSourceAdvancedSection advancedSection;
+    protected OriginalSourceAdvancedSection advancedSection;
     protected String label = "Source";
     protected CdmBase cdmEntity;
 
@@ -80,19 +79,19 @@ public class NomenclaturalSourceElement extends OriginalSourceElement {
         for (ICdmFormElement element: selection_NomRef.getElements()){
             element.setBackground(getPersistentBackground());
         }
-        if (entity instanceof DescriptionElementSource){
-            select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Original spelling", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.ALL, style);
-        }
 
-        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
-            text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
-        }
-        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
-            text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
-        }
+        select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Original spelling", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.ALL, style);
+
 
-        text_originaleNameString = formFactory.createTextWithLabelElement(
-                formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
+//        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
+//            text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
+//        }
+//        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
+//            text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
+//        }
+//
+//        text_originaleNameString = formFactory.createTextWithLabelElement(
+//                formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
 
         externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
         externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
@@ -101,6 +100,18 @@ public class NomenclaturalSourceElement extends OriginalSourceElement {
 
         addControl(externalLinks);
         addElement(externalLinks);
+
+        advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
+        TableWrapData layoutData = LayoutConstants.FILL_HORIZONTALLY(2, 1);
+        layoutData.indent = 10;
+
+
+        advancedSection.setLayoutData(layoutData);
+        advancedSection.setBackground(this.getPersistentBackground());
+        advancedSection.setEntity(entity);
+        addControl(advancedSection);
+        addElement(advancedSection);
+
         this.getLayoutComposite().layout();
 
     }
index c24e72e69d4085b5e8f80b015c88f100506df03f..6da0dbceb9816ab47336590ac4de37a382a5e806 100755 (executable)
@@ -35,6 +35,9 @@ public class OriginalSourceAdvancedSection extends AbstractCdmDetailSection<Orig
     protected AbstractCdmDetailElement<OriginalSourceBase> createCdmDetailElement(
             AbstractCdmDetailSection<OriginalSourceBase> parentElement, int style) {
 
+        if (parentElement.getParentElement() instanceof NomenclaturalSourceElement){
+            return getFormFactory().createAdvancedNomenclaturalSourceDetailElement(parentElement, style);
+        }
         return getFormFactory().createAdvancedSourceDetailElement(parentElement, style);
     }