(no commit message)
authora.theys <a.theys@localhost>
Wed, 25 Jan 2012 10:23:20 +0000 (10:23 +0000)
committera.theys <a.theys@localhost>
Wed, 25 Jan 2012 10:23:20 +0000 (10:23 +0000)
26 files changed:
.gitattributes
eu.etaxonomy.taxeditor.application/plugin.xml
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PalmUses.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.cdmlib/.classpath
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteUseRecordOperation.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.store/icons/leaf_detail.png [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewPart.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java [new file with mode: 0644]

index 266386012647cd5ab11f57a372da2ae532f9252d..740a6c92239a28c8d550d1b3b85731f4c2712fc5 100644 (file)
@@ -30,6 +30,7 @@ eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/SaveHand
 eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/TaxonomicEditorPlugin.java -text
 eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/BulkEditing.java -text
 eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Default.java -text
+eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PalmUses.java -text
 eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PolytomousKey.java -text
 eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Taxonomic.java -text
 eu.etaxonomy.taxeditor.application/src/main/resources/log4j.properties -text
@@ -474,6 +475,16 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/m
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/MoveMediaInListOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/RemoveImageFromDescriptionElementOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteUseRecordOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/resources/TaonDescriptionEditor.screen -text
 eu.etaxonomy.taxeditor.editor/src/main/resources/log4j.properties -text
 eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/Application.java -text
@@ -956,6 +967,7 @@ eu.etaxonomy.taxeditor.store/icons/icon.ico -text
 eu.etaxonomy.taxeditor.store/icons/icon.png -text
 eu.etaxonomy.taxeditor.store/icons/import_wiz.gif -text
 eu.etaxonomy.taxeditor.store/icons/large_image.gif -text
+eu.etaxonomy.taxeditor.store/icons/leaf_detail.png -text
 eu.etaxonomy.taxeditor.store/icons/linkto_help.gif -text
 eu.etaxonomy.taxeditor.store/icons/lockedstate.gif -text
 eu.etaxonomy.taxeditor.store/icons/ma_12x12.gif -text
@@ -1437,6 +1449,8 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/use
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailWizardPage.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java -text
@@ -1499,6 +1513,8 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/De
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/reporting/ReportingViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewPart.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java -text
 eu.etaxonomy.taxeditor.store/src/main/resources/eu/etaxonomy/cdm/editorApplicationContext.xml -text
 eu.etaxonomy.taxeditor.store/src/main/resources/log4j.properties -text
 eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/NameProtectTitleCacheTest.java -text
index 61c00707866d224a44f7bcd0a39fbc8f4533d054..1f370efc81d3f52434fd030d9dce81cff91b205d 100644 (file)
             id="eu.etaxonomy.taxeditor.application.perspective.polytomous"\r
             name="Polytomous Key">\r
       </perspective>\r
+       <perspective\r
+            class="eu.etaxonomy.taxeditor.perspective.PalmUses"\r
+            id="eu.etaxonomy.taxeditor.application.perspective.palmuses"\r
+            name="Palm Uses">\r
+      </perspective>\r
+     \r
    </extension>\r
    <!--extension\r
          point="org.eclipse.ui.views">\r
              id="eu.etaxonomy.taxeditor.editor.forms.detailsView">\r
        </showInPart>\r
     </perspectiveExtension>\r
+    <perspectiveExtension\r
+          targetID="eu.etaxonomy.taxeditor.application.perspective.palmuses">\r
+       <showInPart\r
+             id="eu.etaxonomy.taxeditor.editor.forms.detailsView">\r
+       </showInPart>\r
+    </perspectiveExtension>\r
  </extension>\r
    <extension\r
          point="org.eclipse.ui.menus">\r
diff --git a/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PalmUses.java b/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PalmUses.java
new file mode 100644 (file)
index 0000000..735c403
--- /dev/null
@@ -0,0 +1,36 @@
+/**\r
+ * \r
+ */\r
+package eu.etaxonomy.taxeditor.perspective;\r
+\r
+import org.eclipse.ui.IPageLayout;\r
+\r
+\r
+\r
+import eu.etaxonomy.taxeditor.editor.view.uses.UsesViewPart;\r
+import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;\r
+import eu.etaxonomy.taxeditor.view.userecords.UseRecordsViewPart;\r
+\r
+/**\r
+ * @author a.theys\r
+ *\r
+ */\r
+public class PalmUses extends Default {\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)\r
+        */\r
+       @Override\r
+       public void createInitialLayout(IPageLayout layout) {\r
+               layout.addView(TaxonNavigator.ID, IPageLayout.LEFT, 0.25f, layout.getEditorArea());\r
+               layout.addView(UseRecordsViewPart.ID, IPageLayout.RIGHT, 0.25f, layout.getEditorArea());\r
+               layout.addView(UsesViewPart.ID, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea());\r
+               \r
+               // layout.addView(SupplementalDataViewPart.ID, IPageLayout.BOTTOM, 0.25f, DetailsViewPart.ID);\r
+               \r
+               createAdditionalFolder(layout, layout.getEditorArea());\r
+       }\r
+       \r
+\r
+}\r
+\r
index 6b053d5451713236225db7dd0ec31b3366334700..1270f8c7e5f83115ded0e9ab56a489e43128fbb6 100644 (file)
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-3.0.9-SNAPSHOT.jar"/>\r
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-3.0.9-SNAPSHOT.jar"/>\r
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-io-3.0.9-SNAPSHOT.jar"/>\r
-       <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar" sourcepath="C:/Users/l.morris/.m2/repository/eu/etaxonomy/cdmlib-model/3.0.9-SNAPSHOT/cdmlib-model-3.0.9-SNAPSHOT-sources.jar"/>\r
-       <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.9-SNAPSHOT.jar" sourcepath="C:/Users/l.morris/.m2/repository/eu/etaxonomy/cdmlib-persistence/3.0.9-SNAPSHOT/cdmlib-persistence-3.0.9-SNAPSHOT-sources.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar" sourcepath="/cdmlib-model"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.9-SNAPSHOT.jar"/>\r
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.0.9-SNAPSHOT.jar"/>\r
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.9-SNAPSHOT.jar"/>\r
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.9-SNAPSHOT.jar" sourcepath="/cdmlib-services"/>\r
index 5a9e71d0a087e32b550b04770d683c21e54b5262..a41310e2dcebd41b0706ad5d19e64cb12d39843c 100644 (file)
@@ -12,7 +12,8 @@ Export-Package: eu.etaxonomy.taxeditor.editor,
  eu.etaxonomy.taxeditor.editor.name,
  eu.etaxonomy.taxeditor.editor.name.handler,
  eu.etaxonomy.taxeditor.editor.view.descriptive,
- eu.etaxonomy.taxeditor.editor.view.media
+ eu.etaxonomy.taxeditor.editor.view.media,
+ eu.etaxonomy.taxeditor.editor.view.uses
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
  org.eclipse.core.expressions,
index 99bef4cf7d14692d4be97fafc7c4ec8273780c2b..49bb8bda71f8a90940f9c78608983ce0e2b49420 100644 (file)
                id="eu.etaxonomy.taxeditor.editor.view.descriptive"
                name="Descriptive"
                restorable="true">
+         </view>
+          <view
+               allowMultiple="false"
+               class="eu.etaxonomy.taxeditor.editor.view.uses.UsesViewPart"
+               icon="icons/leaf.png"
+               id="eu.etaxonomy.taxeditor.editor.view.uses"
+               name="Uses"
+               restorable="true">
          </view>
          <view
                allowMultiple="false"
                style="push">
          </command>
       </menuContribution>
