Project

General

Profile

Download (4.03 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.supplemental;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.events.SelectionListener;
13
import org.eclipse.swt.widgets.Text;
14

    
15
import eu.etaxonomy.cdm.common.CdmUtils;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19
import eu.etaxonomy.cdm.model.reference.ICdmTarget;
20
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
21
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
22
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
24
import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
25
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
26
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
27
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
28
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
29
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
30

    
31
/**
32
 * @author n.hoffmann
33
 * @created Mar 16, 2010
34
 */
35
public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase> extends AbstractReferencedEntityElement<T> {
36
	
37
	protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
38
	protected TextWithLabelElement text_idInSource;
39
	protected TextWithLabelElement text_idNamespace;
40
    protected TextWithLabelElement text_originaleNameString;
41
    protected TextWithLabelElement text_cdmsource;
42

    
43
    protected ExternalLinksSection externalLinks;
44

    
45
	public AbstractOriginalSourceElement(CdmFormFactory formFactory,
46
			AbstractFormSection section,
47
			T element, SelectionListener removeListener,
48
			int style, boolean isCommonNameReference) {
49
		super(formFactory, section, element, removeListener, style, isCommonNameReference);
50
	}
51

    
52
	public AbstractOriginalSourceElement(CdmFormFactory formFactory,
53
            AbstractFormSection section,
54
            T element, SelectionListener removeListener,
55
            int style) {
56
        super(formFactory, section, element, removeListener, style);
57
    }
58

    
59
	@Override
60
	public void setEntity(T entity) {
61
	    super.setEntity(entity);
62
        text_originaleNameString.setText(entity.getOriginalNameString());
63
        ICdmTarget cdmSource = entity.getCdmSource();
64
        String source = "";
65
        if(cdmSource instanceof IdentifiableEntity) {
66
            source = ((IdentifiableEntity) cdmSource).getTitleCache();
67
        } else if(cdmSource instanceof CdmBase) {
68
            source += CdmUtils.isNotBlank(source)?"\nUUID: ":"";
69
            source += ((CdmBase) cdmSource).getUuid().toString();
70
        } else if(cdmSource!=null){
71
            source = cdmSource.toString();
72
        }
73
        text_cdmsource.setText(source);
74
        externalLinks.setEntity(entity);
75
	}
76

    
77
	/**
78
	 * @wbp.parser.entryPoint*/
79
	@Override
80
	public void createControls(ICdmFormElement formElement, int style) {
81
		combo_origsourcetype = formFactory
82
				.createEnumComboElement(OriginalSourceType.class,
83
						formElement, new OriginalSourceTypeComparator(getEntity()), style, false);
84
		super.createControls(formElement, style);
85
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
86
		    text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", null, style);
87
		}
88
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
89
		    text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", null, style);
90
		}
91
		text_originaleNameString = formFactory.createTextWithLabelElement(
92
		        formElement, "Original Information", null, SWT.NULL);
93
		text_cdmsource = formFactory.createTextWithLabelElement(
94
		        formElement, "CDM Source", null, SWT.NULL);
95
		((Text) text_cdmsource.getMainControl()).setEditable(false);
96
	}
97
}
(1-1/20)