Project

General

Profile

« Previous | Next » 

Revision d0e36b21

Added by Patrick Plitzner almost 10 years ago

  • fixed TransientObjectException when adding and saving a scope for a TaxonDescription (fixes #2607)
    • made use of AbstractUnboundEntityCollectionsection
    • a DefinedTerm will not be created but selected from a list of existing ones

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ScopeElement.java
14 14

  
15 15
import eu.etaxonomy.cdm.model.common.DefinedTerm;
16 16
import eu.etaxonomy.cdm.model.common.TermType;
17
import eu.etaxonomy.cdm.model.description.TaxonDescription;
17 18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
18 19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
19 20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
50 51
	@Override
51 52
	public void setEntity(DefinedTerm entity) {
52 53
		this.entity = entity;
53
		combo_scope.setSelection(entity);
54
		if(!entity.getLabel().isEmpty()){
55
		    combo_scope.setSelection(entity);
56
		}
54 57
	}
55 58

  
56 59
	/** {@inheritDoc} */
......
62 65
	/** {@inheritDoc} */
63 66
	@Override
64 67
	public void handleEvent(Object eventSource) {
65

  
68
	    DefinedTerm scopeTerm = combo_scope.getSelection();
69
	    if(eventSource==combo_scope && scopeTerm!=null){
70
	        if(getParentElement() instanceof ScopeSection){
71
	            TaxonDescription taxonDescription = ((ScopeSection)getParentElement()).getEntity();
72
	            taxonDescription.removeScope(entity);
73
                taxonDescription.addScope(scopeTerm);
74
                entity = scopeTerm;
75
	        }
76
	    }
66 77
	}
67 78

  
68

  
69 79
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ScopeSection.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
18 18
import eu.etaxonomy.cdm.model.description.TaxonDescription;
19 19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
21
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
22 22

  
23 23
/**
24 24
 * <p>ScopeSection class.</p>
......
27 27
 * @created Mar 18, 2010
28 28
 * @version 1.0
29 29
 */
30
public class ScopeSection extends AbstractEntityCollectionSection<TaxonDescription, DefinedTerm> {
30
public class ScopeSection extends AbstractUnboundEntityCollectionSection<TaxonDescription, DefinedTerm> {
31 31

  
32 32
	/**
33 33
	 * <p>Constructor for ScopeSection.</p>
......
40 40
	public ScopeSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
41 41
		super(cdmFormFactory, conversation, parentElement, "Scope", style);
42 42
	}
43
	
43

  
44 44
	/** {@inheritDoc} */
45 45
	@Override
46 46
	public void addElement(DefinedTerm element) {
......
49 49

  
50 50
	/** {@inheritDoc} */
51 51
	@Override
52
	public DefinedTerm createNewElement() {		
53
		return DefinedTerm.NewInstance(TermType.Scope,"","Untitled","");					
54
	}
55

  
56
	/** {@inheritDoc} */
57
	@Override
58
	public Collection<DefinedTerm> getCollection(TaxonDescription entity) {
59
		return entity.getScopes();
52
	public DefinedTerm createNewElement() {
53
		return DefinedTerm.NewInstance(TermType.Scope,"","","");
60 54
	}
61 55

  
62 56
	/** {@inheritDoc} */
......
76 70
	public void removeElement(DefinedTerm element) {
77 71
		getEntity().removeScope(element);
78 72
	}
73

  
74
    /* (non-Javadoc)
75
     * @see eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection#getEntityCollection(java.lang.Object)
76
     */
77
    @Override
78
    protected Collection<DefinedTerm> getEntityCollection(TaxonDescription entity) {
79
        return entity.getScopes();
80
    }
79 81
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/dna/SequenceReferenceCollectionDetailElement.java
26 26
 * @date 07.01.2014
27 27
 *
28 28
 */
29
public class SequenceReferenceCollectionDetailElement extends AbstractEntityCollectionElement<Reference>{
29
public class SequenceReferenceCollectionDetailElement extends AbstractEntityCollectionElement<Reference<?>>{
30 30

  
31 31
    protected EntitySelectionElement<Reference> selection_reference;
32 32
    protected TextWithLabelElement text_referenceDetail;
33
    private Sequence sequence;
34 33

  
35 34
    /**
36 35
     * <p>
......
53 52
     *            a T object.
54 53
     */
55 54
    public SequenceReferenceCollectionDetailElement(CdmFormFactory formFactory,
56
            AbstractFormSection section, Reference entity,
55
            AbstractFormSection<?> section, Reference<?> entity,
57 56
            SelectionListener removeListener, int style) {
58 57
        super(formFactory, section, entity, removeListener, null, style);
59
        if(section instanceof SequenceReferenceCollectionDetailSection){
60
            sequence = (Sequence) section.getEntity();
61
        }
62 58
    }
63 59

  
64 60
    /*
......
88 84
     *            a T object.
89 85
     */
90 86
    @Override
91
    public void setEntity(Reference entity) {
87
    public void setEntity(Reference<?> entity) {
92 88
        this.entity = entity;
93 89
        selection_reference.setEntity(entity);
94 90
        text_referenceDetail.setText(entity.getReferenceAbstract());
......
100 96
    @Override
101 97
    public void handleEvent(Object eventSource) {
102 98
        if(eventSource==selection_reference){
103
            sequence.removeCitation(entity);
104
            Reference newCitation = selection_reference.getSelection();
105
            sequence.addCitation(newCitation);
106
            entity = newCitation;
107
            text_referenceDetail.setEnabled(true);
99
            if(getParentElement() instanceof SequenceReferenceCollectionDetailSection){
100
                Sequence sequence = ((SequenceReferenceCollectionDetailSection) getParentElement()).getEntity();
101
                sequence.removeCitation(entity);
102
                Reference<?> newCitation = selection_reference.getSelection();
103
                sequence.addCitation(newCitation);
104
                entity = newCitation;
105

  
106
                text_referenceDetail.setEnabled(true);
107
            }
108 108
        } else if(eventSource==text_referenceDetail){
109 109
            entity.setReferenceAbstract(text_referenceDetail.getText());
110 110
        }

Also available in: Unified diff