+      
+      
+      
+      
+      <menuContribution
+            locationURI="popup:eu.etaxonomy.taxeditor.editor.view.uses">
+         <command
+               commandId="eu.etaxonomy.taxeditor.use.commands.adduse"
+               label="New Use"
+               style="push">
+         </command>
+         <command
+               commandId="eu.etaxonomy.taxeditor.editor.use.createUseRecord"
+               label="New Use Record"
+               style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <or>
+                  <reference
+                        definitionId="isDescription">
+                  </reference>
+                  <reference
+                        definitionId="isDescriptionElement">
+                  </reference>
+                  <reference
+                        definitionId="isFeatureNodeContainer">
+                  </reference>
+               </or>
+            </visibleWhen>
+         </command>
+         <separator
+               name="eu.etaxonomy.taxeditor.usesEditor.separator3"
+               visible="true">
+         </separator>
+         <separator
+               name="taxeditor-editor.separator1"
+               visible="true">
+         </separator>
+         <separator
+               name="eu.etaxonomy.taxeditor.taxonDescriptionEditor.separator.afterNew"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.ui.edit.delete"
+               label="Delete"
+               style="push">
+         </command>
+         <separator
+               name="eu.etaxonomy.taxeditor.taxonDescriptionEditor.separator.afterDelete"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.ui.file.save"
+               label="Save"
+               style="push">
+         </command>
+      </menuContribution>
+      
+      
+      
+      
+      
       <menuContribution
             locationURI="popup:eu.etaxonomy.taxeditor.editor.view.media">
          <command
             </with>
          </activeWhen>
       </handler>
+      <handler
+            class="eu.etaxonomy.taxeditor.editor.view.uses.handler.DeleteUseHandler"
+            commandId="org.eclipse.ui.edit.delete">
+         <activeWhen>
+            <with
+                  variable="activePartId">
+               <equals
+                     value="eu.etaxonomy.taxeditor.editor.view.uses">
+               </equals>
+            </with>
+         </activeWhen>
+      </handler>
    </extension>
    <extension
+         id="eu.etaxonomy.taxeditor.editor.use.createUseRecord"
          name="Name Commands"
          point="org.eclipse.ui.commands">
       <category
             id="eu.etaxonomy.taxeditor.description.commands.moveDescriptionElements"
             name="Move Description Elements">
       </command>
