// $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 org.eclipse.swt.events.SelectionListener;
import eu.etaxonomy.cdm.model.agent.Person;
-import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
* <p>
* TeamMemberElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Apr 30, 2010
* @version 1.0
* <p>
* Constructor for TeamMemberElement.
* </p>
- *
+ *
* @param cdmFormFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
selection_person = formFactory
.createSelectionElement(Person.class,
getConversationHolder(), this, "Person", null,
- EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE,
+ EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE,
style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
* (eu.etaxonomy.cdm.model.common.VersionableEntity)
}
/** {@inheritDoc} */
- @Override
- public void handleEvent(Object eventSource) {
- if (eventSource == selection_person) {
- if (getParentElement() instanceof TeamMemberSection) {
- TeamMemberSection teamMemberSection = (TeamMemberSection) getParentElement();
- Team team = teamMemberSection.getEntity();
-
- int index = team.getTeamMembers().indexOf(getEntity());
-
- team.removeTeamMember(getEntity());
- team.addTeamMember(selection_person.getEntity(), index);
- firePropertyChangeEvent(new CdmPropertyChangeEvent(
- teamMemberSection, eventSource));
- }
- entity = selection_person.getEntity();
-
- }
- }
+ @Override
+ public void handleEvent(Object eventSource) {
+ if (eventSource == selection_person) {
+ if (getParentElement() instanceof TeamMemberSection) {
+ TeamMemberSection teamMemberSection = (TeamMemberSection) getParentElement();
+ teamMemberSection.getEntity().addTeamMember(selection_person.getEntity());
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(teamMemberSection, eventSource));
+ }
+ entity = selection_person.getEntity();
+ }
+ }
}
// $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.agent.Team;
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>TeamMemberSection class.</p>
* @created Apr 30, 2010
* @version 1.0
*/
-public class TeamMemberSection extends AbstractEntityCollectionSection<Team, Person> {
+public class TeamMemberSection extends AbstractUnboundEntityCollectionSection<Team, Person> {
/**
* <p>Constructor for TeamMemberSection.</p>
public TeamMemberSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
super(cdmFormFactory, conversation, parentElement, null, style);
}
-
+
/** {@inheritDoc} */
@Override
public String getTitleString() {
return Person.NewTitledInstance("");
}
- /** {@inheritDoc} */
- @Override
- public Collection<Person> getCollection(Team entity) {
- return getEntity().getTeamMembers();
- }
-
/** {@inheritDoc} */
@Override
public String getEmptyString() {
public void removeElement(Person element) {
getEntity().removeTeamMember(element);
}
-
-
+
+ @Override
+ protected Collection<Person> getEntityCollection(Team entity) {
+ return getEntity().getTeamMembers();
+ }
+
+
}
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
/**
- * This class extends the functionality of {@link AbstractEntityCollectionSection}
- * by creating an {@link AbstractEntityCollectionElement} for an
- * ELEMENT which is not directly added the the model ENTITY.<br>
+ * This class extends the functionality of
+ * {@link AbstractEntityCollectionSection} by creating an
+ * {@link AbstractEntityCollectionElement} for an ELEMENT which is not directly
+ * added the the model ENTITY.<br>
* <br>
- * This is useful if the ELEMENT is created after the creation of the AbstractEntityCollectionElement itself
- * and not in this class.
+ * This is useful if the ELEMENT is created after the creation of the
+ * AbstractEntityCollectionElement itself and not in this class and also if you
+ * do not want to create empty elements. <br>
+ * <br>
+ * <b>Note:</b> In sub classes: do <b>not</b> override {@link #getCollection(Object)}. Use
+ * {@link #getEntityCollection(Object)} instead
*
* @author pplitzner
* @date 21.01.2014