add first implementation for simple details view
authorKatja Luther <k.luther@bgbm.org>
Fri, 3 Jun 2016 11:41:32 +0000 (13:41 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 3 Jun 2016 11:42:50 +0000 (13:42 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractIdentifiableEntityDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AuthorshipDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AuthorshipDetailSection.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/NameDetailSection.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/name/NonViralNameDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index 2541c85bd437284f6360dc746fc2f784b4e75b1e..d8ef6945c726398f54e32ea9866e8abdb9bbec27 100644 (file)
@@ -9,6 +9,8 @@ import java.util.EnumSet;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -26,16 +28,20 @@ public abstract class AbstractIdentifiableEntityDetailElement<T extends IIdentif
      */
     private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
     protected ToggleableTextElement toggleable_cache;
+    protected boolean isAdvancedView ;
 
     public AbstractIdentifiableEntityDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
         super(formFactory, formElement);
         updateToggleableCacheState();
+        initIsAdvancedDetailsView();
 
     }
 
     public void updateToggleableCacheField() {
-        if (!getEntity().isProtectedTitleCache()) {
-            toggleable_cache.setText(getEntity().generateTitle());
+        if (toggleable_cache != null){
+            if (!getEntity().isProtectedTitleCache()) {
+                toggleable_cache.setText(getEntity().generateTitle());
+            }
         }
     }
 
@@ -60,5 +66,15 @@ public abstract class AbstractIdentifiableEntityDetailElement<T extends IIdentif
             toggleable_cache.setEnabled(getEntity() != null && CdmStore.currentAuthentiationHasPermission((CdmBase) getEntity(), UPDATE));
         }
     }
+    protected void initIsAdvancedDetailsView(){
+        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
+            isAdvancedView = false;
+        } else{
+            isAdvancedView = true;
+        }
+
+
+
+    }
 
 }
index 9e672a485ac361830c7c647b95f06918d24bdd08..c52cacf451d98f51195bf35f165f409282da938b 100644 (file)
@@ -61,14 +61,16 @@ public class AuthorshipDetailElement extends
        @Override
        protected void createControls(ICdmFormElement formElement,
                        NonViralName entity, int style) {
-               toggleable_cache = formFactory.createToggleableTextField(this,
+           if (isAdvancedView){
+               toggleable_cache = formFactory.createToggleableTextField(this,
                                "Authorship Cache", entity.getAuthorshipCache(),
                                entity.isProtectedAuthorshipCache(), style);
+                   //TODO RL
+            if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                toggleable_cache.setVisible(false);
+            }
+           }
 
-               //TODO RL
-               if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
-                       toggleable_cache.setVisible(false);
-               }
                selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Author",
@@ -100,13 +102,16 @@ public class AuthorshipDetailElement extends
                }
 
                super.updateContent();
-               toggleable_cache.setEnabled(getEntity().isProtectedAuthorshipCache());
+               if (toggleable_cache != null){
+               toggleable_cache.setEnabled(getEntity().isProtectedAuthorshipCache());
+
 
-               if (this.isIrrelevant()) {
-                       setIrrelevant(isIrrelevant());
-               } else {
-                       setIrrelevant(toggleable_cache.getState(),
-                                       Arrays.asList(new Object[] { toggleable_cache }));
+               if (this.isIrrelevant()) {
+                       setIrrelevant(isIrrelevant());
+               } else {
+                       setIrrelevant(toggleable_cache.getState(),
+                                       Arrays.asList(new Object[] { toggleable_cache }));
+               }
                }
        }
 
@@ -148,8 +153,10 @@ public class AuthorshipDetailElement extends
 
        @Override
        public void updateToggleableCacheField() {
-               if(! getEntity().isProtectedAuthorshipCache()){
-                       toggleable_cache.setText(getEntity().getAuthorshipCache());
-               }
+           if (toggleable_cache != null){
+               if(! getEntity().isProtectedAuthorshipCache()){
+                       toggleable_cache.setText(getEntity().getAuthorshipCache());
+               }
+           }
        }
 }
index e6f79398c3e3c097d7a93c9efdb0fb66c855d044..77e8bf16b30f8ac244502955ca359da3e24ea832 100644 (file)
@@ -31,9 +31,11 @@ public class AuthorshipDetailSection extends AbstractCdmDetailSection<NonViralNa
 
        private TaxonBase taxonBase;
 
+
        public AuthorshipDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
                        ISelectionProvider selectionProvider, int style) {
                super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
+
        }
 
        /** {@inheritDoc} */
index d80937e970d00992a2342e2fa6423b6af1305530..293f09bb7a3ef92fc1e236df7330cf7f511ceb0f 100644 (file)
@@ -79,19 +79,19 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
        @Override
        protected void createControls(ICdmFormElement formElement, NonViralName nonViralName, int style) {
 
-               toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style);
-
+           if (isAdvancedView){
+               toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style);
+           }
                combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style);
 
                createGenusOrUninomialControls(this, nonViralName, style);
                createInfragenerericEpithetControls(this, nonViralName, style);
                createSpecificEpithetControls(this, nonViralName, style);
                createInfraSpecificEpithetControls(this, nonViralName, style);