+      <category
+            id="eu.etaxonomy.taxeditor.editor.view.uses.command.category"
+            name="-- New Uses">
+      </category>
+      <command
+            categoryId="eu.etaxonomy.taxeditor.editor.view.uses.command.category"
+            defaultHandler="eu.etaxonomy.taxeditor.editor.view.uses.handler.CreateUseHandler"
+            id="eu.etaxonomy.taxeditor.use.commands.adduse"
+            name="New Use">
+      </command>
+      <command
+            categoryId="eu.etaxonomy.taxeditor.editor.view.uses.command.category"
+            defaultHandler="eu.etaxonomy.taxeditor.editor.view.uses.handler.CreateUseRecordHandler"
+            id="eu.etaxonomy.taxeditor.editor.use.createUseRecord"
+            name="New Use Record">
+      </command>
       <category
             id="eu.etaxonomy.taxeditor.editor.media.category"
             name="-- Media">
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java
new file mode 100644 (file)
index 0000000..18a9a5d
--- /dev/null
@@ -0,0 +1,195 @@
+package eu.etaxonomy.taxeditor.editor.view.uses;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.UUID;\r
+\r
+import org.eclipse.jface.viewers.ITreeContentProvider;\r
+import org.eclipse.jface.viewers.Viewer;\r
+\r
+import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
+import eu.etaxonomy.cdm.model.common.Marker;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.FeatureTree;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;\r
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;\r
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+import eu.etaxonomy.taxeditor.store.TermStore;\r
+\r
+public class UsesContentProvider implements ITreeContentProvider {\r
+\r
+       private static final Object[] NO_CHILDREN = new Object[0];\r
+       private Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache;\r
+       Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+               \r
+       /**\r
+        * <p>Constructor for DescriptiveContentProvider.</p>\r
+        *\r
+        * @param featureNodeContainerCache a {@link java.util.Map} object.\r
+        */\r
+       public UsesContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {\r
+               //MarkerType markerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete"\r
+               //this.markerTypes.addAll(CdmStore.getTermManager().getPreferredMarkerTypes());\r
+               this.featureNodeContainerCache = featureNodeContainerCache;\r
+       }\r
+       \r
+\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public Object[] getChildren(Object parentElement) {\r
+               if (parentElement instanceof TaxonEditorInput) {\r
+                       return getDescriptions((TaxonEditorInput) parentElement).toArray(); \r
+               }\r
+               else if (parentElement instanceof TaxonDescription) {\r
+                       if ( ! ((TaxonDescription) parentElement).isImageGallery()) {\r
+                               TaxonDescription description = (TaxonDescription) parentElement;\r
+                               \r
+                               FeatureNodeContainerTree containerTree = getContainerTreeForDesription(description);\r
+                               \r
+                               return containerTree.getRoot().getChildren().toArray();\r
+                       }\r
+               }\r
+               else if (parentElement instanceof FeatureNodeContainer){\r
+                       FeatureNodeContainer container = (FeatureNodeContainer) parentElement;\r
+                       if(container.isLeaf()){\r
+                               return container.getDescriptionElements().toArray();\r
+                       }else{\r
+                               return container.getChildren().toArray();\r
+                       }\r
+               }\r
+               \r
+               return NO_CHILDREN;\r
+       }\r
+       \r
+       private FeatureNodeContainerTree getContainerTreeForDesription(TaxonDescription description){\r
+               if(! featureNodeContainerCache.containsKey(description)){\r
+                       FeatureNodeContainerTree containerTree = new FeatureNodeContainerTree(description, getFeatureTree(description));\r
+                       featureNodeContainerCache.put(description, containerTree);\r
+               }\r
+               return featureNodeContainerCache.get(description);\r
+       }\r
+\r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public boolean hasChildren(Object element) {\r
+               if (element instanceof TaxonDescription){\r
+                       TaxonDescription description = (TaxonDescription) element;\r
+                       FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);\r
+                       if(containerTree != null && containerTree.getRoot() != null){\r
+                               return containerTree.getRoot().getChildren().size() != 0;\r
+                       }\r
+               } \r
+               return getChildren(element).length != 0;\r
+       }\r
+       \r
+       /**\r
+        * Retrieves the feature tree associated with the given description\r
+        * \r
+        * TODO as of now this is always the same thing because feature trees may not be associated \r
+        * to descriptions yet.\r
+        * \r
+        * @param description\r
+        * @return\r
+        */\r
+       private FeatureTree getFeatureTree(DescriptionBase description){\r
+               FeatureTree featureTree = null;\r
+               \r
+               // TODO change this to the feature tree associated with this taxon description\r
+               if (description.hasStructuredData()){                                   \r
+                       featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();\r
+               }else{\r
+                       featureTree = PreferencesUtil.getDefaultFeatureTreeForTextualDescription();\r
+               }\r
+               \r
+               // create a transient tree with all features if none was selected\r
+               if(featureTree == null){\r
+                       featureTree = FeatureTree.NewInstance(TermStore.getTerms(Feature.class));\r
+               }\r
+               \r
+               return featureTree;\r
+       }\r
+\r
+       /**\r
+        * Get all descriptions associated with the given TaxonEditorInput\r
+        * \r
+        * @param parentElement\r
+        * @return\r
+        */\r
+       //CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(input.getTaxonNode().getTaxon(), null, null, null, null, null, null)\r
+       private List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) {\r
+               //this.markerTypes.addAll(CdmStore.getTermManager().getPreferredMarkerTypes());\r
+               this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class));\r
+               Taxon taxon = parentElement.getTaxon();\r
+               Set<MarkerType> typesToDisdplay = new HashSet<MarkerType>();\r
+               List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>();\r
+               List<TaxonDescription> usesDescriptions = new ArrayList<TaxonDescription>();\r
+               \r
+               /*for (MarkerType markerType : markerTypes) {\r
+                       if (markerType.toString().equals("complete")) {\r
+                               typesToDisdplay.add(markerType);\r
+                       }\r
+               }*/\r
+               //usesDescriptions = CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(taxon, null, null, typesToDisdplay, null, null, null);\r
+               //for(DescriptionBase description : CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(taxon, null, null, typesToDisdplay, null, null, null)){\r
+               for(DescriptionBase description : taxon.getDescriptions()){\r
+                       if(! description.isImageGallery()){\r
+                               Set<Marker> descriptionMarkers = description.getMarkers();\r
+                               if(descriptionMarkers != null) {\r
+                                       for (Marker marker: descriptionMarkers) {\r
+                                               //TODO Use the GetbyUUID method\r
+                                               if(marker.getMarkerType().getTitleCache().equals("use")) {\r
+                                                       descriptions.add(description);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }                       \r
+               return descriptions;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public Object getParent(Object element) {\r
+               return null;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public Object[] getElements(Object inputElement) {\r
+               return getChildren(inputElement);\r
+       }\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()\r
+        */\r
+       /**\r
+        * <p>dispose</p>\r
+        */\r
+       public void dispose() {\r
+               featureNodeContainerCache.clear();\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}    \r
+\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java
new file mode 100644 (file)
index 0000000..37968d9
--- /dev/null
@@ -0,0 +1,80 @@
+package eu.etaxonomy.taxeditor.editor.view.uses;\r
+\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;\r
+\r
+import org.eclipse.jface.viewers.ColumnLabelProvider;\r
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;\r
+import org.eclipse.jface.viewers.StyledString;\r
+\r
+import eu.etaxonomy.cdm.api.service.DefaultCategoricalDescriptionBuilder;\r
+import eu.etaxonomy.cdm.api.service.DescriptionBuilder;\r
+import eu.etaxonomy.cdm.model.common.Language;\r
+import eu.etaxonomy.cdm.model.common.LanguageString;\r
+import eu.etaxonomy.cdm.model.description.CategoricalData;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.description.TextData;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+\r
+public class UsesLabelProvider extends ColumnLabelProvider implements\r
+               IStyledLabelProvider {\r
+       \r
+       private static DescriptionBuilder<CategoricalData> categoricalDescriptionBuilder = new DefaultCategoricalDescriptionBuilder();\r
+       public String getText(Object element) {\r
+               String text = "";\r
+               /*\r
+                * return DescriptionHelper.getLabel(element);\r
+                * \r
+                * for (Marker marker : element.getMarkers()) { if\r
+                * (marker.getMarkerType().getTitleCache().equals("use")) { return\r
+                * "Use: " + text; } }\r
+                */\r
+               if (element instanceof DescriptionBase) {\r
+                       text = ((DescriptionBase) element).getTitleCache();\r
+                       if (text == null || text.length() == 0) {\r
+                               text = "Use: No label provided";\r
+                       }\r
+                       else {\r
+                               text = "Use: " + text;\r
+                       }\r
+               }\r
+               else if (element instanceof CategoricalData) {\r
+                       TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList());\r
+                       text = textData.getText(CdmStore.getDefaultLanguage());\r
+                       if (text == null || text.length() == 0) {\r
+                               text = "No data provided";\r
+                       }\r
+                       return text;\r
+               }\r
+               /*else  if (element instanceof DescriptionElementBase) {\r
+                       Map useRecordText = ((DescriptionElementBase) element).getModifyingText();\r
+                       \r
+                       \r
+                       if (text == null || text.length() == 0) {\r
+                               text = "Use Record: No label provided";\r
+                       }\r
+                       text = useRecordText.toString();\r
+                       //text = "Something else";\r
+               }*/\r
+               else{\r
+                       text = "Use Record";\r
+               }\r
+\r
+               return  text;\r
+       }\r
+\r
+       @Override\r
+       public StyledString getStyledText(Object element) {\r
+               return new StyledString(this.getText(element),\r
+                               StyledString.QUALIFIER_STYLER);\r
+       }\r
+       \r
+       private static List<Language> getLanguageList(){\r
+               return Arrays.asList(new Language[]{CdmStore.getDefaultLanguage()});\r
+       }\r
+\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java
new file mode 100644 (file)
index 0000000..cfe3bb9
--- /dev/null
@@ -0,0 +1,254 @@
+package eu.etaxonomy.taxeditor.editor.view.uses;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.action.GroupMarker;\r
+import org.eclipse.jface.action.IToolBarManager;\r
+import org.eclipse.jface.action.MenuManager;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.jface.viewers.TreeViewer;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.dnd.DND;\r
+import org.eclipse.swt.dnd.Transfer;\r
+import org.eclipse.swt.graphics.ImageData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Menu;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IWorkbenchActionConstants;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;\r
+import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;\r
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
+import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;\r
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;\r
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;\r
+import eu.etaxonomy.taxeditor.model.ImageResources;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;\r
+\r
+\r
+\r
+public class UsesViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {\r
+       \r
+       public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses";\r
+       private TreeViewer viewer;\r
+       private Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<TaxonDescription, FeatureNodeContainerTree>();\r
+       private ToggleDescriptionAction showAllElementsAction;\r
+       private ToggleDescriptionAction hideAllElementsAction;\r
+\r
+       private int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;\r
+       \r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public void createViewer(Composite parent) {\r
+               \r
+               viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL\r
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION));\r
+                               \r
+               viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));          \r
+               \r
+               //viewer.setInput(descService.listTaxonDescriptions(Taxon, null, null, null, null, null, null));\r
+               \r
+               viewer.setLabelProvider(new UsesLabelProvider());\r
+               \r
+               //viewer.setSorter(new DescriptiveViewerSorter());\r
+               \r
+               viewer.setAutoExpandLevel(2);\r
+               \r
+               \r
+               \r
+               Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };\r
+               /*viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(\r
+                               this));\r
+               viewer.addDropSupport(dndOperations, transfers,\r
+                               new DescriptionElementDropAdapter(viewer));*/\r
+                                               \r
+               // Propagate selection from viewer\r
+               getSite().setSelectionProvider(viewer);\r
+               \r
+               showAllElementsAction = new ToggleDescriptionAction(false);             \r
+               hideAllElementsAction = new ToggleDescriptionAction(true);\r
+               \r
+               // Add context menu to tree\r
+               createMenu();\r
+               \r
+               createToolbar();\r
+               \r
+               // set initial input\r
+//             if(getEditor() != null){\r
+//                     viewer.setInput(getEditor().getEditorInput());\r
+//             }\r
+       }\r
+       \r
+       private void createToolbar() {\r
+               IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();\r
+               toolBarManager.add(showAllElementsAction);\r
+               toolBarManager.add(hideAllElementsAction);\r
+       }\r
+       \r
+       private void createMenu(){\r
+               MenuManager menuManager = new MenuManager();\r
+               menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));\r
+               \r
+               getSite().registerContextMenu(menuManager, viewer);\r
+\r
+               // FIXME for some reason this is not working\r
+               menuManager.add(showAllElementsAction);\r
+               menuManager.add(hideAllElementsAction);\r
+                               \r
+               Control control = viewer.getControl();\r
+               Menu menu = menuManager.createContextMenu(control);\r
+               \r
+               control.setMenu(menu);  \r
+       }\r
+       \r
+       public void changed(Object object) {\r
+               for(FeatureNodeContainerTree containerTree : featureNodeContainerCache.values()){\r
+                       containerTree.buildTree();\r
+               }\r
+               viewer.refresh();\r
+               \r
+               /*if(object instanceof DescriptionElementBase){\r
+                       DescriptionElementBase descriptionElement = (DescriptionElementBase) object;\r
+                       DescriptionBase description = descriptionElement.getInDescription();\r
+                       FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);\r
+                       \r
+                       FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);\r
+                       viewer.expandToLevel(featureNodeContainer, 1);\r
+                       \r
+               }*/\r
+\r
+               if(object != null){\r
+                       StructuredSelection selection = new StructuredSelection(object);\r
+                       viewer.setSelection(selection, true);\r
+               }\r
+\r
+               super.changed(object);\r
+       }\r
+       \r
+       \r
+       /* (non-Javadoc)\r
+        * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()\r
+        */\r
+       /** {@inheritDoc} */\r
+       @Override\r
+       protected ISelection getInitialSelection() {\r
+               if(getEditor() != null){\r
+                       return new StructuredSelection(getEditor().getEditorInput());\r
+               }       \r
+               \r
+               return super.getInitialSelection();\r
+       }\r
+       \r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public boolean postOperation(CdmBase objectAffectedByOperation) {\r
+               return super.postOperation(objectAffectedByOperation);\r
+       }\r
+       \r
+       @Override\r
+       public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
+               if(EditorUtil.getActiveEditor() == null){\r
+                       showEmptyPage();\r
+                       return;\r
+               }\r
+               \r
+               if(part instanceof BulkEditor){\r
+                       showEmptyPage();\r
+                       return;\r
+               }\r
+               \r
+               if(part instanceof AbstractGraphKeyEditor){\r
+                       showEmptyPage();\r
+                       return;\r
+               }\r
+               \r
+               if(part instanceof MultiPageTaxonEditor){\r
+                       if(! part.equals(this.part)){\r
+                               TaxonEditorInput input = (TaxonEditorInput)((IEditorPart) part).getEditorInput();\r
+                               featureNodeContainerCache.clear();\r
+                               //showViewer(part, new StructuredSelection(CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(input.getTaxonNode().getTaxon(), null, null, null, null, null, null)));\r
+                               showViewer(part, new StructuredSelection(input));\r
+                       }\r
+                       showViewer();\r
+               }\r
+               \r
+       }\r
+\r
+       @Override\r
+       public boolean onComplete() {\r
+               return false;\r
+       }\r
+\r
+       /*@Override\r
+       public void showViewer(IWorkbenchPart part, IStructuredSelection selection) {\r
+               this.part = part;               \r
+       \r
+               Object element = selection.getFirstElement();\r
+               \r
+               getViewer().setInput(descService.listTaxonDescriptions((Taxon) element, null, null, null, null, null, null));\r
+               \r
+               showViewer();   \r
+       }*/\r
+       \r
+       @Override\r
+       public Viewer getViewer() {\r
+               return viewer;\r
+       }\r
+       \r
+       private class ToggleDescriptionAction extends Action{\r
+               private boolean expanded;\r
+               \r
+               public ToggleDescriptionAction(boolean expand){\r
+                       super(null, Action.AS_PUSH_BUTTON);\r
+                       expanded = expand;\r
+                       setImageAndTooltip();\r
+               }\r
+               \r
+               private void setImageAndTooltip(){\r
+                       setImageDescriptor(new ImageDescriptor() {\r
+                               @Override\r
+                               public ImageData getImageData() {\r
+                                       setText(expanded ? "Collapse All" : "Expand All");\r
+                                       String resource = expanded ? ImageResources.COLLAPSE_ALL : ImageResources.EXPAND_ALL;\r
+                                       return ImageResources.getImage(resource).getImageData();\r
+                               }\r
+                       });\r
+                       \r
+                       String toolTipText = expanded ? "Collapse all" : "Show all descriptive data";\r
+                       setToolTipText(toolTipText);\r
+               }\r
+               \r
+               @Override\r
+               public void run() {\r
+                       if(expanded){\r
+                               viewer.collapseAll();\r
+                       }else{\r
+                               viewer.expandAll();\r
+                       }\r
+                       setImageAndTooltip();\r
+               }\r
+       }\r
+\r
+       \r
+\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java
new file mode 100644 (file)
index 0000000..e9a71d5
--- /dev/null
@@ -0,0 +1,49 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.handler;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.common.NotDefinedException;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.forms.editor.FormEditor;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
+import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateTaxonUseOperation;\r
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+\r
+public class CreateUseHandler extends AbstractHandler {\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+               IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
+               IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;\r
+               \r
+               \r
+               IEditorPart editor = HandlerUtil.getActiveEditor(event);\r
+               if (editor instanceof FormEditor) {\r
+                       editor = ((FormEditor) editor).getActiveEditor();\r
+               }\r
+               IEditorInput input = editor.getEditorInput();\r
+               if (input instanceof TaxonEditorInput) {\r
+                       Taxon taxon = ((TaxonEditorInput) input).getTaxon();    \r
+                       AbstractPostOperation operation;\r
+                       try {\r
+                               // TODO use undo context specific to editor\r
+                               operation = new CreateTaxonUseOperation(event.getCommand().getName(), \r
+                                               EditorUtil.getUndoContext(), taxon, postOperationEnabled);\r
+                               EditorUtil.executeOperation(operation);\r
+                       } catch (NotDefinedException e) {\r
+                               EditorUtil.warn(getClass(), "Command name not set.");\r
+                       }\r
+               } \r
+               return null;\r
+       }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java
new file mode 100644 (file)
index 0000000..390cb76
--- /dev/null
@@ -0,0 +1,104 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.handler;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TextData;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateUseRecordOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+public class CreateUseRecordHandler extends AbstractHandler {
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IWorkbenchPart part = HandlerUtil.getActivePart(event);
+               IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part
+                               : null;
+
+               IEditorPart editor = HandlerUtil.getActiveEditor(event);
+               if (editor instanceof FormEditor) {
+                       editor = ((FormEditor) editor).getActiveEditor();
+               }
+               IEditorInput input = editor.getEditorInput();
+               if (input instanceof TaxonEditorInput) {
+                       Taxon taxon = ((TaxonEditorInput) input).getTaxon();
+
+                       TaxonDescription description = null;
+
+                       ISelection selection = HandlerUtil.getActiveMenuSelection(event);
+                       if (selection instanceof ITreeSelection) {
+                               TreePath[] paths = ((ITreeSelection) selection).getPaths();
+                               Object firstSegment = paths[0].getFirstSegment();
+                               if (firstSegment instanceof TaxonDescription) {
+                                       description = (TaxonDescription) firstSegment;
+                               }
+                       }else if (selection instanceof IStructuredSelection) {
+                               Object selectedElement = ((IStructuredSelection) selection)
+                                               .getFirstElement();
+                               if (selectedElement instanceof TaxonDescription){
+                                       description = (TaxonDescription) selectedElement;
+                               }
+                       } 
+
+                       if (description != null) {
+                               //CategoricalData element = CategoricalData.NewInstance();
+                               AbstractPostOperation operation = null;
+                               try {
+                                       List<Feature> features = CdmStore.getTermManager().getPreferredTerms(Feature.class);
+                                       //TextData element = TextData.NewInstance();
+                                       /*TextData feature  = TextData.NewInstance();
+                                       *Feature feature = (Feature) HibernateProxyHelper.deproxy(feature);*/
+                                       for (Feature feature : features) {
+                                               if(feature.getTitleCache().equals("Use Record")) {
+                                                       feature.setSupportsCategoricalData(true);
+                                                       //CategoricalData element = CategoricalData.NewInstance();
+                                                       //element.setFeature(feature);
+                                                       /*operation = new CreateUseRecordOperation(event
+                                                                       .getCommand().getName(),
+                                                                       EditorUtil.getUndoContext(), taxon,
+                                                                       description, feature, postOperationEnabled);*/
+                                                       operation = new CreateUseRecordOperation(event
+                                                                       .getCommand().getName(),
+                                                                       EditorUtil.getUndoContext(), taxon,
+                                                                       description, feature, postOperationEnabled);
+                                                                       
+                                               }
+                                       }
+                                       // TODO use undo context specific to editor
+                                       
+                                       EditorUtil.executeOperation(operation);
+                               } catch (NotDefinedException e) {
+                                       EditorUtil.warn(getClass(), "Command name not set");
+                               }
+                       } else {
+                               EditorUtil.error(getClass(), new IllegalArgumentException("Could not determine the taxon description"));
+                               return null;
+                       }
+               }
+               return null;
+
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java
new file mode 100644 (file)
index 0000000..0028fc3
--- /dev/null
@@ -0,0 +1,110 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.handler;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.common.NotDefinedException;\r
+import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.TreePath;\r
+import org.eclipse.jface.viewers.TreeSelection;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.media.Media;\r
+import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;\r
+import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation;\r
+import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteTaxonUseOperation;\r
+import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteUseRecordOperation;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+\r
+public class DeleteUseHandler extends AbstractHandler {\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.\r
+        * ExecutionEvent)\r
+        */\r
+       /** {@inheritDoc} */\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+               IStructuredSelection selection = (IStructuredSelection) HandlerUtil\r
+                               .getActiveSite(event).getSelectionProvider().getSelection();\r
+\r
+               IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
+               IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part\r
+                               : null;\r
+\r
+               try {\r
+                       String label = event.getCommand().getName();\r
+\r
+                       IUndoContext undoContext = EditorUtil.getUndoContext();\r
+\r
+                       List<AbstractPostOperation> operations = new ArrayList<AbstractPostOperation>();\r
+\r
+                       for (Object object : selection.toArray()) {\r
+\r
+                               AbstractPostOperation operation = null;\r
+\r
+                               // TaxonDescription\r
+                               if (object instanceof TaxonDescription) {\r
+                                       operations.add(new DeleteTaxonUseOperation(label,\r
+                                                       undoContext, (TaxonDescription) object,\r
+                                                       postOperationEnabled));\r
+                               }\r
+                               // DescriptionElementBase\r
+                               else if (object instanceof DescriptionElementBase) {\r
+                                       operations.add(new DeleteUseRecordOperation(label,\r
+                                                       undoContext, (DescriptionElementBase) object,\r
+                                                       postOperationEnabled));\r
+                               } else if (object instanceof FeatureNodeContainer) {\r
+                                       List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) object)\r
+                                                       .getDescriptionElementsForEntireBranch();\r
+\r
+                                       for (DescriptionElementBase description : descriptions) {\r
+                                               operations.add(new DeleteUseRecordOperation(\r
+                                                               label, undoContext, description,\r
+                                                               postOperationEnabled));\r
+                                       }\r
+                               }\r
+                               // Media\r
+                               else if (object instanceof Media) {\r
+                                       TreeSelection treeSelection = (TreeSelection) selection;\r
+\r
+                                       TreePath[] path = treeSelection.getPathsFor(object);\r
+\r
+                                       TaxonDescription imageGallery = (TaxonDescription) path[0]\r
+                                                       .getFirstSegment();\r
+\r
+                                       operations\r
+                                                       .add(new DeleteMediaOperation(label, undoContext,\r
+                                                                       imageGallery, (Media) object,\r
+                                                                       postOperationEnabled));\r
+                               } else {\r
+                                       EditorUtil.error(getClass(),\r
+                                                       "Selection is not valid for this delete handler",\r
+                                                       null);\r
+                               }\r
+                       }\r
+\r
+                       // execute all cumulated operations\r
+                       for (AbstractPostOperation operation : operations) {\r
+                               EditorUtil.executeOperation(operation);\r
+                       }\r
+\r
+               } catch (NotDefinedException e) {\r
+                       EditorUtil.warn(getClass(), "Command name not set.");\r
+               }\r
+\r
+               return null;\r
+       }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java
new file mode 100644 (file)
index 0000000..b8ca26e
--- /dev/null
@@ -0,0 +1,114 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.operation;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+\r
+import eu.etaxonomy.cdm.model.common.Marker;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.description.TextData;\r
+import eu.etaxonomy.cdm.model.media.Media;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+\r
+public class CreateTaxonUseOperation extends AbstractPostOperation {\r
+       private TaxonDescription description;\r
+       private boolean isImageGallery;\r
+       private Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+       private Marker marker;\r
+\r
+       /**\r
+        * <p>Constructor for CreateTaxonDescriptionOperation.</p>\r
+        *\r
+        * @param label a {@link java.lang.String} object.\r
+        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.\r
+        * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.\r
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.\r
+        */\r
+       public CreateTaxonUseOperation(String label, IUndoContext undoContext,\r
+                       Taxon taxon, IPostOperationEnabled postOperationEnabled) {\r
+               this(label, undoContext, taxon, postOperationEnabled, false);\r
+       }\r
+\r
+       /**\r
+        * <p>Constructor for CreateTaxonDescriptionOperation.</p>\r
+        *\r
+        * @param label a {@link java.lang.String} object.\r
+        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.\r
+        * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.\r
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.\r
+        * @param isImageGallery a boolean.\r
+        */\r
+       public CreateTaxonUseOperation(String label, IUndoContext undoContext,\r
+                       Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {\r
+               super(label, undoContext, taxon, postOperationEnabled);\r
+               this.isImageGallery  = isImageGallery;\r
+       }\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+        */\r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+               \r
+               description = TaxonDescription.NewInstance(taxon);\r
+               monitor.worked(20);\r
+               //this.markerTypes.addAll(CdmStore.getTermManager().getPreferredMarkerTypes());\r
+               this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class));\r
+               Set<MarkerType> typesToDisdplay = new HashSet<MarkerType>();\r
+               for (MarkerType markerType : markerTypes) {\r
+                       if (markerType.getTitleCache().equals("use")) {\r
+                               marker = Marker.NewInstance(markerType, true);\r
+                               description.addMarker(marker);\r
+                       }\r
+               }\r
+               if(isImageGallery){\r
+                       description.setImageGallery(isImageGallery);\r
+                       // add the description element to hold the media elements for this image gallery\r
+                       TextData element = TextData.NewInstance(Feature.IMAGE());\r
+                       element.addMedia(Media.NewInstance());\r
+                       description.addElement(element);\r
+               }\r
+               monitor.worked(40);\r
+\r
+               return postExecute(description);\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+        */\r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+               \r
+               taxon.addDescription(description);\r
+               \r
+               return postExecute(description);\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+        */\r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+\r
+               taxon.removeDescription(description);\r
+               \r
+               return postExecute(null);\r
+       }\r
+}\r
+\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java
new file mode 100644 (file)
index 0000000..90fd7e6
--- /dev/null
@@ -0,0 +1,109 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.operation;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.CommonTaxonName;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Distribution;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TaxonInteraction;
+import eu.etaxonomy.cdm.model.description.TextData;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+public class CreateUseRecordOperation extends AbstractPostOperation {
+       
+       public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
+       
+       private TaxonDescription description;
+       private Feature feature;
+       private DescriptionElementBase element;
+
+       
+       /*public CreateUseRecordOperation(String label, IUndoContext undoContext,
+                       Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {*/
+       public CreateUseRecordOperation(String label, IUndoContext undoContext,
+               Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {
+                       super(label, undoContext, taxon, postOperationEnabled);
+               
+                       this.description = description;
+                       this.feature = feature;
+       }
+
+       public CreateUseRecordOperation(String label,
+                       IUndoContext undoContext, Taxon taxon,
+                       TaxonDescription description, Feature feature,
+                       DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
+                       /*public CreateUseRecordOperation(String label,
+                                       IUndoContext undoContext, Taxon taxon,
+                                       TaxonDescription description, Feature feature,
+                                       DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {*/
+                       
+                               this(label, undoContext, taxon, description, feature, postOperationEnabled);
+                               //this(label, undoContext, taxon, description, (CategoricalData) element, postOperationEnabled);
+               
+               this.element = element;
+       }
+
+       @Override
+       public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+                       throws ExecutionException {
+               monitor.worked(20);
+               if (element == null) {
+                       if (feature.isSupportsCommonTaxonName()) {
+                               element = CommonTaxonName.NewInstance("", null);
+                       } 
+                       else if (feature.isSupportsDistribution()) {
+                               element = Distribution.NewInstance();
+                       } 
+                       else if(feature.isSupportsTaxonInteraction()){
+                               element = TaxonInteraction.NewInstance();
+                       }
+                       else if(feature.isSupportsIndividualAssociation()){
+                               element = IndividualsAssociation.NewInstance();
+                       }
+                       else if(feature.isSupportsCategoricalData()){
+                               element = CategoricalData.NewInstance();
+                       }
+                       else if(feature.isSupportsQuantitativeData()){
+                               element = QuantitativeData.NewInstance();
+                       }
+                       else {
+                               element = TextData.NewInstance();
+                       }
+               }
+
+               
+               element.setFeature(feature);
+               description.addElement(element);
+               monitor.worked(40);
+
+               return postExecute(element);
+       }
+
+       @Override
+       public IStatus redo(IProgressMonitor monitor, IAdaptable info)
+                       throws ExecutionException {
+               
+               description.addElement(element);
+               
+               return postExecute(element);
+       }
+
+       @Override
+       public IStatus undo(IProgressMonitor monitor, IAdaptable info)
+                       throws ExecutionException {
+               description.removeElement(element);
+               
+               return postExecute(null);
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java
new file mode 100644 (file)
index 0000000..66a5073
--- /dev/null
@@ -0,0 +1,70 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.operation;\r
+\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+\r
+public class DeleteTaxonUseOperation extends AbstractPostOperation {\r
+               \r
+               private TaxonDescription description;\r
+\r
+               /**\r
+                * <p>Constructor for DeleteTaxonDescriptionOperation.</p>\r
+                *\r
+                * @param label a {@link java.lang.String} object.\r
+                * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.\r
+                * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.\r
+                * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.\r
+                */\r
+               public DeleteTaxonUseOperation(String label, IUndoContext undoContext,\r
+                               TaxonDescription description, IPostOperationEnabled postOperationEnabled) {\r
+                       super(label, undoContext, postOperationEnabled);\r
+                       \r
+                       this.description = description;\r
+                       taxon = description.getTaxon();\r
+               }\r
+\r
+               /* (non-Javadoc)\r
+                * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+                */\r
+               /** {@inheritDoc} */\r
+               @Override\r
+               public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
+                               throws ExecutionException {\r
+\r
+                       monitor.worked(20);\r
+                       taxon.removeDescription(description);\r
+                       monitor.worked(40);\r
+\r
+                       return postExecute(description);\r
+               }\r
+\r
+               /* (non-Javadoc)\r
+                * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+                */\r
+               /** {@inheritDoc} */\r
+               @Override\r
+               public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
+                               throws ExecutionException {\r
+                       return execute(monitor, info);\r
+               }\r
+\r
+               /* (non-Javadoc)\r
+                * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
+                */\r
+               /** {@inheritDoc} */\r
+               @Override\r
+               public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
+                               throws ExecutionException {\r
+\r
+                       taxon.addDescription(description);\r
+                       \r
+                       return postExecute(null);\r
+               }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteUseRecordOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteUseRecordOperation.java
new file mode 100644 (file)
index 0000000..b50e4bd
--- /dev/null
@@ -0,0 +1,64 @@
+package eu.etaxonomy.taxeditor.editor.view.uses.operation;\r
+\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.store.StoreUtil;\r
+\r
+public class DeleteUseRecordOperation extends AbstractPostOperation {\r
+       private DescriptionElementBase element;\r
+       private DescriptionBase description = null;\r
+       \r
+       \r
+       public DeleteUseRecordOperation(String label, IUndoContext undoContext,\r
+                       DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {\r
+               super(label, undoContext, postOperationEnabled);\r
+               \r
+               this.element = element;\r
+       }\r
+\r
+\r
+       @Override\r
+       public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+               description = element.getInDescription();\r
+               \r
+               monitor.worked(20);\r
+               \r
+               // Remove element from description\r
+               if (description == null) {\r
+                       StoreUtil.error(this.getClass(), "Couldn't find element's description!", null);\r
+               } else {\r
+                       description.removeElement(element);\r
+               }\r
+               monitor.worked(40);\r
+\r
+        // Redraw editor if exists\r
+               return postExecute(null);\r
+       }\r
+\r
+\r
+       @Override\r
+       public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+               return execute(monitor, info);\r
+       }\r
+\r
+\r
+       @Override\r
+       public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
+                       throws ExecutionException {\r
+\r
+               description.addElement(element);\r
+               \r
+               return postExecute(element);\r
+       }\r
+       \r
+}\r
index 9dd02b8e828423153a49df7c7dcd98e190da624c..160d8fe74bf06852964f487f2be34677019ae211 100644 (file)
@@ -46,11 +46,11 @@ Export-Package: eu.etaxonomy.cdm,
  eu.etaxonomy.taxeditor.view.datasource,
  eu.etaxonomy.taxeditor.view.datasource.handler,
  eu.etaxonomy.taxeditor.view.detail,
- eu.etaxonomy.taxeditor.view.supplementaldata
+ eu.etaxonomy.taxeditor.view.supplementaldata,
+ eu.etaxonomy.taxeditor.view.userecords
 Require-Bundle: org.eclipse.osgi,
  org.eclipse.ui,
  org.eclipse.jface.text,
- org.eclipse.pde.runtime,
  org.eclipse.ui.forms,
  eu.etaxonomy.taxeditor.cdmlib
 Import-Package: org.eclipse.core.commands,
diff --git a/eu.etaxonomy.taxeditor.store/icons/leaf_detail.png b/eu.etaxonomy.taxeditor.store/icons/leaf_detail.png
new file mode 100644 (file)
index 0000000..217c601
Binary files /dev/null and b/eu.etaxonomy.taxeditor.store/icons/leaf_detail.png differ
index 3e8d1ac8a5dc82fe8e5729f3851267f675a2eaf3..09d10f1b45c63fcd9238bbc0a94b7a320ab47364 100644 (file)
         id="eu.etaxonomy.taxeditor.view.detail"
         name="Details"
         restorable="true">
+  </view>
+  <view
+        class="eu.etaxonomy.taxeditor.view.userecords.UseRecordsViewPart"
+        icon="icons/leaf_detail.png"
+        id="eu.etaxonomy.taxeditor.view.userecords"
+        name="Use Records"
+        restorable="true">
   </view>
    </extension>
    <extension
index 835ca848861e3ca54cf337cd585e213e8608ccf4..7b53cb8364a35792a04dac7f55b2dc9df8330049 100644 (file)
@@ -56,6 +56,7 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
 import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
 import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.view.userecords.UseRecordsViewPart;
 
 /**
  * <p>
@@ -909,4 +910,30 @@ public abstract class AbstractUtility {
                                        .reflow();
                }
        }
+       
+       public static UseRecordsViewPart getUseRecordsView() {
+               return (UseRecordsViewPart) getView(UseRecordsViewPart.ID, false);
+       }
+
+       /**
+        * <p>
+        * refreshUseRecordsViewer
+        * </p>
+        */
+       public static void refreshUseRecordsViewer() {
+               if (getUseRecordsView() != null) {
+                       ((AbstractCdmDataViewer) getUseRecordsView().getViewer()).refresh();
+               }
+       }
+
+       /**
+        * <p>
+        * reflowUseRecordsViewer
+        * </p>
+        */
+       public static void reflowUseRecordsViewer() {
+               if (getUseRecordsView() != null) {
+                       ((AbstractCdmDataViewer) getUseRecordsView().getViewer()).reflow();
+               }
+       }
 }
index 467acc68ab268218e6d620a4d43adfe3b71d7ca8..bada117220dbfd9975e381ca66da82d828ecf4d5 100644 (file)
@@ -381,6 +381,7 @@ public class DescriptionHelper {
                if (text == null || text.length() == 0) {
                        text = "No label provided";
                }
+               
                return "Description: " + text;
        }
        
index 7210fc710d12e958a7abbf249f8f65a8a26276c7..754660a8d5b883a14e8aeb585c76381c7d728d09 100644 (file)
@@ -51,7 +51,7 @@ public class DescriptionDetailElement extends AbstractCdmDetailElement<Descripti
                detailDescription = formFactory.createMultilineTextWithLabel(this, "Label", 50, SWT.WRAP);
                detailDescription.setText(entity.getTitleCache());
                
-//             selection_featureTree = (FeatureTreeSelectionElement) formFactory.createSelectionElement(SelectionType.FEATURE_TREE, getConversationHolder(), formElement, "Feature Tree", null, style);
+               selection_featureTree = (FeatureTreeSelectionElement) formFactory.createSelectionElement(SelectionType.FEATURE_TREE, getConversationHolder(), formElement, "Feature Tree", null, style, 1);
        }
        
        /** {@inheritDoc} */
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java
new file mode 100644 (file)
index 0000000..bd78627
--- /dev/null
@@ -0,0 +1,69 @@
+package eu.etaxonomy.taxeditor.ui.section.userecords;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.forms.widgets.Section;\r
+\r
+import eu.etaxonomy.cdm.model.description.CategoricalData;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.description.State;\r
+import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;\r
+import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;\r
+import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;\r
+import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;\r
+import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;\r
+\r
+//public class UseRecordDetailElement extends AbstractDetailedDescriptionDetailElement<CategoricalData> {\r
+public class UseRecordDetailElement extends AbstractCdmDetailElement<CategoricalData> {\r
+\r
+       \r
+       private static final Logger logger = Logger\r
+                       .getLogger(DescriptionElementDetailElement.class);\r
+       \r
+       private CheckboxElement checkbox_orderRelevant;\r
+       private TermComboElement UseCategory_stateData;\r
+       private UseSubCategorySection UseSubCategory_stateData;\r
+       //private AbstractDetailedDescriptionDetailElement detailElement;\r
+       \r
+       /*public UseRecordDetailElement(CdmFormFactory formFactory,\r
+                       ICdmFormElement formElement, CategoricalData entity, int style) {\r
+               super(formFactory, formElement, entity, style);\r
+       }*/\r
+       /*public UseRecordDetailElement(CdmFormFactory formFactory,\r
+                       ICdmFormElement formElement, int style) {*/\r
+       public UseRecordDetailElement(CdmFormFactory formFactory,\r
+                       ICdmFormElement formElement) {\r
+               super(formFactory, formElement);\r
+       }\r
+       \r
+       /** {@inheritDoc} */\r
+       @Override\r
+       protected void createControls(ICdmFormElement formElement,\r
+                       CategoricalData entity, int style) {\r
+               \r
+               \r
+               State state = State.NewInstance("Tato", "Toto", "Titi");\r
+               //checkbox_orderRelevant = formFactory.createCheckbox(formElement, "Order Relevant", entity.getOrderRelevant(), style);\r
+               UseCategory_stateData = formFactory.createTermComboElement(State.class, this, "Use Category", state , style);\r
+               //createEntityDetailSection(EntityDetailType.USE_CAT, getConversationHolder(), formElement, Section.EXPANDED);\r
+               UseSubCategory_stateData = (UseSubCategorySection) formFactory.createEntityDetailSection(EntityDetailType.USE_SUBCAT, getConversationHolder(), formElement,Section.EXPANDED);\r
+               //UseCategory_stateData.setEntity(entity);\r
+               UseSubCategory_stateData.setEntity(entity);\r
+               //UseCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));\r
+               UseSubCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));\r
+               \r
+       }\r
+       \r
+       \r
+       /** {@inheritDoc} */\r
+       @Override\r
+       public void handleEvent(Object eventSource) {\r
+               if(eventSource == checkbox_orderRelevant){\r
+                       getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection());\r
+               }\r
+       }\r
+\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java
new file mode 100644 (file)
index 0000000..38f0fd3
--- /dev/null
@@ -0,0 +1,35 @@
+package eu.etaxonomy.taxeditor.ui.section.userecords;\r
+\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+\r
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;\r
+import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;\r
+import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;\r
+\r
+public class UseRecordDetailSection extends AbstractCdmDetailSection<DescriptionElementBase> {\r
+       public UseRecordDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,\r
+                       ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {\r
+               super(cdmFormFactory, conversation, parentElement, selectionProvider, style);\r
+       }\r
+\r
+       @Override\r
+       protected DetailType getDetailType() {\r
+               return DetailType.USE_RECORD;\r
+       }\r
+\r
+       @Override\r
+       public String getHeading() {\r
+               return "Use Record";\r
+       }\r
+       \r
+       /** {@inheritDoc} */\r
+       @Override\r
+       protected void setSectionTitle() {\r
+               this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));\r
+               setTextClient(createToolbar());\r
+       }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewPart.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewPart.java
new file mode 100644 (file)
index 0000000..c87beb8
--- /dev/null
@@ -0,0 +1,98 @@
+package eu.etaxonomy.taxeditor.view.userecords;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;\r
+import eu.etaxonomy.taxeditor.store.StoreUtil;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;\r
+\r
+\r
+       public class UseRecordsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{\r
+               \r
+               public static String ID = "eu.etaxonomy.taxeditor.view.userecords";\r
+               private UseRecordsViewer viewer;\r
+               \r
+               @Override\r
+               public void createViewer(Composite parent) {\r
+                       //selectionService.addPostSelectionListener(this);\r
+                       \r
+                       viewer = new UseRecordsViewer(parent, this);\r
+                       getSite().setSelectionProvider(viewer);\r
+                       \r
+               }\r
+               \r
+               @Override\r
+               public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
+                       if(StoreUtil.getActiveEditor() == null){\r
+                               showEmptyPage();\r
+                               return;\r
+                       }\r
+                       \r
+                       if(part == this){\r
+                               return;\r
+                       }\r
+                       \r
+                       if(!(selection instanceof IStructuredSelection)){\r
+                               return;\r
+                       }\r
+                       \r
+                       IStructuredSelection structuredSelection = (IStructuredSelection) selection;\r
+                       \r
+                       if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {\r
+                               if(structuredSelection.size() != 1){\r
+                                       showEmptyPage();\r
+                                       return;\r
+                               }\r
+                               \r
+                               // do not show details for feature nodes TODO really? \r
+                               if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){\r
+                                       // do show the map for distributions\r
+                                       Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();\r
+                                       if(!feature.equals(Feature.DISTRIBUTION())){\r
+                                               showEmptyPage();\r
+                                               return;\r
+                                       }\r
+                               }\r
+                               \r
+                               showViewer(part, structuredSelection);\r
+                       }else{\r
+                               showEmptyPage();                \r
+                       }       \r
+                       \r
+               }\r
+               \r
+               @Override\r
+               public Viewer getViewer() {\r
+                       return viewer;\r
+               }\r
+\r
+               /** {@inheritDoc} */\r
+               @Override\r
+               public void dispose() {\r
+                       super.dispose();\r
+                       selectionService.removePostSelectionListener(this);\r
+               }\r
+\r
+               /**\r
+                * <p>onComplete</p>\r
+                *\r
+                * @return a boolean.\r
+                */\r
+               public boolean onComplete() {\r
+                       return true;\r
+               }\r
+\r
+               \r
+\r
+               \r
+\r
+       \r
+       }\r
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java
new file mode 100644 (file)
index 0000000..047a4a0
--- /dev/null
@@ -0,0 +1,251 @@
+package eu.etaxonomy.taxeditor.view.userecords;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.SelectionChangedEvent;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.forms.widgets.Section;\r
+\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.taxeditor.ui.forms.RootElement;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;\r
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;\r
+import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;\r
+import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;\r
+import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;\r
+import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;\r
+import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;\r
+import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;\r
+\r
+\r
+\r
+\r
+\r
+public class UseRecordsViewer extends AbstractCdmDataViewer {\r
+\r
+       private ISelection selection;\r
+       \r
+       public UseRecordsViewer(Composite parent, AbstractCdmViewPart viewPart) {\r
+               super(parent, viewPart);\r
+       }\r
+       @Override\r
+       protected void showParts() {\r
+               if (getInput() instanceof TaxonBase) {\r
+                       createTaxonSections(rootElement);\r
+\r
+               } else if (getInput() instanceof DescriptionBase) {\r
+                       if (((DescriptionBase) getInput()).isImageGallery()) {\r
+                               createImageGallerySection(rootElement);\r
+\r
+                       } else {\r
+                               createUseSection(rootElement);\r
+\r
+                       }\r
+               } else if (getInput() instanceof DescriptionElementBase) {\r
+                       createUseRecordSection(rootElement);\r
+\r
+               } \r
+               \r
+               /*if (getInput() instanceof TaxonBase) {\r
+                       if (currentViewPart != VIEW_PART.TAXON) {\r
+                               createTaxonSections(rootElement);\r
+                               currentViewPart = VIEW_PART.TAXON;\r
+                       }\r
+               } else if (getInput() instanceof Reference) {\r
+                       if (currentViewPart != VIEW_PART.REFEERENCE) {\r
+                               createReferenceSections(rootElement);\r
+                               currentViewPart = VIEW_PART.REFEERENCE;\r
+                       }\r
+               } else if (getInput() instanceof DescriptionBase) {\r
+                       if (((DescriptionBase) getInput()).isImageGallery()) {\r
+                               if (currentViewPart != VIEW_PART.IMAGE_GALLERY) {\r
+                                       createImageGallerySection(rootElement);\r
+                                       currentViewPart = VIEW_PART.IMAGE_GALLERY;\r
+                               }\r
+                       } else {\r
+                               if (currentViewPart != VIEW_PART.DESCRIPTION) {\r
+                                       createDescriptionSection(rootElement);\r
+                                       currentViewPart = VIEW_PART.DESCRIPTION;\r
+                               }\r
+                       }\r
+               } else if (getInput() instanceof DescriptionElementBase) {\r
+                       if (currentViewPart != VIEW_PART.DESCRIPTION_ELEMENT) {\r
+                               createDescriptionElementSection(rootElement);\r
+                               currentViewPart = VIEW_PART.DESCRIPTION_ELEMENT;\r
+                       }\r
+               } else {\r
+                       destroySections();\r
+                       currentViewPart = VIEW_PART.EMPTY;\r
+               }\r
+               layout();\r
+               */\r
+       }\r
+       private void createTaxonSections(RootElement parent) {\r
+               destroySections();\r
+\r
+               TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.TAXONBASE,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.NONVIRALNAME,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory\r
+                               .createEntityDetailSection(\r
+                                               EntityDetailType.NOMENCLATURALSTATUS,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               ProtologueSection protologSection = (ProtologueSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.PROTOLOG,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory\r
+                               .createCdmDetailSection(DetailType.PARSINGMESSAGE,\r
+                                               getConversationHolder(), parent, this, Section.EXPANDED);\r
+\r
+               addPart(taxonBaseDetailSection);\r
+               addPart(nonViralNameSection);\r
+               addPart(nomenclaturalStatusSection);\r
+               addPart(protologSection);\r
+               addPart(referenceDetailSection);\r
+               addPart(typeDesignationSection);\r
+               addPart(nameRelationshipSection);\r
+               addPart(parsingMessagesSection);\r
+       }\r
+       \r
+       \r
+       private void createUseRecordSection(RootElement parent) {\r
+               destroySections();\r
+\r
+               UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.USE_RECORD,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+               \r
+               addPart(descriptionUseRecordSection);\r
+               \r
+               \r
+       }\r
+       \r
+       private void createUseSection(RootElement parent) {\r
+               destroySections();\r
+               DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.DESCRIPTION,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               /*NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory\r
+                               .createCdmDetailSection(DetailType.NATURAL_LANGUAGE,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/\r
+\r
+               DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               /*formFactory.createHorizontalSeparator(parent, SWT.BORDER);\r
+\r
+               ScopeSection scopeSection = (ScopeSection) formFactory\r
+                               .createEntityDetailSection(EntityDetailType.SCOPE,\r
+                                               getConversationHolder(), parent, Section.TWISTIE);\r
+\r
+               formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/\r
+\r
+               addPart(descriptionDetailSection);\r
+               addPart(descriptionSourceSection);\r
+               \r
+       }\r
+       \r
+       \r
+       \r
+       private void createImageGallerySection(RootElement parent) {\r
+               destroySections();\r
+               DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.DESCRIPTION,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               addPart(descriptionDetailSection);\r
+       }\r
+       \r
+       private void createReferenceSections(RootElement parent) {\r
+               destroySections();\r
+\r
+               ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory\r
+                               .createCdmDetailSection(DetailType.REFERENCEBASE,\r
+                                               getConversationHolder(), parent, this, Section.TWISTIE\r
+                                                               | Section.EXPANDED);\r
+\r
+               addPart(referenceDetailSection);\r
+               \r
+       }\r
+       @Override\r
+       public ISelection getSelection() {\r
+               return selection;\r
+       }\r
+       @Override\r
+       public void setSelection(ISelection selection, boolean reveal) {\r
+               this.selection = selection;\r
+               SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(\r
+                               this, selection);\r
+               fireSelectionChanged(selectionChangedEvent);\r
+       }\r
+\r
+}\r