Project

General

Profile

Revision 5d53f076

ID5d53f0766807cbea057f32a7908e3ea820530112
Parent 7e65b368
Child 6a70366c

Added by Patrick Plitzner over 5 years ago

Refactor identifier section classes #5898
- add abstract identifier section to support IdentifiableEntities and
DerivedUnitFacades

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
173 173
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
174 174
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
175 175
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
176
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailElement;
177
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
178 176
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
179 177
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
180 178
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
......
299 297
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
300 298
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
301 299
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
300
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
301
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierElement;
302
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
302 303
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
303 304
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
304 305
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
......
2343 2344
        return section;
2344 2345
    }
2345 2346

  
2346
    public IdentifierDetailSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2347
        IdentifierDetailSection section = new IdentifierDetailSection(this, conversation, parentElement, style);
2347
    public IdentifierSection createIdentifierDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2348
        IdentifierSection section = new IdentifierSection(this, conversation, parentElement, style);
2348 2349
        addAndAdaptSection(parentElement, section);
2349 2350
        return section;
2350 2351
    }
2352
    
2353
    public DerivedUnitFacadeIdentifierSection createDerivedUnitFacadeIdentifierSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2354
    	DerivedUnitFacadeIdentifierSection section = new DerivedUnitFacadeIdentifierSection(this, conversation, parentElement, style);
2355
    	addAndAdaptSection(parentElement, section);
2356
    	return section;
2357
    }
2351 2358

  
2352 2359
    public CurrentSampleDesignationDetailSection createCurrentSampleDesignationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2353 2360
        CurrentSampleDesignationDetailSection section = new CurrentSampleDesignationDetailSection(this, conversation, parentElement, style);
......
2565 2572
                element = new SampleDesignationTextDetailElement(this, parentElement, (Identifier<DnaSample>) entity, removeListener, backgroundColor, style);
2566 2573
            }
2567 2574
            else{
2568
                element = new IdentifierDetailElement(this, parentElement, (Identifier) entity, removeListener, style);
2575
                element = new IdentifierElement(this, parentElement, (Identifier) entity, removeListener, style);
2569 2576
            }
