fixing #5341 and colouring for cache relevant fields #4915 and #4944
authorKatja Luther <k.luther@bgbm.org>
Thu, 5 Nov 2015 11:12:40 +0000 (12:12 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 5 Nov 2015 11:12:40 +0000 (12:12 +0100)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/EditFeatureTreeWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/SelectFeatureTreeWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/PersonDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/operation/TaxonNavigatorTest.java

index ecbc76b..ea3fb60 100644 (file)
@@ -28,7 +28,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.model.common.ITreeNode;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
index 236dd72..53d23d8 100644 (file)
@@ -24,7 +24,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
index a39b9ff..16efff5 100644 (file)
@@ -163,7 +163,9 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
                viewer.setInput(featureTree);
 
                text_title.removeModifyListener(this);
-               text_title.setText(featureTree.getTitleCache());
+               if (featureTree != null){
+                       text_title.setText(featureTree.getTitleCache());
+               }
                text_title.addModifyListener(this);
        }
 
index 1a8b2a8..0816291 100644 (file)
@@ -163,9 +163,10 @@ public class SelectFeatureTreeWizardPage extends WizardPage implements ISelectio
                @Override
         public void widgetSelected(SelectionEvent e) {
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                       Object source = e.getSource();
                        for(Object element : selection.toArray()){
                                viewer.remove(element);
-
+                               ((FeatureTreeEditorWizard) getWizard()).setSelectedFeatureTree(null);
                                DeleteResult result =   CdmStore.getService(IFeatureTreeService.class).delete(((FeatureTree) element).getUuid());
 
                                if (result.isError()){
index 5199df5..ba51d80 100644 (file)
@@ -120,4 +120,13 @@ public class PersonDetailElement extends AbstractIdentifiableEntityDetailElement
 
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
+       
+       @Override
+       protected void handleToggleableCacheField() {
+        boolean pushedState = toggleable_cache.getState();
+
+        getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
+        setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_nomenclaturalTitle }));
+        updateToggleableCacheField();
+    }
 }
index f223d8c..15012f0 100644 (file)
@@ -94,9 +94,7 @@ public class TeamDetailElement extends AbstractIdentifiableEntityDetailElement<T
                        handleToggleableCacheField();
                        
                } else if (eventSource == toggleable_nomenclaturalTitleCache) {
-                       getEntity().setNomenclaturalTitle(
-                                       toggleable_nomenclaturalTitleCache.getText(),
-                                       toggleable_nomenclaturalTitleCache.getState());
+                       updateToggleable_nomanclaturalTitleCacheField();
                        setIrrelevant(
                                        toggleable_nomenclaturalTitleCache.getState(),
                                        Arrays.asList(new Object[] { toggleable_nomenclaturalTitleCache, hasAdditionalMembers }));
@@ -113,4 +111,10 @@ public class TeamDetailElement extends AbstractIdentifiableEntityDetailElement<T
 
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
+       
+       public void updateToggleable_nomanclaturalTitleCacheField() {
+        if (!getEntity().isProtectedNomenclaturalTitleCache()) {
+            toggleable_nomenclaturalTitleCache.setText(getEntity().getNomenclaturalTitle());
+        }
+    }
 }
index a54f02a..d80937e 100644 (file)
@@ -250,4 +250,15 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
                        toggleable_cache.setText(getEntity().getNameCache());
                }
        }
+       
+       @Override
+       protected void handleToggleableCacheField() {
+        boolean pushedState = toggleable_cache.getState();
+
+        getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
+        setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_appendedPhrase, checkbox_anamorphic }));
+        updateToggleableCacheField();
+    }  
+
+
 }
index 9661e04..6b82772 100644 (file)
@@ -154,4 +154,12 @@ public class NonViralNameDetailElement extends
                    getEntity().setLsid(textLsid.parseText());
                }
        }
+       @Override
+       protected void handleToggleableCacheField() {
+        boolean pushedState = toggleable_cache.getState();
+
+        getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
+        setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, textLsid }));
+        updateToggleableCacheField();
+    }
 }
index 4ca0bef..b18ad68 100644 (file)
@@ -60,7 +60,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
        private TextWithLabelElement text_publisher;
        private TextWithLabelElement text_referenceAbstract;
        private TextWithLabelElement text_series;
