-// $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.
*/
-
package eu.etaxonomy.taxeditor.ui.section.description;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.name.TaxonName;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
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.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
- * <p>
- * DescriptionElementSourceElement class.
- * </p>
- *
* @author n.hoffmann
* @created Nov 16, 2009
- * @version 1.0
- * @param <T>
*/
public class DescriptionElementSourceElement extends
AbstractOriginalSourceElement<DescriptionElementSource> implements
- IEntityElement<DescriptionElementSource> {
+ IEntityElement<DescriptionElementSource>{
- private EntitySelectionElement<TaxonNameBase> selection_name;
+ private EntitySelectionElement<TaxonName> selection_name;
+ boolean isEnabled = true;
- /**
- * <p>
- * Constructor for DescriptionElementSourceElement.
- * </p>
- *
- * @param formElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
- * object.
- * @param element
- * a
- * {@link eu.etaxonomy.cdm.model.common.DescriptionElementSource}
- * object.
- * @param removeListener
- * a {@link org.eclipse.swt.events.SelectionListener} object.
- * @param style
- * a int.
- * @param cdmFormFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- */
public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
- AbstractFormSection formElement, DescriptionElementSource element,
- SelectionListener removeListener, int style) {
- super(cdmFormFactory, formElement, element, removeListener, style);
- formFactory.createSelectionArbitrator(this);
+ AbstractFormSection<?> formElement, DescriptionElementSource element,
+ SelectionListener removeListener, int style, boolean isCommonNameReference) {
+ super(cdmFormFactory, formElement, element, removeListener, style, isCommonNameReference);
+ cdmFormFactory.createSelectionArbitrator(this);
}
- /*
- * (non-Javadoc)
- *
- * @see eu.etaxonomy.taxeditor.forms.entitysections.OriginalSourceComposite#
- * createControls(org.eclipse.swt.widgets.Composite, int)
- */
- /** {@inheritDoc} */
@Override
public void createControls(ICdmFormElement formElement, int style) {
super.createControls(formElement, style);
selection_name = formFactory
- .createSelectionElement(TaxonNameBase.class,
- getConversationHolder(), formElement, "Name in Source",
+ .createSelectionElement(TaxonName.class,
+ formElement, "Name in Source",
null, EntitySelectionElement.ALL, SWT.NULL);
+
+ externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
+ externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ if (getEntity() != null){
+ setEntity(entity);
+ }
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractOriginalSourceElement
- * #setElement(eu.etaxonomy.cdm.model.common.OriginalSourceBase)
- */
- /** {@inheritDoc} */
@Override
public void setEntity(DescriptionElementSource entity) {
super.setEntity(entity);
- text_idInSource.setText(entity.getIdInSource());
- text_idNamespace.setText(entity.getIdNamespace());
+ if (selection_reference != null){
+ if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
+ text_idInSource.setText(entity.getIdInSource());
+ }
+ if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
+ text_idNamespace.setText(entity.getIdNamespace());
+ }
- selection_reference.setEntity(entity.getCitation());
- text_referenceDetail.setText(entity.getCitationMicroReference());
- text_originaleNameString.setText(entity.getOriginalNameString());
- selection_name.setEntity(entity.getNameUsedInSource());
- combo_origsourcetype.setSelection(entity.getType());
+ selection_reference.setEntity(entity.getCitation());
+ text_referenceDetail.setText(entity.getCitationMicroReference());
+ text_originalInfo.setText(entity.getOriginalInfo());
+ selection_name.setEntity(entity.getNameUsedInSource());
+ combo_origsourcetype.setSelection(entity.getType());
+ externalLinks.setEntity(entity);
+ }
}
- /** {@inheritDoc} */
@Override
- public void setSelected(boolean selected) {
-
- }
+ public void setSelected(boolean selected) {}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
- * (java.lang.Object)
- */
- /** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if (eventSource == text_idInSource) {
- getEntity().setIdInSource(text_idInSource.getText());
- } else if (eventSource == text_idNamespace) {
- getEntity().setIdNamespace(text_idNamespace.getText());
- } else if (eventSource == selection_reference) {
- getEntity().setCitation(selection_reference.getSelection());
- } else if (eventSource == text_referenceDetail) {
- getEntity().setCitationMicroReference(
- text_referenceDetail.getText());
- } else if (eventSource == text_originaleNameString) {
- getEntity().setOriginalNameString(
- text_originaleNameString.getText());
- } else if (eventSource == selection_name) {
- getEntity().setNameUsedInSource(selection_name.getSelection());
- }
+ super.handleEvent(eventSource);
+ if (eventSource == selection_name) {
+ getEntity().setNameUsedInSource(selection_name.getSelection());
+ }
}
-}
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ externalLinks.setEnabled(isEnabled);
+ }
+}
\ No newline at end of file