Project

General

Profile

Download (4.09 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

    
10
package eu.etaxonomy.taxeditor.ui.section.supplemental;
11

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

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

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

    
44
    protected ExternalLinksSection externalLinks;
45

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

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

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

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

    
103
	}
104

    
105

    
106
}
(1-1/20)