ref #9116: layout issues and improve handling if no source exist
authorKatja Luther <k.luther@bgbm.org>
Fri, 14 Aug 2020 14:12:45 +0000 (16:12 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 14 Aug 2020 14:13:30 +0000 (16:13 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/EditTaxonNodeWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
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/OriginalSourceElement.java

index 47c37affbb8f541d128c1c69bc4280f11b544be2..dd632b29f89530346bda1215531f3da1509e6c46 100644 (file)
@@ -16,6 +16,7 @@ import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.dto.CreateTaxonDTO;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
@@ -64,13 +65,14 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizardParentChild<Taxon
                TaxonNode parent = getParentEntity();
 
                Map<Language, LanguageString> notes = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getMultiLanguageTextExcludedNotes();
-               UUID refUuid = parent.getReference() != null? parent.getReference().getUuid(): null;
+               DescriptionElementSource source = parent.getSource().checkEmpty()? null: parent.getSource();
+
 
                TaxonNodeStatus status = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getTaxonNodeStatus();
                if (status == null){
                    notes = null;
                }
-               result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, refUuid, parent.getMicroReference(),
+               result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, source, parent.getMicroReference(),
                         status, notes);
 
                if (result.isOk()){
index 4e127eb5a85a93fafdf0de80ac70a431aa64adf0..aa492df7b91d93ec5dba26ebd3ac31b4aca872f4 100644 (file)
@@ -56,7 +56,9 @@ public class EditTaxonNodeWizard extends AbstractEditWizard<TaxonNode> implement
     protected void saveEntity() {
         getConversationHolder().bind();
         TaxonNode node = getEntity();
-
+        if (node.getSource().checkEmpty()){
+            node.setSource(null);
+        }
         MergeResult result = CdmStore.getService(ITaxonNodeService.class).merge(node, true);
         EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, node.getTaxon().getUuid());
 
index a6c399e1a592c14c1c63706dcbaa103dad713402..7ab81732f2d10aaee160150edb5c66ccf48abc04 100644 (file)
@@ -22,7 +22,6 @@ import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.TableWrapData;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
@@ -121,12 +120,13 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
        protected void createControls(ICdmFormElement formElement,
                TaxonNode entity, int style) {
 //         taxon = entity.getTaxon();
+
            Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
-        taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
-        TableWrapData tableWrap = LayoutConstants.FILL_HORIZONTALLY(2, 2);
-        tableWrap.valign = SWT.TOP;
-        taxonTitle.setLayoutData(tableWrap);
-        taxonTitle.setFont(FONT_BOLD);
+           taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
+           taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+           taxonTitle.setFont(FONT_BOLD);
+
+
 
            if (isCreateNew()){
                textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
@@ -156,11 +156,17 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                     Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
 
             checkbox_publish.setEnabled(isCreateNew());
-
+            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
+            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
             Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
-            nodeTitle.setText(Messages.TaxonNodeWizardPage_TAXON_NODE);
+            nodeTitle.setText("Taxon Node");
             nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
             nodeTitle.setFont(FONT_BOLD);
+//            LabelElement nodeTitle = formFactory.createLabel(formElement, Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
+//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+//            nodeTitle.setBackground(getPersistentBackground());
+//            nodeTitle.setBold();
+
             selection_parentTaxonNode = formFactory
                     .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
                             EntitySelectionElement.DELETABLE, style, 100);
@@ -183,12 +189,20 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
             }
             textTaxonSec.setEnabled(false);
             microReference.setEnabled(false);
+            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
+            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
 
             Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
             nodeTitle.setText("Taxon Node");
             nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
             nodeTitle.setFont(FONT_BOLD);
 
+//            LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
+//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+//            nodeTitle.setBackground(getPersistentBackground());
+//            nodeTitle.setBold();
+
+
             if (entity.getParent().getTaxon() == null){
                 TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
                         formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style);
@@ -199,8 +213,8 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                 textParent.setEnabled(false);
             }
            }
-           Label spacer = new Label(getLayoutComposite(), SWT.NULL);
-           spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+
+
         combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true);
         if (!isCreateNew()){
             combo_status.setSelection(entity.getStatus());
@@ -235,20 +249,22 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
            }
 
