Add geoscopes and taxonomic scope as subsection to polytomous key detail
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 21 Sep 2015 14:57:26 +0000 (16:57 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 22 Sep 2015 07:49:28 +0000 (09:49 +0200)
element

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/CreateFieldUnitHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopePolyKeyDetailSection.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/CreateFieldUnitHandler.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/CreateFieldUnitHandler.java
new file mode 100644 (file)
index 0000000..60ca90f
--- /dev/null
@@ -0,0 +1,21 @@
+package eu.etaxonomy.taxeditor.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class CreateFieldUnitHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+        if(currentSelection instanceof IStructuredSelection){
+            System.out.println(currentSelection);
+        }
+        return null;
+    }
+
+}
index 0d397df21957c33d9764d3e879cc2302741b1781..d0255238423d81458506fe3a027f3c8144f8e86d 100644 (file)
@@ -224,6 +224,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSectio
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
@@ -2332,6 +2333,12 @@ public class CdmFormFactory extends FormToolkit {
         return section;
     }
 
         return section;
     }
 
+    public GeoScopePolyKeyDetailSection createGeoScopePolyKeyDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
+        GeoScopePolyKeyDetailSection section = new GeoScopePolyKeyDetailSection(this, conversation, parentElement, style);
+        addAndAdaptSection(parentElement, section);
+        return section;
+    }
+
     public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
         IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
         addAndAdaptSection(parentElement, section);
     public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
         IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
         addAndAdaptSection(parentElement, section);
index e5c8c9fb0b2719bf655f85a6771d2c639177aeac..de294870ebe18393972e29494ad4ee6262be2822 100644 (file)
@@ -3,13 +3,17 @@
  */
 package eu.etaxonomy.taxeditor.ui.section.key;
 
  */
 package eu.etaxonomy.taxeditor.ui.section.key;
 
+import org.eclipse.swt.SWT;
+
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
 
 /**
  * @author n.hoffmann
 
 /**
  * @author n.hoffmann
@@ -20,6 +24,8 @@ public class PolytomousKeyDetailElement extends
 
     private TextWithLabelElement textLabel;
     private NumberWithLabelElement numberStartNumber;
 
     private TextWithLabelElement textLabel;
     private NumberWithLabelElement numberStartNumber;
+    private TaxonomicScopeSection sectionTaxonomicScope;
+    private GeoScopePolyKeyDetailSection sectionGeoScopes;
 
        public PolytomousKeyDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
 
        public PolytomousKeyDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
@@ -30,20 +36,22 @@ public class PolytomousKeyDetailElement extends
        protected void createControls(ICdmFormElement formElement,
                        PolytomousKey entity, int style) {
            textLabel = formFactory.createTextWithLabelElement(formElement, "Title", entity.getTitleCache(), style);
        protected void createControls(ICdmFormElement formElement,
                        PolytomousKey entity, int style) {
            textLabel = formFactory.createTextWithLabelElement(formElement, "Title", entity.getTitleCache(), style);
-            numberStartNumber = formFactory.createNumberTextWithLabelElement(formElement, "Start Number", entity.getStartNumber(), style);
+
+           numberStartNumber = formFactory.createNumberTextWithLabelElement(formElement, "Start Number", entity.getStartNumber(), style);
+
+           sectionTaxonomicScope = formFactory.createTaxonomicScopeSection(getConversationHolder(), formElement, style);
+           sectionTaxonomicScope.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+           sectionTaxonomicScope.setEntity(entity);
+
+           sectionGeoScopes = formFactory.createGeoScopePolyKeyDetailSection(getConversationHolder(), formElement, SWT.NULL);
+           sectionGeoScopes.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+           sectionGeoScopes.setEntity(entity);
        }
 
        public String getText() {
            return textLabel.getText();
        }
 
        }
 
        public String getText() {
            return textLabel.getText();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
-        * .lang.Object)
-        */
        @Override
        public void handleEvent(Object eventSource) {
                if(eventSource==textLabel){
        @Override
        public void handleEvent(Object eventSource) {
                if(eventSource==textLabel){
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopePolyKeyDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopePolyKeyDetailSection.java
new file mode 100644 (file)
index 0000000..2c5cdc6
--- /dev/null
@@ -0,0 +1,74 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.ui.section.occurrence;
+
+import java.util.Collection;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+
+/**
+ *
+ * @author pplitzner
+ * @date Sep 21, 2015
+ *
+ */
+public class GeoScopePolyKeyDetailSection extends AbstractEntityCollectionSection<PolytomousKey, NamedArea> {
+
+    public GeoScopePolyKeyDetailSection(CdmFormFactory formFactory,
+                       ConversationHolder conversation, ICdmFormElement parentElement, int style) {
+               super(formFactory, conversation, parentElement, "Geo Scopes", style);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public Collection<NamedArea> getCollection(PolytomousKey entity) {
+               return entity.getGeographicalScope();
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public NamedArea createNewElement() {
+               NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
+
+               return selection;
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public void addElement(NamedArea element) {
+               getEntity().addGeographicalScope(element);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public void removeElement(NamedArea element) {
+               getEntity().removeGeographicalScope(element);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public String getEmptyString() {
+               return "No geo scopes yet.";
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       protected String getTooltipString() {
+               return "Add a geo scope";
+       }
+
+}
index 4856e3ff7f3ef99b55c64f1914f782c6273d5368..c0bd141c4b2d7d15b747f3712ad46a5af357190d 100644 (file)
@@ -816,13 +816,8 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
         PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
 
         PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
 
-        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
-        TaxonomicScopeSection taxonomicScopeSection = formFactory.createTaxonomicScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
-
         addPart(polytomousKeyDetailSection);
         addPart(polytomousKeyNodeDetailSection);
         addPart(polytomousKeyDetailSection);
         addPart(polytomousKeyNodeDetailSection);
-        addPart(taxonomicScopeSection);
 
     }
 
 
     }