Project

General

Profile

« Previous | Next » 

Revision 13360a1e

Added by Katja Luther over 3 years ago

ref #9199: adapt nom. ref, nom. status, typedes. elements to original source

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java
15 15

  
16 16
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
17 17
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
18
import eu.etaxonomy.cdm.model.reference.Reference;
19 18
import eu.etaxonomy.taxeditor.store.StoreUtil;
20 19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21 20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
24 23
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
25 24
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
26 25
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
27
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
26
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
28 27
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSourcedEntityBaseElement;
29 28
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
30
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
31 29

  
32 30
/**
33 31
 * <p>Abstract AbstractTypeDesignationElement class.</p>
......
39 37
public abstract class AbstractTypeDesignationElement<T extends TypeDesignationBase> extends AbstractSourcedEntityBaseElement<T> {
40 38

  
41 39
	protected CheckboxElement checkbox_notDesignated;
42
	protected EntitySelectionElement<Reference> selection_reference;
43
    protected TextWithLabelElement text_referenceDetail;
40
//	protected EntitySelectionElement<Reference> selection_reference;
41
//    protected TextWithLabelElement text_referenceDetail;
42
	protected OriginalSourceElement singleSourceElement;
44 43
    protected SourceSection sourceSection;
45 44
    protected ICdmFormElement formElement;
46 45
    protected int style;
......
65 64
	@Override
66 65
	public void createControls(ICdmFormElement formElement, int style) {
67 66
	    checkbox_notDesignated = formFactory.createCheckbox(formElement, "Not Designated", false, style);
67

  
68 68
        sourceSection = formFactory.createSourceSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(SourceSection.class, IdentifiableSource.class.getCanonicalName()));
69 69
        sourceSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
70 70
		this.formElement = formElement;
......
77 77
	    removeSourcesControls();
78 78

  
79 79
	    if (this.entity != null && this.entity.hasDesignationSource()){
80
	        if (selection_reference == null){
80
	        if (singleSourceElement == null){
81 81
	            removeNotDesignatedControls();
82
    	        selection_reference = formFactory
83
                        .createSelectionElement(Reference.class, formElement, "Status Reference",
84
                                entity.getCitation(), EntitySelectionElement.ALL, style);
85

  
86
                text_referenceDetail = formFactory.createTextWithLabelElement(
87
                    formElement, "Reference Detail", entity.getCitationMicroReference(), style);
82
	            singleSourceElement = formFactory.createOriginalSourceElement(formElement, entity, "Status Reference");
83
//    	        selection_reference = formFactory
84
//                        .createSelectionElement(Reference.class, formElement, "Status Reference",
85
//                                entity.getCitation(), EntitySelectionElement.ALL, style);
86
//
87
//                text_referenceDetail = formFactory.createTextWithLabelElement(
88
//                    formElement, "Reference Detail", entity.getCitationMicroReference(), style);
88 89
                checkbox_notDesignated = formFactory.createCheckbox(formElement, "Not Designated", entity.isNotDesignated(), style);
89 90
	        }
90 91
        }else{
91
            if (selection_reference != null){
92
            if (singleSourceElement != null){
92 93
                removeReferenceControls();
93 94
                //check if there is still a reference
94 95
                if (this.entity.getCitation() != null){
......
96 97
                    this.entity.setCitationMicroReference(null);
97 98
                }
98 99
            }
100
        }
101
	    if (entity.hasDesignationSource()){
102
            singleSourceElement.setEntity(entity.getSource());
99 103
        }
100 104
	    sourceSection = formFactory.createSourceSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(SourceSection.class, IdentifiableSource.class.getCanonicalName()));
101 105
        sourceSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
......
117 121
        for (Iterator<ICdmFormElement> iterator = getElements().iterator();iterator.hasNext();) {
118 122
            ICdmFormElement childElement = iterator.next();
119 123
            // recursion
120
           if (childElement instanceof EntitySelectionElement && ((EntitySelectionElement)childElement).equals(selection_reference)) {
121
                childElement.removeElements();
122

  
123
                // unregister selection arbitrator
124
                if(childElement instanceof ISelectableElement){
125
                    SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator();
126
                    if(selectionArbitrator != null){
127
                        formFactory.destroySelectionArbitrator(selectionArbitrator);
128
                    }
129
                }
130

  
131
                // unregister from property changes
132
                formFactory.removePropertyChangeListener(childElement);
133
                selection_reference = null;
134
           }
135
          if (childElement instanceof TextWithLabelElement && ((TextWithLabelElement)childElement).equals(text_referenceDetail)) {
124
//           if (childElement instanceof EntitySelectionElement && ((EntitySelectionElement)childElement).equals(selection_reference)) {
125
//                childElement.removeElements();
126
//
127
//                // unregister selection arbitrator
128
//                if(childElement instanceof ISelectableElement){
129
//                    SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator();
130
//                    if(selectionArbitrator != null){
131
//                        formFactory.destroySelectionArbitrator(selectionArbitrator);
132
//                    }
133
//                }
134
//
135
//                // unregister from property changes
136
//                formFactory.removePropertyChangeListener(childElement);
137
//                singleSourceElement = null;
138
//           }
139
          if (childElement instanceof OriginalSourceElement && ((OriginalSourceElement)childElement).equals(singleSourceElement)) {
136 140

  
137 141
                  childElement.removeElements();
138 142

  
......
146 150

  
147 151
                  // unregister from property changes
148 152
                  formFactory.removePropertyChangeListener(childElement);
149
                  text_referenceDetail = null;
150

  
151

  
153
                  singleSourceElement = null;
152 154
          }
153 155
        }
154 156

  
......
172 174
                // unregister from property changes
173 175
                formFactory.removePropertyChangeListener(childElement);
174 176
                checkbox_notDesignated = null;
177
                break;
175 178
           }
176 179

  
177 180
        }
......
207 210
    }
208 211
    @Override
209 212
    public void handleEvent(Object eventSource) {
210
        if (eventSource == selection_reference) {
211
            getEntity().setCitation(selection_reference.getEntity());
212
            setEntity(entity);
213
        }
214
        if (eventSource == text_referenceDetail) {
215
            getEntity().setCitationMicroReference(text_referenceDetail.getText());
216
            setEntity(entity);
217
        }
213
//        if (eventSource == selection_reference) {
214
//            getEntity().setCitation(selection_reference.getEntity());
215
//            setEntity(entity);
216
//        }
217
//        if (eventSource == text_referenceDetail) {
218
//            getEntity().setCitationMicroReference(text_referenceDetail.getText());
219
//            setEntity(entity);
220
//        }
218 221
        if (eventSource == checkbox_notDesignated) {
219 222
            getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
220 223
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java
112 112
			return;
113 113
		}
114 114
		Object eventSource = event.getSource();
115
		if (eventSource == combo_relationshipType) {
116
			type = combo_relationshipType.getSelection().getTerm();
115
		if (eventSource == combo_relationshipType && combo_relationshipType.getSelection() != null) {
116
		    type = combo_relationshipType.getSelection().getTerm();
117 117
			this.inverse = combo_relationshipType.getSelection().isInverse();
118 118
		} else if (eventSource == selection_relatedTo) {
119 119
			relatedName = selection_relatedTo.getEntity();
120

  
120 121
		}
121 122

  
122 123
		boolean complete = type != null && relatedName != null;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameTypeDesignationElement.java
75 75
		combo_typeStatus.setSelection(HibernateProxyHelper.deproxy(entity.getTypeStatus(), NameTypeDesignationStatus.class));
76 76

  
77 77
		checkbox_notDesignated.setSelection(entity.isNotDesignated());
78

  
78 79
	}
79 80

  
80 81
	/** {@inheritDoc} */
