Merge branch 'release/4.4.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NonViralNameDetailElement.java
index 1213418a592094bbbe9977831a7c19553513e8a0..23fe4db93d8564c53a15e1016e5cd33ae05b022e 100644 (file)
@@ -22,6 +22,7 @@ import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.LsidWithExceptionLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
 
@@ -31,31 +32,60 @@ 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;
        private EnumComboElement<NomenclaturalCode> combo_nomenclaturalCode;
        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);
-           }
+        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);
+            }
+        }else{
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE)){
+                       toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
+                if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                    toggleable_cache.setVisible(false);
+                }
+               }
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE)){
+                       combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
+                       combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
+                        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                                 combo_nomenclaturalCode.setVisible(false);
+                 } 
+               }
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID)){
+                       textLsid = formFactory.createLsidWithExceptionLabelElement(formElement, "Lsid", entity.getLsid(), style);
+                       
+               }
+                       
+               
+        }
+
 
            section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
            section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
@@ -67,12 +97,25 @@ 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);
+           }
+        }else{
+                if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                        if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID)){
+                       section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
+                       section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+                       addControl(section_hybrid);
+                       addElement(section_hybrid);
+                        }
+           }
+        }
+
+
     }
 
        /** {@inheritDoc} */
@@ -138,13 +181,34 @@ public class NonViralNameDetailElement extends
                        if (getParentElement() instanceof AbstractCdmDetailSection) {
                 ((AbstractCdmDetailSection) getParentElement()).updateTitle();
             }
-                       if (!toggleable_cache.getState()) {
-                               toggleable_cache.setText(getEntity().getTitleCache());
+                       if (toggleable_cache != null){
+                       if (!toggleable_cache.getState()) {
+                               toggleable_cache.setText(getEntity().getTitleCache());
+                       }
                        }
                }
                if (eventSource == section_name) {
                        section_name.setEntity(getEntity());
                        getLayoutComposite().layout();
                }
+               else if(eventSource==textLsid){
+                   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();
+    }
+
+
+
+
+//    @Override
+//    public void toggleAdvancedMediaView(){
+//        mediaDetailElement.toggleAdvancedMediaView();
+//    }
 }