*/
package eu.etaxonomy.taxeditor.ui.section.description;
+import java.util.Iterator;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
+import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
+import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
IEntityElement<DescriptionElementSource>{
private EntitySelectionElement<TaxonName> selection_name;
- private EntitySelectionElement<SpecimenOrObservationBase> selection_specimen;
boolean isEnabled = true;
public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
.createSelectionElement(TaxonName.class,
formElement, "Name in Source",
null, EntitySelectionElement.ALL, SWT.NULL);
- if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimenInFactSource.getKey())) {
- selection_specimen = formFactory
- .createSelectionElement(SpecimenOrObservationBase.class,
- formElement, "Specimen",
- null, EntitySelectionElement.ALL, SWT.NULL);
- }
+
externalLinks = formFactory.createExternalLinksSection(formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
if (getEntity() != null){
@Override
public void setEntity(DescriptionElementSource entity) {
super.setEntity(entity);
- if (selection_reference != null){
+ if (selection_reference != null ){
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
text_idInSource.setText(entity.getIdInSource());
}
text_referenceDetail.setText(entity.getCitationMicroReference());
text_originalInfo.setText(entity.getOriginalInfo());
selection_name.setEntity(entity.getNameUsedInSource());
- if (selection_specimen != null) {
- selection_specimen.setEntity(entity.getSpecimen());
- }
+
combo_origsourcetype.setSelection(entity.getType());
externalLinks.setEntity(entity);
}
super.handleEvent(eventSource);
if (eventSource == selection_name) {
getEntity().setNameUsedInSource(selection_name.getSelection());
+
}
if (eventSource == selection_specimen) {
getEntity().setSpecimen(selection_specimen.getSelection());
+ this.selection_reference.setEnabled(selection_specimen.getSelection() == null);
+ }
+ if (eventSource == selection_reference) {
+
+ this.selection_specimen.setEnabled(selection_reference.getSelection() == null);
}
}
super.setEnabled(enabled);
externalLinks.setEnabled(isEnabled);
}
+
}
\ No newline at end of file
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.cdm.model.common.TimePeriod;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.reference.ICdmTarget;
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
protected boolean isCommonNameReference = false;
protected EntitySelectionElement<Reference> selection_reference;
+ protected EntitySelectionElement<SpecimenOrObservationBase> selection_specimen;
protected TextWithLabelElement text_referenceDetail;
protected TimePeriodElement accessed;
protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
selection_reference = formFactory
.createCommonNameReferenceSelectionElement(formElement, "Reference",
null, EntitySelectionElement.ALL, style);
- }else{
+ }else if (entity instanceof DescriptionElementSource && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimenInFactSource.getKey())) {
+ selection_reference = formFactory
+ .createSelectionElement(Reference.class,
+ formElement, "Reference",
+ null, EntitySelectionElement.ALL, style);
+ selection_specimen = formFactory
+ .createSelectionElement(SpecimenOrObservationBase.class,
+ formElement, "or Specimen",
+ null, EntitySelectionElement.ALL, SWT.NULL);
+ }else{
selection_reference = formFactory
.createSelectionElement(Reference.class,
formElement, "Reference",
if (entity != null){
selection_reference.setEntity(entity.getCitation());
+ if (selection_specimen != null && entity instanceof DescriptionElementSource) {
+ selection_specimen.setEntity(((DescriptionElementSource)entity).getSpecimen());
+ }
text_referenceDetail.setText(entity.getCitationMicroReference());
text_originalInfo.setText(entity.getOriginalInfo());