reordered sections in detail view
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
index e4ac3f0b1504ad6fc4423b0b5ebad1244e2c5b4e..3f2143547b412ac6ebe34ddfeb64f69242fdf8b4 100644 (file)
@@ -1,6 +1,7 @@
+
 // $Id$
 /**
- * Copyright (C) 2007 EDIT
+ * Copyright (C) 2011 EDIT
  * European Distributed Institute of Taxonomy 
  * http://www.e-taxonomy.eu
  * 
@@ -11,7 +12,6 @@
 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;
@@ -36,13 +36,14 @@ import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
-import eu.etaxonomy.cdm.model.description.TextData;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+
+import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
@@ -169,6 +170,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
        /** {@inheritDoc} */
        @Override
        protected void showParts() {
+           // FIXME (CM) : Need to clean out this code.
+           // Too much type checking to decide which detail view to display.
+           // Need to build in a mechanism where navigators / editors are 'aware'
+           // of the corresponding detail viewer.
                if (getInput() instanceof TaxonBase) {
                        createTaxonSections(rootElement);
 
@@ -189,7 +194,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                } else if (getInput() instanceof DescriptionBase) {
                        Set<Marker> descriptionMarkers = ((DescriptionBase) getInput()).getMarkers();
-                       MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));
+                       MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
                        Boolean isUseDescription = false;
                        for (Marker marker : descriptionMarkers) {
                                if (marker.getMarkerType().equals(useMarkertype)) {
@@ -207,7 +212,7 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        }
                } else if (getInput() instanceof DescriptionElementBase) {
                        Set<Marker> descriptionMarkers = ((DescriptionElementBase) getInput()).getInDescription().getMarkers();
-                       MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));
+                       MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
                        Boolean isUseDescription = false;
                        for (Marker marker : descriptionMarkers) {
                                if (marker.getMarkerType().equals(useMarkertype)) {
@@ -310,6 +315,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                fireSelectionChanged(selectionChangedEvent);
        }
 
+       /**
+        * createTaxonSections(RootElement parent)
+        * @param parent
+        */
        private void createTaxonSections(RootElement parent) {
                destroySections();
 
@@ -371,6 +380,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(parsingMessagesSection);
        }
 
+       /**
+        * createNameSections
+        * @param parent
+        */
        private void createNameSections(RootElement parent) {
                destroySections();
                NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
@@ -419,6 +432,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(nameRelationshipSection);
        }
 
+       /**
+        * createReferenceSections
+        * @param parent
+        */
        private void createReferenceSections(RootElement parent) {
                destroySections();
 
@@ -430,6 +447,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(referenceDetailSection);
        }
 
+       /**
+        * createTeamOrPersonBaseDetailSection
+        * @param parent
+        */
        private void createTeamOrPersonBaseDetailSection(RootElement parent) {
                destroySections();
                TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = (TeamOrPersonBaseDetailSection) formFactory
@@ -440,6 +461,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(teamOrPersonBaseDetailSection);
        }
 
+       /**
+        * createTeamDetailSection
+        * @param parent
+        */
        private void createTeamDetailSection(RootElement parent) {
                destroySections();
                TeamDetailSection teamDetailSection = (TeamDetailSection) formFactory
@@ -449,7 +474,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                addPart(teamDetailSection);
        }
-
+       
+       /**
+        * createPersonDetailSection
+        * @param parent
+        */
        private void createPersonDetailSection(RootElement parent) {
                destroySections();
                PersonDetailSection personDetailSection = (PersonDetailSection) formFactory
@@ -459,6 +488,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(personDetailSection);
        }
 
+       /**
+        * createDescriptionElementSection
+        * @param parent
+        */
        private void createDescriptionElementSection(RootElement parent) {
                destroySections();
 
@@ -488,6 +521,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(descriptionElementMediaSection);
        }
 
+       /**
+        * createDescriptionSection
+        * @param parent
+        */
        private void createDescriptionSection(RootElement parent) {
                destroySections();
                DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
@@ -529,6 +566,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(scopeSection);
        }
        
+       /**
+        * Creates the use Description section
+        * @param parent
+        */
        private void createUseDescriptionSection(RootElement parent) {
                destroySections();
                DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
@@ -563,6 +604,11 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
                addPart(descriptionDetailSection);
        }
+       
+       /**
+        * createMediaElementSection
+        * @param parent
+        */
 
        private void createMediaElementSection(RootElement parent) {
                destroySections();
@@ -574,6 +620,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(mediaDetailSection);
        }
 
+       /**
+        * createDerivedUnitBaseElementSection
+        * @param parent
+        */
        private void createDerivedUnitBaseElementSection(RootElement parent) {
                destroySections();
 
@@ -660,17 +710,54 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(taxonomicScopeSection);
        }
 
+       /**
+        * createPolytomousKeyNodeSection
+        * @param parent
+        */
        private void createPolytomousKeyNodeSection(RootElement parent) {
                destroySections();
 
-               PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = (PolytomousKeyNodeDetailSection) formFactory
-                               .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE,
-                                               getConversationHolder(), parent, this, Section.TWISTIE
-                                                               | Section.EXPANDED);
+        PolytomousKeyDetailSection polytomousKeyDetailSection = (PolytomousKeyDetailSection) formFactory
+                .createCdmDetailSection(DetailType.POLYTOMOUS_KEY,
+                        getConversationHolder(), parent, this, Section.TWISTIE
+                                | Section.COMPACT);
+        
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        
+        PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = (PolytomousKeyNodeDetailSection) formFactory
+                .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE,
+                        getConversationHolder(), parent, this, Section.TWISTIE
+                                | Section.EXPANDED);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        GeographicalScopeDetailSection geographicalScopeDetailSection = (GeographicalScopeDetailSection) formFactory
+                .createEntityDetailSection(EntityDetailType.GEOGRAPHICAL_SCOPE,
+                        getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+        ScopeRestrictionSection scopeRestrictionSection = (ScopeRestrictionSection) formFactory
+                .createEntityDetailSection(EntityDetailType.SCOPE_RESTRICTION,
+                        getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);
+
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+        TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory
+                .createEntityDetailSection(EntityDetailType.TAXONOMIC_SCOPE,
+                        getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);        
+
+           addPart(polytomousKeyDetailSection);
+           addPart(geographicalScopeDetailSection);
+           addPart(scopeRestrictionSection);
+           addPart(taxonomicScopeSection);
                addPart(polytomousKeyNodeDetailSection);
        }
        
+       /**
+        * create the UseRecordSection
+        * @param parent
+        */
        private void createUseRecordSection(RootElement parent) {
                destroySections();
 
@@ -686,6 +773,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                
        }
 
+       /**
+        * createUserSection
+        * @param parent
+        */
        private void createUserSection(RootElement parent) {
                destroySections();
 
@@ -703,6 +794,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(groupByUserDetailSection);
        }
 
+       /**
+        * createTaxonRelationshipSection
+        * @param parent
+        */
        private void createTaxonRelationshipSection(RootElement parent) {
                destroySections();
 
@@ -732,6 +827,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                addPart(termVocabularyDetailSection);
        }
 
+       /**
+        * createDefinedTermSection
+        * @param parent
+        */
        private void createDefinedTermSection(RootElement parent) {
                destroySections();