* 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 org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.name.TaxonName;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
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;
/**
- *
* @author n.hoffmann
* @created Nov 16, 2009
- * @version 1.0
*/
public class DescriptionElementSourceElement extends
AbstractOriginalSourceElement<DescriptionElementSource> implements
- IEntityElement<DescriptionElementSource> {
+ IEntityElement<DescriptionElementSource>{
private EntitySelectionElement<TaxonName> selection_name;
+ boolean isEnabled = true;
public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
AbstractFormSection<?> formElement, DescriptionElementSource element,
SelectionListener removeListener, int style, boolean isCommonNameReference) {
super(cdmFormFactory, formElement, element, removeListener, style, isCommonNameReference);
- formFactory.createSelectionArbitrator(this);
+ cdmFormFactory.createSelectionArbitrator(this);
}
- /** {@inheritDoc} */
@Override
public void createControls(ICdmFormElement formElement, int style) {
super.createControls(formElement, style);
selection_name = formFactory
- .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ .createSelectionElement(TaxonName.class,
formElement, "Name in Source",
null, EntitySelectionElement.ALL, SWT.NULL);
- externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+ externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ if (getEntity() != null){
+ setEntity(entity);
+ }
}
- /** {@inheritDoc} */
@Override
public void setEntity(DescriptionElementSource entity) {
super.setEntity(entity);
- if (PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_ID_IN_SOURCE)){
- text_idInSource.setText(entity.getIdInSource());
- }
- if (PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_NAME_IN_SOURCE)){
- 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) {}
- /** {@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());
- }
- else if(eventSource == combo_origsourcetype){
- getEntity().setType(combo_origsourcetype.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