-       private TextWithLabelElement text_seriesPart;
+//     private TextWithLabelElement text_seriesPart;
        private TextWithLabelElement text_volume;
        private TextWithLabelElement text_abbrevTitle;
        private TextWithLabelElement text_title;
@@ -162,6 +162,8 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                                "Date Published", entity.getDatePublished(), style);
 
                createUriAndAbstract(this, entity, SWT.NULL);
+               handleToggleableAbbrevTitleField();
+               handleToggleableCacheField();
        }
 
        /*
@@ -185,8 +187,8 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                // Object[]{text_cache}));
                toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
                toggleableAbbrevCache.setEnabled(getEntity().isProtectedAbbrevTitleCache());
-        setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[] { toggleable_cache }));
-        setIrrelevant(toggleableAbbrevCache.getState(), Arrays.asList(new Object[] { toggleableAbbrevCache}));
+               setIrrelevantReferenceDetail(false);
+               setIrrelevantReferenceDetail(true);
        }
 
        /**
@@ -360,10 +362,10 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                text_editor = formFactory.createTextWithLabelElement(element, "Editor",
                                reference.getEditor(), style);
 
-               // series part
+               /* series part
                text_seriesPart = formFactory.createTextWithLabelElement(element,
                                "Series", reference.getSeriesPart(), style);
-
+*/
                if (referenceType.equals(ReferenceType.Book)) {
                        // edition
                        text_edition = formFactory.createTextWithLabelElement(element,
@@ -432,8 +434,8 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                        getEntity().setPublisher(text_publisher.getText());
                } else if (eventSource == text_referenceAbstract) {
                        getEntity().setReferenceAbstract(text_referenceAbstract.getText());
-               } else if (eventSource == text_seriesPart) {
-                       getEntity().setSeriesPart(text_seriesPart.getText());
+               } else if (eventSource == text_series) {
+                       getEntity().setSeriesPart(text_series.getText());
                } else if (eventSource == text_title) {
                        getEntity().setTitle(text_title.getText());
                        toggleable_cache.setText(text_title.getText());
@@ -474,7 +476,7 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
     protected void handleToggleableAbbrevTitleField() {
         boolean pushedAbbrevState = toggleableAbbrevCache.getState();
         getEntity().setAbbrevTitleCache(toggleableAbbrevCache.getText(), pushedAbbrevState);
-        setIrrelevant(pushedAbbrevState, Arrays.asList(new Object[] { toggleableAbbrevCache, toggleable_cache, text_title }));
+        setIrrelevantReferenceDetail(true);
         updateToggleableCacheField();
     }
 
@@ -548,4 +550,37 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                        }
                }
        }
+       
+       @Override
+       protected void handleToggleableCacheField() {
+       
+               boolean pushedState = toggleable_cache.getState();
+        getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
+        setIrrelevantReferenceDetail(false);
+        updateToggleableCacheField();
+    }
+       
+       protected void setIrrelevantReferenceDetail(boolean abbrev){
+               
+               List<Object> except = new ArrayList();
+           except.addAll( Arrays.asList(new Object[] { toggleable_cache, toggleableAbbrevCache, text_editor, text_isbn, text_issn, text_organisation, text_pages, text_placePublished, text_publisher, text_referenceAbstract,  text_uri, selection_institution}));
+           boolean pushedState;
+           if (abbrev){
+             except.add(text_title);
+             pushedState = toggleableAbbrevCache.getState();
+           } else{
+               except.add(text_abbrevTitle);
+               pushedState = toggleable_cache.getState();
+           }
+           switch( getEntity().getType()){
+           case Journal:
+               except.add(element_timePeriod);
+               break;
+           case Book:
+               except.remove(text_series);
+               except.remove(text_edition);
+               break;
+           }   
+           setIrrelevant(pushedState, except);
+       }
 }
index 8139ecd..b086a18 100644 (file)
@@ -180,4 +180,12 @@ public class TaxonBaseDetailElement extends AbstractIdentifiableEntityDetailElem
                    ((Taxon)getEntity()).setPublish(checkbox_published.getSelection());
                }
        }
+       @Override
+       protected void handleToggleableCacheField() {
+        boolean pushedState = toggleable_cache.getState();
+
+        getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
+        setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_appendedPhrase, checkbox_published, checkbox_unplaced, checkbox_excluded}));
+        updateToggleableCacheField();
+    }
 }
index b9d3cf6..3b99b77 100644 (file)
@@ -26,7 +26,7 @@ import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;