ref #6283 Fixed potential NPE for EntitySelectionElement
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 18 Jan 2017 15:23:01 +0000 (16:23 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 18 Jan 2017 15:23:01 +0000 (16:23 +0100)
 - refactored constructors to always initialise the clazz variable

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/NomenclaturalAuthorTeamSelectionElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElement.java

index 8709c56efc2066b2a19d52c144c54c9ca77337e1..0f6aecbbd1ac530046506c5f0f376d4877d95341 100644 (file)
@@ -52,10 +52,6 @@ import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityLabelTextProvider;
 
 /**
- * <p>
- * Abstract AbstractSelectionElement class.
- * </p>
- *
  * @author n.hoffmann
  * @created Nov 17, 2009
  * @version 1.0
@@ -101,39 +97,12 @@ public class EntitySelectionElement<T extends CdmBase> extends
        private final ConversationHolder conversation;
        private Class<T> clazz;
 
-       /**
-        * <p>
-        * Constructor for AbstractSelectionElement.
-        * </p>
-        *
-        * @param formFactory
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
-        *            object.
-        * @param conversation
-        *            TODO
-        * @param parentElement
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
-        *            object.
-        * @param labelString
-        *            a {@link java.lang.String} object.
-        * @param entity
-        *            a T object.
-        * @param isEditable
-        *            a boolean.
-        * @param isSelectable
-        *            a boolean.
-        * @param isDeletable
-        *            a boolean.
-        * @param style
-        *            a int.
-        * @param <T>
-        *            a T object.
-        */
        public EntitySelectionElement(CdmFormFactory formFactory,
-                       ConversationHolder conversation, ICdmFormElement parentElement,
+                       ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
                        String labelString, T entity, int mode, int style, boolean filterElement) {
                super(formFactory, parentElement);
 
+               this.clazz = clazz;
                this.isEditable = (mode & EDITABLE) == EDITABLE;
                this.isDeletable = (mode & DELETABLE) == DELETABLE;
                boolean isSelectable = (mode & SELECTABLE) == SELECTABLE;
@@ -154,31 +123,15 @@ public class EntitySelectionElement<T extends CdmBase> extends
                }
        }
 
-       public EntitySelectionElement(CdmFormFactory formFactory,
-            ConversationHolder conversation, ICdmFormElement parentElement,
-            String labelString, T entity, int mode, int style){
-           this(formFactory, conversation, parentElement, labelString, entity, mode, style, false);
-       }
-
-       /**
-     * @param entity2
-     */
     private void setFilteredEntity(T filterEntity) {
         this.filteredEntity =filterEntity;
 
     }
 
-    public EntitySelectionElement(CdmFormFactory formFactory,
-                       ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
-                       String labelString, T entity, int mode, int style, boolean filterElement) {
-               this(formFactory, conversation, parentElement, labelString, entity, mode, style, filterElement);
-               this.clazz = clazz;
-       }
-
     public EntitySelectionElement(CdmFormFactory formFactory,
             ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
             String labelString, T entity, int mode, int style){
-        this(formFactory, conversation, parentElement, labelString, entity, mode, style, false);
+        this(formFactory, conversation, parentElement, clazz, labelString, entity, mode, style, false);
     }
 
        private void createControls(Composite parent, int style) {
index c7445fa27eeb5b7c2ecd56c220cfae1c3c34c2a2..94b0beaf0122f80fa0d7645cf7fa15ca556aa848 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * 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.
  */
@@ -21,7 +21,7 @@ import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
  * <p>
  * NomenclaturalAuthorTeamSelectionElement class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Jun 22, 2010
  * @version 1.0
@@ -35,7 +35,7 @@ public class NomenclaturalAuthorTeamSelectionElement extends
         * <p>
         * Constructor for NomenclaturalAuthorTeamSelectionElement.
         * </p>
-        * 
+        *
         * @param formFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -55,7 +55,7 @@ public class NomenclaturalAuthorTeamSelectionElement extends
        public NomenclaturalAuthorTeamSelectionElement(CdmFormFactory formFactory,
                        ConversationHolder conversation, ICdmFormElement parentElement,
                        String labelString, Team entity, int mode, int style) {
-               super(formFactory, conversation, parentElement, labelString, entity,
+               super(formFactory, conversation, parentElement, Team.class, labelString, entity,
                                mode, style);
        }
 
index 77211f592d6c0bf3424571800b50dc34e2b8845d..0a753619a39653427458f4008e693d3a744d4705 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -26,28 +26,28 @@ import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 public class TaxonNodeSelectionElement extends EntitySelectionElement<TaxonNode> {
 
        private Classification classification;
-       
+
        public TaxonNodeSelectionElement(CdmFormFactory formFactory,
                        ConversationHolder conversation, ICdmFormElement parentElement,
                        String labelString, TaxonNode entity, int mode, int style) {
-               super(formFactory, conversation, parentElement, labelString, entity, mode,
+               super(formFactory, conversation, parentElement, TaxonNode.class, labelString, entity, mode,
                                style);
        }
-       
+
        /**
         * @return
         */
        public Classification getClassification() {
                return classification;
        }
-       
+
        public void setClassification(Classification classification){
                this.classification = classification;
        }
-       
+
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt
         * .events.SelectionEvent)
@@ -59,10 +59,10 @@ public class TaxonNodeSelectionElement extends EntitySelectionElement<TaxonNode>
                                getConversationHolder(), "Select parent taxon", null, null, getClassification());
                setSelectionInternal(newSelection);
        }
-       
+
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement#getTitle
         * ()