......
106 107
		} else if (eventSource == checkbox_notDesignated) {
107 108
			getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
108 109
		}
109
		else if (eventSource == selection_reference) {
110
			getEntity().setCitation(selection_reference.getSelection());
111
		} else if (eventSource == text_referenceDetail) {
112
			getEntity().setCitationMicroReference(
113
					text_referenceDetail.getText());
114
		}
110
//		else if (eventSource == selection_reference) {
111
//			getEntity().setCitation(selection_reference.getSelection());
112
//		} else if (eventSource == text_referenceDetail) {
113
//			getEntity().setCitationMicroReference(
114
//					text_referenceDetail.getText());
115
//		}
115 116
	}
116 117
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
107 107
		} else if (eventSource == checkbox_notDesignated) {
108 108
			getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
109 109
		}
110
		else if (eventSource == selection_reference) {
111
			getEntity().setCitation(selection_reference.getSelection());
112
		} else if (eventSource == text_referenceDetail) {
113
			getEntity().setCitationMicroReference(
114
					text_referenceDetail.getText());
115
		}
110
//		else if (eventSource == selection_reference) {
111
//			getEntity().setCitation(selection_reference.getSelection());
112
//		} else if (eventSource == text_referenceDetail) {
113
//			getEntity().setCitationMicroReference(
114
//					text_referenceDetail.getText());
115
//		}
116 116
	}
