import eu.etaxonomy.cdm.model.common.DefinedTerm;
import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@Override
public void setEntity(DefinedTerm entity) {
this.entity = entity;
- combo_scope.setSelection(entity);
+ if(!entity.getLabel().isEmpty()){
+ combo_scope.setSelection(entity);
+ }
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
-
+ DefinedTerm scopeTerm = combo_scope.getSelection();
+ if(eventSource==combo_scope && scopeTerm!=null){
+ if(getParentElement() instanceof ScopeSection){
+ TaxonDescription taxonDescription = ((ScopeSection)getParentElement()).getEntity();
+ taxonDescription.removeScope(entity);
+ taxonDescription.addScope(scopeTerm);
+ entity = scopeTerm;
+ }
+ }
}
-
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
/**
* <p>ScopeSection class.</p>
* @created Mar 18, 2010
* @version 1.0
*/
-public class ScopeSection extends AbstractEntityCollectionSection<TaxonDescription, DefinedTerm> {
+public class ScopeSection extends AbstractUnboundEntityCollectionSection<TaxonDescription, DefinedTerm> {
/**
* <p>Constructor for ScopeSection.</p>
public ScopeSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
super(cdmFormFactory, conversation, parentElement, "Scope", style);
}
-
+
/** {@inheritDoc} */
@Override
public void addElement(DefinedTerm element) {
/** {@inheritDoc} */
@Override
- public DefinedTerm createNewElement() {
- return DefinedTerm.NewInstance(TermType.Scope,"","Untitled","");
- }
-
- /** {@inheritDoc} */
- @Override
- public Collection<DefinedTerm> getCollection(TaxonDescription entity) {
- return entity.getScopes();
+ public DefinedTerm createNewElement() {
+ return DefinedTerm.NewInstance(TermType.Scope,"","","");
}
/** {@inheritDoc} */
public void removeElement(DefinedTerm element) {
getEntity().removeScope(element);
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection#getEntityCollection(java.lang.Object)
+ */
+ @Override
+ protected Collection<DefinedTerm> getEntityCollection(TaxonDescription entity) {
+ return entity.getScopes();
+ }
}
* @date 07.01.2014
*
*/
-public class SequenceReferenceCollectionDetailElement extends AbstractEntityCollectionElement<Reference>{
+public class SequenceReferenceCollectionDetailElement extends AbstractEntityCollectionElement<Reference<?>>{
protected EntitySelectionElement<Reference> selection_reference;
protected TextWithLabelElement text_referenceDetail;
- private Sequence sequence;
/**
* <p>
* a T object.
*/
public SequenceReferenceCollectionDetailElement(CdmFormFactory formFactory,
- AbstractFormSection section, Reference entity,
+ AbstractFormSection<?> section, Reference<?> entity,
SelectionListener removeListener, int style) {
super(formFactory, section, entity, removeListener, null, style);
- if(section instanceof SequenceReferenceCollectionDetailSection){
- sequence = (Sequence) section.getEntity();
- }
}
/*
* a T object.
*/
@Override
- public void setEntity(Reference entity) {
+ public void setEntity(Reference<?> entity) {
this.entity = entity;
selection_reference.setEntity(entity);
text_referenceDetail.setText(entity.getReferenceAbstract());
@Override
public void handleEvent(Object eventSource) {
if(eventSource==selection_reference){
- sequence.removeCitation(entity);
- Reference newCitation = selection_reference.getSelection();
- sequence.addCitation(newCitation);
- entity = newCitation;
- text_referenceDetail.setEnabled(true);
+ if(getParentElement() instanceof SequenceReferenceCollectionDetailSection){
+ Sequence sequence = ((SequenceReferenceCollectionDetailSection) getParentElement()).getEntity();
+ sequence.removeCitation(entity);
+ Reference<?> newCitation = selection_reference.getSelection();
+ sequence.addCitation(newCitation);
+ entity = newCitation;
+
+ text_referenceDetail.setEnabled(true);
+ }
} else if(eventSource==text_referenceDetail){
entity.setReferenceAbstract(text_referenceDetail.getText());
}