-               if (!isCreateNew()){
-                   selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
 
-                   selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-                   selectionNodeAgentRelation.setEntity(entity);
-               }
 
                sourceSection = formFactory.createOriginalSourceElement(formElement, entity);
-               if (isCreateNew()){
-                   sourceSection.setEntity(null);
+               if (isCreateNew() || entity.getSource() == null){
+                   DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
+                   entity.setSource(source);
+                   sourceSection.setEntity(source);
                }else{
                    sourceSection.setEntity(entity.getSource());
+
                }
 
+               selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
+               selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+        selectionNodeAgentRelation.setEntity(entity);
+        setBackground(getPersistentBackground());
 
        }
 
@@ -323,9 +339,8 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                }
 
         if (eventSource == sourceSection) {
-            if(!isCreateNew()){
-                getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
-            }
+//            getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
+
         }else if (eventSource == selection_SecRef) {
             if (taxon != null){
                 taxon.setSec(selection_SecRef.getEntity());
index aa8702c634300d2f9d39aabc77a56a027057ec28..0667ebd12e7a3053f92bf918ddc4167584787092 100644 (file)
@@ -75,11 +75,13 @@ public class TaxonNodeWizardPage extends AbstractCdmEntityWizardPage<TaxonNode>
        @Override
        public TaxonNodeDetailElement createElement(ICdmFormElement rootElement) {
            TaxonNodeDetailElement detailElement = formFactory.createTaxonNodeDetailElement(rootElement, this.isCreateNew);
-               if (isCreateNew){
+
+           if (isCreateNew){
                    detailElement.setParentTreeNode(((NewTaxonNodeWizard)getWizard()).getParentEntity());
                }else{
                    detailElement.setEntity(entity);
                }
+//         detailElement.setPersistentBackground(Abstrac);;
 
                formFactory.addPropertyChangeListener(this);
 //             if (isCreateNew){
index 4d32a522a140ce098add41fbe56d1ac7beda65ce..eab6ca96952041cade90b2803d8e24363615fbb2 100755 (executable)
@@ -69,9 +69,12 @@ public class AdvancedSourceElement extends AbstractCdmDetailElement<ReferencedEn
         text_originaleNameString.setBackground(background);
 
         select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
+        select_nameUsedInSource.setBackground(background);
+
         externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
         externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
         externalLinks.setEntity( ((OriginalSourceBase)entity));
+        externalLinks.setBackground(background);
         addControl(externalLinks);
         addElement(externalLinks);
 
index b56d3663d47aeafc897b293678ef25f53a91b9e6..a22b032908402084f8b146bb3c84318138654cf0 100755 (executable)
@@ -16,7 +16,6 @@ import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
 import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -57,13 +56,15 @@ public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEn
         }
         selection_Ref.setBackground(this.getPersistentBackground());
         microReference = formFactory.createTextWithLabelElement(formElement, "Details", entity != null? entity.getCitationMicroReference(): "", style);
+
+
         for (ICdmFormElement element: selection_Ref.getElements()){
             element.setBackground(getPersistentBackground());
         }
 
         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);
 
@@ -71,35 +72,19 @@ public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEn
         addElement(advancedSection);
         advancedSection.setBackground(this.getPersistentBackground());
         advancedSection.setEntity(entity);
+        if (!((DescriptionElementSource)entity).checkEmpty()){
+            advancedSection.setExpanded(true);
+        }else{
+            advancedSection.setExpanded(false);
+        }
 
     }
 
     @Override
     public void handleEvent(Object eventSource) {
         if (eventSource.equals(selection_Ref)){
-
-            if (getEntity() == null){
-                Reference ref = selection_Ref.getEntity();
-                DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
-                setEntity(source);
-                selection_Ref.setEntity(ref);
-                if (cdmEntity != null && cdmEntity instanceof TaxonNode){
-                    ((TaxonNode)cdmEntity).setSource(source);
-                }
-            }
-            //TODO: why is this null????ß
             getEntity().setCitation(selection_Ref.getEntity());
-
         }else if (eventSource.equals(microReference)){
-
-            if (getEntity() == null){
-                DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
-                setEntity(source);
-                if (cdmEntity != null && cdmEntity instanceof TaxonNode){
-                    ((TaxonNode)cdmEntity).setSource(source);
-                }
-            }
-            //TODO: why is this null????ß
             getEntity().setCitationMicroReference(microReference.getText());
 
         }