Add identifer section to supplemental data view #5898
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 20 Jun 2016 16:25:12 +0000 (18:25 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 20 Jun 2016 16:25:12 +0000 (18:25 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java

index 9171b031b2c11a12c4fa318e11e3cad06c131a60..e1796bcfd7e9c3480cde6a690429e475c99aa7bd 100644 (file)
@@ -23,13 +23,9 @@ import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
 
 /**
- * <p>
- * CollectionDetailElement class.
- * </p>
+ * 
+ * @author pplitzner
  *
- * @author n.hoffmann
- * @created Oct 13, 2010
- * @version 1.0
  */
 public class IdentifierDetailElement extends AbstractEntityCollectionElement<Identifier> {
 
@@ -37,37 +33,12 @@ public class IdentifierDetailElement extends AbstractEntityCollectionElement<Ide
 
        private TermComboElement<DefinedTerm> comboIdentifierType;
 
-       /**
-     * <p>
-     * Constructor for CollectingAreasDetailElement.
-     * </p>
-     *
-     * @param formFactory
-     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
-     *            object.
-     * @param section
-     *            a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
-     *            object.
-     * @param entity
-     *            a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
-     * @param removeListener
-     *            a {@link org.eclipse.swt.events.SelectionListener} object.
-     * @param style
-     *            a int.
-     */
     public IdentifierDetailElement(CdmFormFactory formFactory,
             AbstractFormSection section, Identifier entity,
             SelectionListener removeListener, int style) {
         super(formFactory, section, entity, removeListener, null, style);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
-     * (java.lang.Object)
-     */
     /** {@inheritDoc} */
     @Override
     public void setEntity(Identifier entity) {
@@ -76,14 +47,6 @@ public class IdentifierDetailElement extends AbstractEntityCollectionElement<Ide
         comboIdentifierType.setSelection(entity.getType());
     }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
-        * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
-        * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
-        */
        /** {@inheritDoc} */
        @Override
     public void createControls(ICdmFormElement formElement, int style) {
@@ -91,14 +54,6 @@ public class IdentifierDetailElement extends AbstractEntityCollectionElement<Ide
                comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
-        * .lang.Object)
-        */
-       /** {@inheritDoc} */
        @Override
        public void handleEvent(Object eventSource) {
                if (eventSource == textIdentifier) {
index 147f7d4950e41efb5ffa78d6b171663eccf6834d..4c6cdd8680c0aec23577fd4bbb55ba46de9d3bc7 100644 (file)
@@ -12,128 +12,56 @@ package eu.etaxonomy.taxeditor.ui.section.identifier;
 
 import java.util.Collection;
 
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.widgets.Control;
-
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Identifier;
-import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 
 /**
- * <p>
- * CollectingAreasDetailSection class.
- * </p>
+ * 
+ * @author pplitzner
  *
- * @author n.hoffmann
- * @created Oct 14, 2010
- * @version 1.0
  */
-public class IdentifierDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, Identifier> {
+public class IdentifierDetailSection extends AbstractEntityCollectionSection<IdentifiableEntity, Identifier> {
 
-       /**
-        * <p>Constructor for CollectingAreasDetailSection.</p>
-        *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
-        * @param style a int.
-        */
        public IdentifierDetailSection(CdmFormFactory formFactory,
                        ConversationHolder conversation, ICdmFormElement parentElement, int style) {
                super(formFactory, conversation, parentElement, "Identifiers", style);
        }
 
-       @Override
-    protected Control createToolbar() {
-        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
-        Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
-            /* (non-Javadoc)
-             * @see org.eclipse.jface.action.Action#run()
-             */
-            @Override
-            public void run() {
-                Identifier element = createNewElement();
-                if(element != null){
-                    if(! getSection().isExpanded()) {
-                        getSection().setExpanded(true);
-                    }
-                    internalUpdateSection(true);
-                }
-            }
-        };
-        addAction.setImageDescriptor(new ImageDescriptor() {
-
-            @Override
-            public ImageData getImageData() {
-                return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
-            }
-        });
-        addAction.setToolTipText(getTooltipString());
-
-        toolBarManager.add(addAction);
-
-        return toolBarManager.createControl(this);
-    }
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
-        */
        /** {@inheritDoc} */
        @Override
-       public Collection<Identifier> getCollection(DerivedUnitFacade entity) {
+       public Collection<Identifier> getCollection(IdentifiableEntity entity) {
                return entity.getIdentifiers();
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
-        */
        /** {@inheritDoc} */
        @Override
        public Identifier createNewElement() {
-               return Identifier.NewInstance(getEntity().baseUnit(), null, null);
+               return Identifier.NewInstance(null, null);
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
-        */
        /** {@inheritDoc} */
        @Override
        public void addElement(Identifier element) {
                getEntity().addIdentifier(element);
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
-        */
        /** {@inheritDoc} */
        @Override
        public void removeElement(Identifier element) {
-           getEntity().removeIdentifier(getEntity().getIdentifiers().get(0));
+           getEntity().removeIdentifier(element);
            getConversationHolder().commit();
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
-        */
        /** {@inheritDoc} */
        @Override
        public String getEmptyString() {
                return "No identifiers yet.";
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
-        */
        /** {@inheritDoc} */
        @Override
        protected String getTooltipString() {
index f48949c18565ae3590bca53d02502131bbac26e2..b3190cd095fb61f5db44280175cd9dd5d584f1c3 100644 (file)
@@ -27,6 +27,7 @@ import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.RootElement;
+import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
 import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
 import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
@@ -163,10 +164,15 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe
 
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
+        IdentifierDetailSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+        
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
         addPart(creditSection);
         addPart(extensionSection);
         addPart(rightsSection);
         addPart(sourceSection);
+        addPart(identifierSection);
 
        }