Refactoring of selection elements. Additional minor refactoring. Fixed a bug with...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / reference / ReferenceDetailElement.java
index 40f7c99e5644077545412f3b2c81fc44abaf17ed..cf7035e835fe603451779d3f07815447b5e30f9a 100644 (file)
@@ -17,6 +17,8 @@ import java.util.List;
 
 import org.eclipse.swt.SWT;
 
+import eu.etaxonomy.cdm.model.agent.AgentBase;
+import eu.etaxonomy.cdm.model.agent.Institution;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
@@ -32,11 +34,8 @@ import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
 import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.SelectionType;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
-import eu.etaxonomy.taxeditor.ui.selection.AgentSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 
 /**
  * <p>
@@ -64,13 +63,13 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
        private TextWithLabelElement text_title;
        private TextWithLabelElement text_volume;
        private UriWithLabelElement text_uri;
-       private AgentSelectionElement selection_authorTeam;
+       private EntitySelectionElement<AgentBase> selection_authorTeam;
        private TimePeriodElement element_timePeriod;
-       private ReferenceSelectionElement selection_inReference;
-       private InstitutionSelectionElement selection_institution;
+       private EntitySelectionElement<Reference> selection_inReference;
+       private EntitySelectionElement<Institution> selection_institution;
        private EnumComboElement<ReferenceType> combo_referenceType;
 
-       private ReferenceSelectionElement selection_inSeries;
+       private EntitySelectionElement<Reference> selection_inSeries;
 
        /**
         * <p>
@@ -116,11 +115,11 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                                "Title", entity.getTitle(), style);
 
                // author team
-               selection_authorTeam = (AgentSelectionElement) formFactory
-                               .createSelectionElement(SelectionType.AGENT,
+               selection_authorTeam = formFactory
+                               .createSelectionElement(AgentBase.class,
                                                getConversationHolder(), formElement, "Author",
                                                AuthorHelper.getAuthor(entity.getAuthorTeam()),
-                                               AgentSelectionElement.DEFAULT, style);
+                                               EntitySelectionElement.ALL, style);
 
                ReferenceType referenceType = entity.getType();
 
@@ -212,11 +211,11 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                }
 
                if (createInReferenceWidget) {
-                       selection_inReference = (ReferenceSelectionElement) formFactory
-                                       .createSelectionElement(SelectionType.REFERENCE,
+                       selection_inReference = formFactory
+                                       .createSelectionElement(Reference.class,
                                                        getConversationHolder(), element, label,
                                                        reference.getInReference(),
-                                                       ReferenceSelectionElement.DEFAULT, style);
+                                                       EntitySelectionElement.ALL, style);
                }
        }
 
@@ -275,20 +274,20 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
 
                if (referenceType.equals(ReferenceType.Report)) {
                        // institution
-                       selection_institution = (InstitutionSelectionElement) formFactory
-                                       .createSelectionElement(SelectionType.INSTITUTION,
+                       selection_institution = formFactory
+                                       .createSelectionElement(Institution.class,
                                                        getConversationHolder(), element, "Institution",
                                                        reference.getInstitution(),
-                                                       InstitutionSelectionElement.DEFAULT, style);
+                                                       EntitySelectionElement.ALL, style);
                }
 
                if (referenceType.equals(ReferenceType.Thesis)) {
                        // school
-                       selection_institution = (InstitutionSelectionElement) formFactory
-                                       .createSelectionElement(SelectionType.INSTITUTION,
+                       selection_institution = formFactory
+                                       .createSelectionElement(Institution.class,
                                                        getConversationHolder(), element, "School",
                                                        reference.getSchool(),
-                                                       InstitutionSelectionElement.DEFAULT, style);
+                                                       EntitySelectionElement.ALL, style);
                }
 
                if (referenceType.equals(ReferenceType.Proceedings)) {
@@ -339,11 +338,11 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
        private void createPrintedUnitControls(ICdmFormElement element,
                        ReferenceType referenceType, Reference reference, int style) {
                // in series
-               selection_inSeries = (ReferenceSelectionElement) formFactory
-                               .createSelectionElement(SelectionType.REFERENCE,
+               selection_inSeries = formFactory
+                               .createSelectionElement(Reference.class,
                                                getConversationHolder(), element, "In Series",
-                                               reference.getInSeries(),
-                                               ReferenceSelectionElement.DEFAULT, style);
+                                               (Reference) reference.getInSeries(),
+                                               EntitySelectionElement.ALL, style);
 
                // editor
                text_editor = formFactory.createTextWithLabelElement(element, "Editor",