AT: Committing code review changes
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index 8580ee0af22bbe3bb281ebc87a87c2ec02f28b25..b65fdbe09187b3762c05943ef86d5a8542b7a703 100644 (file)
@@ -10,6 +10,9 @@
 
 package eu.etaxonomy.taxeditor.view.detail;
 
+import java.util.Set;
+import java.util.UUID;
+
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.swt.SWT;
@@ -18,11 +21,14 @@ import org.eclipse.ui.forms.widgets.Section;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
+import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.model.common.Marker;
+import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
@@ -38,6 +44,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
@@ -82,6 +89,7 @@ import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
 import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
 import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
@@ -186,7 +194,21 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                        }
                } else if (getInput() instanceof DescriptionElementBase) {
-                       createDescriptionElementSection(rootElement);
+                       Set<Marker> descriptionMarkers = ((DescriptionElementBase) getInput()).getInDescription().getMarkers();
+                       MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));
+                       Boolean isUseDescription = false;
+                       for (Marker marker : descriptionMarkers) {
+                               if (marker.getMarkerType().equals(useMarkertype)) {
+                                       isUseDescription = true;
+                               }
+                       }
+                       
+                       if (isUseDescription == true) {
+                               createUseRecordSection(rootElement);
+                       }
+                       else {
+                               createDescriptionElementSection(rootElement);
+                       }
 
                } else if (getInput() instanceof Media) {
                        createMediaElementSection(rootElement);
@@ -613,6 +635,21 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                addPart(polytomousKeyNodeDetailSection);
        }
+       
+       private void createUseRecordSection(RootElement parent) {
+               destroySections();
+
+               UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
+                               .createCdmDetailSection(DetailType.USE_RECORD,
+                                               getConversationHolder(), parent, this, Section.TWISTIE
+                                                               | Section.EXPANDED);
+
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+               
+               addPart(descriptionUseRecordSection);
+               
+               
+       }
 
        private void createUserSection(RootElement parent) {
                destroySections();