117 117
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedSourceElement.java
30 30
 * @author k.luther
31 31
 * @since Jul 2, 2020
32 32
 */
33
public class AdvancedSourceElement extends AbstractCdmDetailElement<DescriptionElementSource> {
33
public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> {
34 34

  
35 35
    protected TextWithLabelElement text_idInSource;
36 36
    protected TextWithLabelElement text_idNamespace;
......
45 45
    }
46 46

  
47 47
    @Override
48
    protected void createControls(ICdmFormElement formElement, DescriptionElementSource entity, int style) {
48
    protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
49 49
        Display display = Display.getCurrent();
50 50
        Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
51 51

  
52 52

  
53 53
        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
54
            text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?((OriginalSourceBase)entity).getIdInSource():null, style);
54
            text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
55 55
            text_idInSource.setBackground(background);
56 56

  
57 57
        }
58 58
        if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
59
            text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?((OriginalSourceBase)entity).getIdNamespace():null, style);
59
            text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
60 60
            text_idNamespace.setBackground(background);
61 61
        }
62 62
        text_originaleNameString = formFactory.createTextWithLabelElement(
63 63
                formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
64 64

  
65 65
        text_originaleNameString.setBackground(background);
66
        if (entity instanceof DescriptionElementSource){
67
            select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
68
            select_nameUsedInSource.setBackground(background);
69
        }
66 70

  
67
        select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
68
        select_nameUsedInSource.setBackground(background);
69 71

  
70 72
        externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
71 73
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
......
76 78
    }
77 79

  
78 80
    @Override
79
    public void setEntity(DescriptionElementSource entity) {
81
    public void setEntity(OriginalSourceBase entity) {
80 82
        super.setEntity(entity);
81 83
        externalLinks.setEntity(entity);
82 84
    }
......
90 92
         }else if (eventSource.equals(text_originaleNameString)){
91 93
             getEntity().setOriginalNameString(text_originaleNameString.getText());
92 94
         }else if (eventSource.equals(select_nameUsedInSource)){
93
             getEntity().setNameUsedInSource(select_nameUsedInSource.getEntity());
95
             ((DescriptionElementSource)getEntity()).setNameUsedInSource(select_nameUsedInSource.getEntity());
94 96
         }
95 97
    }
96 98
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/NomenclaturalReferenceDetailElement.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.ui.section.reference;
11 11

  
12
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
12 13
import eu.etaxonomy.cdm.model.name.TaxonName;
13
import eu.etaxonomy.cdm.model.reference.Reference;
14
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
14 15
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15 16
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
17 17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
18
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
19 18

  
20 19
/**
21 20
 * <p>
......
28 27
public class NomenclaturalReferenceDetailElement extends
29 28
		AbstractCdmDetailElement<TaxonName> {
30 29

  
31
	private EntitySelectionElement<Reference> selection_nomenclaturalReference;
32
	private TextWithLabelElement text_referenceDetail;
33

  
34
//    private OriginalSourceAdvancedSection advancedSection;
30
    private OriginalSourceElement sourceElement;
35 31

  
36 32
	/**
37 33
	 * <p>
......
56 52
	@Override
57 53
	protected void createControls(ICdmFormElement formElement,
58 54
			TaxonName entity, int style) {
59
		selection_nomenclaturalReference = formFactory
60
				.createSelectionElementWithAbbreviatedTitle(Reference.class,
61
						getConversationHolder(), formElement, "Reference",
62
						entity.getNomenclaturalReference(),
63
						EntitySelectionElement.ALL, style);
64
		text_referenceDetail = formFactory.createTextWithLabelElement(
65
				formElement, "Ref. Detail",
66
				entity.getNomenclaturalMicroReference(), style);
55
//		selection_nomenclaturalReference = formFactory
56
//				.createSelectionElementWithAbbreviatedTitle(Reference.class,
57
//						getConversationHolder(), formElement, "Reference",
58
//						entity.getNomenclaturalReference(),
59
//						EntitySelectionElement.ALL, style);
60
//		text_referenceDetail = formFactory.createTextWithLabelElement(
61
//				formElement, "Ref. Detail",
62
//				entity.getNomenclaturalMicroReference(), style);
63

  
64
	    sourceElement = formFactory.createOriginalSourceElement(formElement, entity, "Reference");
65
	    if (entity.getNomenclaturalSource() == null){
66
            DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.NomenclaturalReference);
67
            entity.setNomenclaturalSource(source);
68
            sourceElement.setEntity(source);
69
        }else{
70
            sourceElement.setEntity(entity.getNomenclaturalSource());
71
        }
72
	    sourceElement.setPersistentBackground(formElement.getPersistentBackground());
67 73

  
68
//		advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
69
//		advancedSection.setEntity(entity.getNomenclaturalSource());
70
//		addControl(advancedSection);
71
//	    addElement(advancedSection);
72 74
	}
73 75

  
74 76
	/** {@inheritDoc} */
