Revision 4b61c2b2
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
232 | 232 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection; |
233 | 233 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement; |
234 | 234 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection; |
235 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement; |
|
236 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection; |
|
235 | 237 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement; |
236 | 238 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection; |
237 | 239 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection; |
... | ... | |
1589 | 1591 |
return section; |
1590 | 1592 |
} |
1591 | 1593 |
|
1594 |
public DerivedUnitTypeDesignationSection createDerivedUnitTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
|
1595 |
DerivedUnitTypeDesignationSection section = new DerivedUnitTypeDesignationSection(this, conversation, parentElement, style); |
|
1596 |
addAndAdaptSection(parentElement, section); |
|
1597 |
return section; |
|
1598 |
} |
|
1599 |
|
|
1592 | 1600 |
public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
1593 | 1601 |
TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style); |
1594 | 1602 |
addAndAdaptSection(parentElement, section); |
... | ... | |
2503 | 2511 |
element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener, |
2504 | 2512 |
style); |
2505 | 2513 |
} else if (entity instanceof SpecimenTypeDesignation) { |
2506 |
element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity, |
|
2507 |
removeListener, style); |
|
2514 |
if(parentElement instanceof DerivedUnitTypeDesignationSection){ |
|
2515 |
element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity, |
|
2516 |
removeListener, style); |
|
2517 |
} |
|
2518 |
else{ |
|
2519 |
element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity, |
|
2520 |
removeListener, style); |
|
2521 |
} |
|
2508 | 2522 |
} else if (entity instanceof StateData) { |
2509 | 2523 |
element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style); |
2510 | 2524 |
} else if (entity instanceof StatisticalMeasurementValue) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.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.occurrence.association; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
import java.util.Set; |
|
15 |
|
|
16 |
import org.eclipse.swt.events.SelectionListener; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
19 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
20 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
22 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
23 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement; |
|
24 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author n.hoffmann |
|
28 |
* @created May 17, 2010 |
|
29 |
* @version 1.0 |
|
30 |
*/ |
|
31 |
public class DerivedUnitTypeDesignationElement extends |
|
32 |
AbstractEntityCollectionElement<SpecimenTypeDesignation> { |
|
33 |
|
|
34 |
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames; |
|
35 |
private ICdmFormElement parentFormElement; |
|
36 |
private int style; |
|
37 |
|
|
38 |
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory, |
|
39 |
AbstractFormSection section, SpecimenTypeDesignation entity, |
|
40 |
SelectionListener removeListener, int style) { |
|
41 |
super(formFactory, section, entity, removeListener, null, style); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void setEntity(SpecimenTypeDesignation entity) { |
|
46 |
this.entity = entity; |
|
47 |
Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames(); |
|
48 |
if(typifiedNames.isEmpty()){ |
|
49 |
formFactory.createSelectionElement( |
|
50 |
TaxonNameBase.class, getConversationHolder(), parentFormElement, "Taxon Name", null, |
|
51 |
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style); |
|
52 |
} |
|
53 |
else{ |
|
54 |
for (TaxonNameBase taxonNameBase : typifiedNames) { |
|
55 |
EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement( |
|
56 |
TaxonNameBase.class, getConversationHolder(), parentFormElement, "Taxon Name", null, |
|
57 |
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style); |
|
58 |
selectionElement.setEntity(taxonNameBase); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
/** {@inheritDoc} */ |
|
64 |
@Override |
|
65 |
public void createControls(ICdmFormElement element, int style) { |
|
66 |
this.parentFormElement = element; |
|
67 |
this.style = style; |
|
68 |
} |
|
69 |
|
|
70 |
/** {@inheritDoc} */ |
|
71 |
@Override |
|
72 |
public void handleEvent(Object eventSource) { |
|
73 |
if (eventSource instanceof EntitySelectionElement) { |
|
74 |
((EntitySelectionElement<TaxonNameBase>) eventSource).getSelection().addTypeDesignation(getEntity(), false); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationSection.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 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 |
package eu.etaxonomy.taxeditor.ui.section.occurrence.association; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Collection; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Set; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
18 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
19 |
import eu.etaxonomy.cdm.api.service.INameService; |
|
20 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
21 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
23 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
24 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
25 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection; |
|
26 |
|
|
27 |
/** |
|
28 |
* @author pplitzner |
|
29 |
* @date Oct 29, 2015 |
|
30 |
* |
|
31 |
*/ |
|
32 |
public class DerivedUnitTypeDesignationSection extends AbstractEntityCollectionSection<DerivedUnitFacade, SpecimenTypeDesignation> { |
|
33 |
|
|
34 |
private Collection<SpecimenTypeDesignation> typeDesignations; |
|
35 |
|
|
36 |
public DerivedUnitTypeDesignationSection(CdmFormFactory formFactory, |
|
37 |
ConversationHolder conversation, ICdmFormElement parentElement, int style) { |
|
38 |
super(formFactory, conversation, parentElement, "Type Designations", style); |
|
39 |
} |
|
40 |
|
|
41 |
/** {@inheritDoc} */ |
|
42 |
@Override |
|
43 |
public Collection<SpecimenTypeDesignation> getCollection(DerivedUnitFacade entity) { |
|
44 |
typeDesignations = entity.innerDerivedUnit().getSpecimenTypeDesignations(); |
|
45 |
return typeDesignations; |
|
46 |
} |
|
47 |
|
|
48 |
/** {@inheritDoc} */ |
|
49 |
@Override |
|
50 |
public SpecimenTypeDesignation createNewElement() { |
|
51 |
return SpecimenTypeDesignation.NewInstance(); |
|
52 |
} |
|
53 |
|
|
54 |
/** {@inheritDoc} */ |
|
55 |
@Override |
|
56 |
public void addElement(SpecimenTypeDesignation element) { |
|
57 |
element.setTypeSpecimen(getEntity().innerDerivedUnit()); |
|
58 |
typeDesignations.add(element); |
|
59 |
} |
|
60 |
|
|
61 |
/** {@inheritDoc} */ |
|
62 |
@Override |
|
63 |
public void removeElement(SpecimenTypeDesignation element) { |
|
64 |
List<SpecimenTypeDesignation> toRemove = new ArrayList<SpecimenTypeDesignation>(); |
|
65 |
for (SpecimenTypeDesignation specimenTypeDesignation : typeDesignations) { |
|
66 |
if(element.equals(specimenTypeDesignation)){ |
|
67 |
toRemove.add(specimenTypeDesignation); |
|
68 |
} |
|
69 |
} |
|
70 |
for (SpecimenTypeDesignation specimenTypeDesignation : toRemove) { |
|
71 |
specimenTypeDesignation.removeType(); |
|
72 |
Set<TaxonNameBase> names = specimenTypeDesignation.getTypifiedNames(); |
|
73 |
for (TaxonNameBase taxonNameBase : names) { |
|
74 |
taxonNameBase.removeTypeDesignation(specimenTypeDesignation); |
|
75 |
if(CdmStore.getCurrentSessionManager().isRemoting()){ |
|
76 |
CdmStore.getService(INameService.class).merge(taxonNameBase); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
typeDesignations.removeAll(toRemove); |
|
81 |
} |
|
82 |
|
|
83 |
/** {@inheritDoc} */ |
|
84 |
@Override |
|
85 |
public String getEmptyString() { |
|
86 |
return "No type designation yet."; |
|
87 |
} |
|
88 |
|
|
89 |
/** {@inheritDoc} */ |
|
90 |
@Override |
|
91 |
protected String getTooltipString() { |
|
92 |
return "Add a type designation"; |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java | ||
---|---|---|
90 | 90 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection; |
91 | 91 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection; |
92 | 92 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection; |
93 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection; |
|
93 | 94 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection; |
94 | 95 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection; |
95 | 96 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection; |
... | ... | |
589 | 590 |
addPart(taxonAssociationDetailSection); |
590 | 591 |
} |
591 | 592 |
|
593 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
|
594 |
DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); |
|
595 |
addPart(derivedUnitTypeDesignationSection); |
|
596 |
|
|
592 | 597 |
formFactory.createHorizontalSeparator(parent, SWT.BORDER); |
593 | 598 |
IdentifierDetailSection identifierDetailSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); |
594 | 599 |
addPart(identifierDetailSection); |
Also available in: Unified diff
Add type designation collection elemetn to derived unit details view