2570 2577
        } else if (entity instanceof TermVocabulary) {
2571 2578
            TermVocabulary<?> termVocabulary = (TermVocabulary<?>)entity;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailElement.java
1
// $Id$
2
/**
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10

  
11
package eu.etaxonomy.taxeditor.ui.section.identifier;
12

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

  
15
import eu.etaxonomy.cdm.model.common.DefinedTerm;
16
import eu.etaxonomy.cdm.model.common.Identifier;
17
import eu.etaxonomy.cdm.model.common.TermType;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
24

  
25
/**
26
 * 
27
 * @author pplitzner
28
 *
29
 */
30
public class IdentifierDetailElement extends AbstractEntityCollectionElement<Identifier> {
31

  
32
	private TextWithLabelElement textIdentifier;
33

  
34
	private TermComboElement<DefinedTerm> comboIdentifierType;
35

  
36
    public IdentifierDetailElement(CdmFormFactory formFactory,
37
            AbstractFormSection section, Identifier entity,
38
            SelectionListener removeListener, int style) {
39
        super(formFactory, section, entity, removeListener, null, style);
40
    }
41

  
42
    /** {@inheritDoc} */
43
    @Override
44
    public void setEntity(Identifier entity) {
45
        this.entity = entity;
46
        textIdentifier.setText(entity.getIdentifier());
47
        comboIdentifierType.setSelection(entity.getType());
48
    }
49

  
50
	/** {@inheritDoc} */
51
	@Override
52
    public void createControls(ICdmFormElement formElement, int style) {
53
		textIdentifier = formFactory.createTextWithLabelElement(formElement, "Identifier", null, style);
54
		comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
55
	}
56

  
57
	@Override
58
	public void handleEvent(Object eventSource) {
59
		if (eventSource == textIdentifier) {
60
			getEntity().setIdentifier(textIdentifier.getText());
61
		} else if (eventSource == comboIdentifierType) {
62
			getEntity().setType(comboIdentifierType.getSelection());
63
		}
64
	}
65

  
66
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.ui.section.identifier;
12

  
13
import java.util.Collection;
14

  
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
17
import eu.etaxonomy.cdm.model.common.Identifier;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
21

  
22
/**
23
 * 
24
 * @author pplitzner
25
 *
26
 */
27
public class IdentifierDetailSection extends AbstractEntityCollectionSection<IdentifiableEntity, Identifier> {
28

  
29
	public IdentifierDetailSection(CdmFormFactory formFactory,
30
			ConversationHolder conversation, ICdmFormElement parentElement, int style) {
31
		super(formFactory, conversation, parentElement, "Identifiers", style);
32
	}
33

  
34
	/** {@inheritDoc} */
35
	@Override
36
	public Collection<Identifier> getCollection(IdentifiableEntity entity) {
37
		return entity.getIdentifiers();
38
	}
39

  
40
	/** {@inheritDoc} */
41
	@Override
42
	public Identifier createNewElement() {
43
		return Identifier.NewInstance(null, null);
44
	}
45

  
46
	/** {@inheritDoc} */
47
	@Override
48
	public void addElement(Identifier element) {
49
		getEntity().addIdentifier(element);
50
	}
51

  
52
	/** {@inheritDoc} */
53
	@Override
54
	public void removeElement(Identifier element) {
55
	    getEntity().removeIdentifier(element);
56
	    getConversationHolder().commit();
57
	}
58

  
59
	/** {@inheritDoc} */
60
	@Override
61
	public String getEmptyString() {
62
		return "No identifiers yet.";
63
	}
64

  
65
	/** {@inheritDoc} */
66
	@Override
67
	protected String getTooltipString() {
68
		return "Add an identifier";
69
	}
70

  
71
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/identifier/AbstractIdentifierSection.java
1
package eu.etaxonomy.taxeditor.ui.section.supplemental.identifier;
2

  
3
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
4
import eu.etaxonomy.cdm.model.common.Identifier;
5
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
6
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
7
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
8

  
9
public abstract class AbstractIdentifierSection<T> extends AbstractEntityCollectionSection<T, Identifier> {
10

  
11
	public AbstractIdentifierSection(CdmFormFactory formFactory,
12
			ConversationHolder conversation, ICdmFormElement parentElement, int style) {
13
		super(formFactory, conversation, parentElement, "Identifiers", style);
14
	}
15

  
16
	/** {@inheritDoc} */
17
	@Override
18
	public Identifier createNewElement() {
19
		return Identifier.NewInstance(null, null);
20
	}
21

  
22
	/** {@inheritDoc} */
23
	@Override
24
	public String getEmptyString() {
25
		return "No identifiers yet.";
26
	}
27

  
28
	/** {@inheritDoc} */
29
	@Override
30
	protected String getTooltipString() {
31
		return "Add an identifier";
32
	}
33

  
34
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/identifier/DerivedUnitFacadeIdentifierSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.ui.section.supplemental.identifier;
12

  
13
import java.util.Collection;
14

  
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
17
import eu.etaxonomy.cdm.model.common.Identifier;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20

  
21
/**
22
 * 
23
 * @author pplitzner
24
 *
25
 */
26
public class DerivedUnitFacadeIdentifierSection extends AbstractIdentifierSection<DerivedUnitFacade> {
27

  
28

  
29
	public DerivedUnitFacadeIdentifierSection(CdmFormFactory formFactory,
30
			ConversationHolder conversation, ICdmFormElement parentElement,
31
			int style) {
32
		super(formFactory, conversation, parentElement, style);
33
	}
34

  
35
	@Override
36
	public Collection<Identifier> getCollection(DerivedUnitFacade entity) {
37
		return entity.getIdentifiers();
38
	}
39

  
40

  
41
	@Override
42
	public void addElement(Identifier element) {
43
		getEntity().addIdentifier(element);
44
	}
45

  
46

  
47
	@Override
48
	public void removeElement(Identifier element) {
49
		getEntity().removeIdentifier(element);
50
	}
51

  
52
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/identifier/IdentifierElement.java
1
// $Id$
2
/**
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10

  
11
package eu.etaxonomy.taxeditor.ui.section.supplemental.identifier;
12

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

  
15
import eu.etaxonomy.cdm.model.common.DefinedTerm;
16
import eu.etaxonomy.cdm.model.common.Identifier;
17
import eu.etaxonomy.cdm.model.common.TermType;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
24

  
25
/**
26
 * 
27
 * @author pplitzner
28
 *
29
 */
30
public class IdentifierElement extends AbstractEntityCollectionElement<Identifier> {
31

  
32
	private TextWithLabelElement textIdentifier;
33

  
34
	private TermComboElement<DefinedTerm> comboIdentifierType;
35

  
36
    public IdentifierElement(CdmFormFactory formFactory,
37
            AbstractFormSection section, Identifier entity,
38
            SelectionListener removeListener, int style) {
39
        super(formFactory, section, entity, removeListener, null, style);
40
    }
41

  
42
    /** {@inheritDoc} */
43
    @Override
44
    public void setEntity(Identifier entity) {
45
        this.entity = entity;
46
        textIdentifier.setText(entity.getIdentifier());
47
        comboIdentifierType.setSelection(entity.getType());
48
    }
49

  
50
	/** {@inheritDoc} */
51
	@Override
52
    public void createControls(ICdmFormElement formElement, int style) {
53
		textIdentifier = formFactory.createTextWithLabelElement(formElement, "Identifier", null, style);
54
		comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
55
	}
56

  
57
	@Override
58
	public void handleEvent(Object eventSource) {
59
		if (eventSource == textIdentifier) {
60
			getEntity().setIdentifier(textIdentifier.getText());
61
		} else if (eventSource == comboIdentifierType) {
62
			getEntity().setType(comboIdentifierType.getSelection());
63
		}
64
	}
65

  
66
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/identifier/IdentifierSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.ui.section.supplemental.identifier;
12

  
13
import java.util.Collection;
14

  
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
17
import eu.etaxonomy.cdm.model.common.Identifier;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20

  
21
/**
22
 * 
23
 * @author pplitzner
24
 *
25
 */
26
public class IdentifierSection extends AbstractIdentifierSection<IdentifiableEntity> {
27

  
28
	public IdentifierSection(CdmFormFactory formFactory,
29
			ConversationHolder conversation, ICdmFormElement parentElement,
30
			int style) {
31
		super(formFactory, conversation, parentElement, style);
32
	}
33

  
34
	@Override
35
	public Collection<Identifier> getCollection(IdentifiableEntity entity) {
36
		return entity.getIdentifiers();
37
	}
38

  
39
	@Override
40
	public void addElement(Identifier element) {
41
		getEntity().addIdentifier(element);
42
	}
43

  
44
	@Override
45
	public void removeElement(Identifier element) {
46
		getEntity().removeIdentifier(element);
47
	}
48

  
49
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
74 74
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
75 75
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
76 76
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
77
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
78 77
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
79 78
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
80 79
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
......
105 104
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
106 105
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
107 106
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
107
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
108 108
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
109 109
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
110 110
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
......
591 591
                addPart(taxonAssociationDetailSection);
592 592
            }
593 593
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
594
            IdentifierDetailSection identifierDetailSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
594
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
595 595
            addPart(identifierDetailSection);
596 596
        }
597 597
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java
27 27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28 28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29 29
import eu.etaxonomy.taxeditor.ui.element.RootElement;
30
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
31 30
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
32 31
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
33 32
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
......
38 37
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
39 38
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
40 39
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
40
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
41 41
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
42 42
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
43 43
import eu.etaxonomy.taxeditor.view.detail.DetailsViewer;
......
164 164

  
165 165
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
166 166

  
167
        IdentifierDetailSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
167
        IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
168 168
        
169
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
170

  
171 169
        addPart(creditSection);
172 170
        addPart(extensionSection);
173 171
        addPart(rightsSection);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)