75 77
	@Override
76 78
	public void handleEvent(Object eventSource) {
77
		if (eventSource == selection_nomenclaturalReference) {
78
			getEntity().setNomenclaturalReference(
79
					selection_nomenclaturalReference.getSelection());
80
		} else if (eventSource == text_referenceDetail) {
81
			getEntity().setNomenclaturalMicroReference(
82
					text_referenceDetail.getText());
83
		}
79
//		if (eventSource == selection_nomenclaturalReference) {
80
//			getEntity().setNomenclaturalReference(
81
//					selection_nomenclaturalReference.getSelection());
82
//		} else if (eventSource == text_referenceDetail) {
83
//			getEntity().setNomenclaturalMicroReference(
84
//					text_referenceDetail.getText());
85
//		}
84 86
	}
87

  
88

  
85 89
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/NomenclaturalReferenceDetailSection.java
13 13

  
14 14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15 15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
16 17
import eu.etaxonomy.cdm.model.name.TaxonName;
17
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
18 18
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
19 19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
62 62
	@Override
63 63
	protected void setSectionTitle() {
64 64
		String title = "";
65
		if(getEntity() != null && getEntity().getNomenclaturalReference() != null){
66
			INomenclaturalReference reference = getEntity().getNomenclaturalReference();
67
			String nomenclaturalCitation = reference.getNomenclaturalCitation(getEntity().getNomenclaturalMicroReference());
68
			title = ": " + nomenclaturalCitation;
65
		if(getEntity() != null && getEntity().getNomenclaturalSource() != null){
66
			DescriptionElementSource reference = getEntity().getNomenclaturalSource();
67
			if (reference != null && reference.getCitation() != null){
68
			    String nomenclaturalCitation = reference.getCitation().getNomenclaturalCitation(reference.getCitationMicroReference());
69
			    title = ": " + nomenclaturalCitation;
70
			}
71

  
69 72
		}
70 73
		this.setText(getHeading() + title);
71 74
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/OriginalSourceAdvancedSection.java
12 12
import org.eclipse.ui.forms.widgets.TableWrapLayout;
13 13

  
14 14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
15
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
16 16
import eu.etaxonomy.taxeditor.l10n.Messages;
17 17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18 18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
23 23
 * @author k.luther
24 24
 * @since Jul 1, 2020
25 25
 */
26
public class OriginalSourceAdvancedSection extends AbstractCdmDetailSection<DescriptionElementSource> {
26
public class OriginalSourceAdvancedSection extends AbstractCdmDetailSection<OriginalSourceBase> {
27 27

  
28 28
    public OriginalSourceAdvancedSection(CdmFormFactory formFactory, ConversationHolder conversation,
29 29
            ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
......
31 31
    }
32 32

  
33 33
    @Override
34
    protected AbstractCdmDetailElement<DescriptionElementSource> createCdmDetailElement(
35
            AbstractCdmDetailSection<DescriptionElementSource> parentElement, int style) {
34
    protected AbstractCdmDetailElement<OriginalSourceBase> createCdmDetailElement(
35
            AbstractCdmDetailSection<OriginalSourceBase> parentElement, int style) {
36 36

  
37 37
        return new AdvancedSourceElement(getFormFactory(), parentElement);
38 38
    }
......
43 43
        return Messages.OriginalSourceAdvancedSection_advanced;
44 44
    }
45 45
    @Override
46
    protected void createControlsByType(AbstractCdmDetailSection<DescriptionElementSource> formElement, Class<DescriptionElementSource> entityClass, int style) {
46
    protected void createControlsByType(AbstractCdmDetailSection<OriginalSourceBase> formElement, Class<OriginalSourceBase> entityClass, int style) {
47 47
        super.createControlsByType(formElement, entityClass, style);
48 48
        int i = this.getTextClientHeightDifference();
49 49

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/OriginalSourceElement.java
12 12
import org.eclipse.jface.util.IPropertyChangeListener;
13 13
import org.eclipse.ui.forms.widgets.TableWrapData;
14 14

  
15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
15 16
import eu.etaxonomy.cdm.model.common.CdmBase;
16 17
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17 18
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
19
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
18 20
import eu.etaxonomy.cdm.model.reference.Reference;
19 21
import eu.etaxonomy.taxeditor.store.StoreUtil;
20 22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
28 30
 * @author k.luther
29 31
 * @since Jul 1, 2020
30 32
 */
31
public class OriginalSourceElement extends AbstractCdmDetailElement<DescriptionElementSource> implements IPropertyChangeListener{
33
public class OriginalSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> implements IPropertyChangeListener{
32 34

  
33 35
    private EntitySelectionElement<Reference> selection_Ref;
34 36
    private TextWithLabelElement microReference;
......
44 46
    }
45 47

  
46 48
    @Override
47
    protected void createControls(ICdmFormElement formElement, DescriptionElementSource entity,  int style) {
49
    protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity,  int style) {
48 50

  
51
        entity = HibernateProxyHelper.deproxy(entity);
49 52
        selection_Ref = formFactory.createSelectionElement(Reference.class,
50 53
                      formElement, label, null,
51
                      EntitySelectionElement.DELETABLE, style, 100);
54
                      EntitySelectionElement.ALL, style, 100);
52 55

  
53 56
        if (entity != null){
54 57
            selection_Ref.setEntity(entity.getCitation());
......
70 73
        addElement(advancedSection);
71 74
        advancedSection.setBackground(this.getPersistentBackground());
72 75
        advancedSection.setEntity(entity);
73

  
74
        if (StringUtils.isNotBlank(entity.getIdInSource()) || StringUtils.isNotBlank(entity.getIdNamespace()) || StringUtils.isNotBlank(entity.getOriginalNameString()) || (entity.getLinks() != null && !entity.getLinks().isEmpty())  || (entity.getNameUsedInSource() != null)){
76
        if (entity == null){
77
            advancedSection.setExpanded(false);
78
        }else if (StringUtils.isNotBlank(entity.getIdInSource()) || StringUtils.isNotBlank(entity.getIdNamespace()) || StringUtils.isNotBlank(entity.getOriginalNameString()) || (entity.getLinks() != null && !entity.getLinks().isEmpty())  || (entity instanceof DescriptionElementSource && ((DescriptionElementSource)entity).getNameUsedInSource() != null)){
75 79
            advancedSection.setExpanded(true);
76 80
        }else{
77 81
            advancedSection.setExpanded(false);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/SingleSourceSection.java
12 12

  
13 13
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
14 14
import eu.etaxonomy.cdm.model.common.CdmBase;
15
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
15
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
16 16
import eu.etaxonomy.cdm.model.reference.Reference;
17 17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18 18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
23 23
 * @author k.luther
24 24
 * @since Jul 2, 2020
25 25
 */
26
public class SingleSourceSection extends AbstractCdmDetailSection<DescriptionElementSource> {
26
public class SingleSourceSection extends AbstractCdmDetailSection<OriginalSourceBase> {
27 27

  
28 28
    private CdmBase cdmEntity;
29 29
    private String label;
......
37 37
    }
38 38

  
39 39
    @Override
40
    protected AbstractCdmDetailElement<DescriptionElementSource> createCdmDetailElement(
41
            AbstractCdmDetailSection<DescriptionElementSource> parentElement, int style) {
40
    protected AbstractCdmDetailElement<OriginalSourceBase> createCdmDetailElement(
41
            AbstractCdmDetailSection<OriginalSourceBase> parentElement, int style) {
42 42

  
43 43
        return new OriginalSourceElement(getFormFactory(), parentElement, cdmEntity, label);
44 44
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
26 26
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
27 27
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
28 28
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
29
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
29 30
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
31
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
30 32
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
31 33
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
32 34

  
......
34 36
 * @author n.hoffmann
35 37
 * @created Mar 16, 2010
36 38
 */
37
public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase> extends AbstractReferencedEntityElement<T> {
39
public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase> extends AbstractEntityCollectionElement<T> {
38 40

  
41
    private SelectionArbitrator selectionArbitrator;
39 42

  
43
    protected boolean isCommonNameReference = false;
40 44
    protected EntitySelectionElement<Reference> selection_reference;
41 45
    protected TextWithLabelElement text_referenceDetail;
42 46
	protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
......
51 55
			AbstractFormSection section,
52 56
			T element, SelectionListener removeListener,
53 57
			int style, boolean isCommonNameReference) {
54
		super(formFactory, section, element, removeListener, style, isCommonNameReference);
58
	    super(formFactory, section, element, removeListener, null, style);
59
		if(formFactory.getSelectionProvider() != null){
60
            selectionArbitrator = formFactory.createSelectionArbitrator(this);
61
        }
62
        this.isCommonNameReference = isCommonNameReference;
55 63
	}
56 64

  
57 65
	public AbstractOriginalSourceElement(CdmFormFactory formFactory,
58 66
            AbstractFormSection section,
59 67
            T element, SelectionListener removeListener,
60 68
            int style) {
61
        super(formFactory, section, element, removeListener, style);
69
	    this(formFactory, section, element, removeListener, style, false);
62 70
    }
63 71

  
64 72
	@Override
......
101 109
		combo_origsourcetype = formFactory
102 110
				.createEnumComboElement(OriginalSourceType.class,
103 111
						formElement, new OriginalSourceTypeComparator(getEntity()), style, false);
104
		super.createControls(formElement, style);
112

  
105 113
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
106 114
		    text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", null, style);
107 115
		}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractReferencedEntityElement.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.taxeditor.ui.section.supplemental;
11

  
12
import org.eclipse.swt.events.SelectionListener;
13

  
14
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
15
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
16
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
19
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
21

  
22
/**
23
 * @author n.hoffmann
24
 * @created Mar 25, 2010
25
 */
26
public abstract class AbstractReferencedEntityElement<T extends AnnotatableEntity>
27
		extends AbstractEntityCollectionElement<T> implements ISelectableElement {
28

  
29
	private SelectionArbitrator selectionArbitrator;
30

  
31
//	protected EntitySelectionElement<Reference> selection_reference;
32
//	protected TextWithLabelElement text_referenceDetail;
33

  
34
	protected boolean isCommonNameReference = false;
35

  
36
	public AbstractReferencedEntityElement(CdmFormFactory formFactory,
37
			AbstractFormSection section, T entity,
38
			SelectionListener removeListener, int style, boolean isCommonNameReference) {
39
		super(formFactory, section, entity, removeListener, null, style);
40
		// make this element selectable
41
		if(formFactory.getSelectionProvider() != null){
42
			selectionArbitrator = formFactory.createSelectionArbitrator(this);
43
		}
44
		this.isCommonNameReference = isCommonNameReference;
45
	}
46

  
47
    public AbstractReferencedEntityElement(CdmFormFactory formFactory,
48
            AbstractFormSection section, T entity,
49
            SelectionListener removeListener, int style) {
50
        super(formFactory, section, entity, removeListener, null, style);
51
        // make this element selectable
52
        if(formFactory.getSelectionProvider() != null){
53
            selectionArbitrator = formFactory.createSelectionArbitrator(this);
54
        }
55
    }
56

  
57
	@Override
58
	public void createControls(ICdmFormElement formElement, int style) {
59

  
60
	}
61

  
62
	@Override
63
	public void setEntity(T entity) {
64
		this.entity = entity;
65

  
66

  
67
	}
68

  
69
	@Override
70
    public SelectionArbitrator getSelectionArbitrator() {
71
		return selectionArbitrator;
72
	}
73

  
74
}

Also available in: Unified diff