-
-               createSpecificNameParts(this, nonViralName, style);
-
-               text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
-
+               if (isAdvancedView){
+                   createSpecificNameParts(this, nonViralName, style);
+                       text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
+               }
        }
 
        /**
@@ -115,11 +115,12 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
                }
 
                super.updateContent();
-
-               if(isIrrelevant()){
-                       setIrrelevant(isIrrelevant());
-               }else{
-                       setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
+               if (isAdvancedView){
+               if(isIrrelevant()){
+                       setIrrelevant(isIrrelevant());
+               }else{
+                       setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
+               }
                }
        }
 
@@ -246,11 +247,13 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
 
        @Override
        public void updateToggleableCacheField() {
-               if(! getEntity().isProtectedNameCache()){
-                       toggleable_cache.setText(getEntity().getNameCache());
-               }
+           if (toggleable_cache != null){
+               if(! getEntity().isProtectedNameCache()){
+                       toggleable_cache.setText(getEntity().getNameCache());
+               }
+           }
        }
-       
+
        @Override
        protected void handleToggleableCacheField() {
         boolean pushedState = toggleable_cache.getState();
@@ -258,7 +261,9 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
         getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
         setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_appendedPhrase, checkbox_anamorphic }));
         updateToggleableCacheField();
-    }  
+    }
+
+
 
 
 }
index 32315ed8d3fbf27442281994cfd28579413f141a..4d686519f96b9553a1561d5344ea325c46bfa19e 100644 (file)
@@ -87,5 +87,6 @@ public class NameDetailSection extends AbstractCdmDetailSection<NonViralName> im
        @Override
        protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) {
            return formFactory.createNameDetailElement(parentElement, style);
+
        }
 }
index 6b82772415c8f007691f004b3215731a67af233d..0b443eb5d2f2da5bf7fc296a022aff16c876349a 100644 (file)
@@ -32,7 +32,7 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement
  * @version 1.0
  */
 public class NonViralNameDetailElement extends
-       AbstractIdentifiableEntityDetailElement<NonViralName> {
+       AbstractIdentifiableEntityDetailElement<NonViralName>  {
 
        private NameDetailSection section_name;
        private AuthorshipDetailSection section_author;
@@ -40,25 +40,33 @@ public class NonViralNameDetailElement extends
        private HybridDetailSection section_hybrid;
        private LsidWithExceptionLabelElement textLsid;
 
+
        public NonViralNameDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
                super(formFactory, formElement);
+               initIsAdvancedDetailsView();
+
        }
 
        /** {@inheritDoc} */
        @Override
     protected void createControls(ICdmFormElement formElement, final NonViralName entity, int style) {
-           toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
 
-           combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
-           combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
 
-           //TODO RL
-           if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
-               toggleable_cache.setVisible(false);
-               combo_nomenclaturalCode.setVisible(false);
-           }
-           textLsid = formFactory.createLsidWithExceptionLabelElement(formElement, "Lsid", entity.getLsid(), style);
+        if (isAdvancedView){
+            toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
+
+            combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
+            combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
+            textLsid = formFactory.createLsidWithExceptionLabelElement(formElement, "Lsid", entity.getLsid(), style);
+            //TODO RL
+            if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                toggleable_cache.setVisible(false);
+                combo_nomenclaturalCode.setVisible(false);
+            }
+        }
+
+
            section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
            section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
            addControl(section_name);
@@ -69,11 +77,13 @@ public class NonViralNameDetailElement extends
            addElement(section_author);
 
            //TODO RL
-           if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
-               section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
-               section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-               addControl(section_hybrid);
-               addElement(section_hybrid);
+           if (isAdvancedView){
+           if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+               section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
+               section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+               addControl(section_hybrid);
+               addElement(section_hybrid);
+           }
            }
 
 
@@ -162,4 +172,12 @@ public class NonViralNameDetailElement extends
         setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, textLsid }));
         updateToggleableCacheField();
     }
+
+
+
+
+//    @Override
+//    public void toggleAdvancedMediaView(){
+//        mediaDetailElement.toggleAdvancedMediaView();
+//    }
 }
index 9a02d8f98d514b01315b30a4767b272ca9265ea9..1449fb1130f1bf0416581a8a260f8b854c00bda2 100644 (file)
@@ -26,6 +26,8 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.NameSelectionDialog;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -66,7 +68,7 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
        protected Control createToolbar() {
                ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
 
-               if(nameChoosable){
+               if(nameChoosable && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
                    //choose name
                    Action chooseNameAction = new Action("Choose Name", IAction.AS_PUSH_BUTTON){
                        @Override
index 07a59b225d8ac4c4ff9af7ae705e659bfba40a00..e26adaafcbc53d6550d2699f04a908c8d8ef5cd2 100644 (file)
@@ -363,26 +363,31 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
                 ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
+        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
+            TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
+            addPart(taxonBaseDetailSection);
+        }
         NonViralNameDetailSection nonViralNameSection = formFactory
                 .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
                         ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
+            NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
+                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+            addPart(nomenclaturalStatusSection);
+            addPart(referenceDetailSection);
+        }
         //TODO RL
-        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)  && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
                ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
@@ -398,10 +403,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
         }
 
         addPart(parsingMessagesSection);
-        addPart(taxonBaseDetailSection);
+
         addPart(nonViralNameSection);
-        addPart(nomenclaturalStatusSection);
-        addPart(referenceDetailSection);
+
     }
 
     private void createNameSections(RootElement parent) {