Project

General

Profile

Download (2.85 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.section.supplemental;
5

    
6
import org.eclipse.swt.events.SelectionListener;
7

    
8
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
9
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
10
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
11
import eu.etaxonomy.taxeditor.store.StoreUtil;
12
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
15
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
16
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
17

    
18
/**
19
 * @author n.hoffmann
20
 * @created Nov 16, 2009
21
 * @version 1.0
22
 */
23
public class IdentifiableSourceElement extends AbstractOriginalSourceElement<IdentifiableSource>{
24

    
25
	public IdentifiableSourceElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement, IdentifiableSource element,
26
			SelectionListener removeListener, int style) {
27
		super(cdmFormFactory, formElement, element, removeListener, style);
28
	}
29

    
30
	/** {@inheritDoc} */
31
	@Override
32
	public void createControls(ICdmFormElement formElement, int style) {
33
		super.createControls(formElement, style);
34
		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, IdentifiableSource.class.getCanonicalName()));
35
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
36
	}
37

    
38
	/** {@inheritDoc} */
39
	@Override
40
	public void setEntity(IdentifiableSource entity) {
41
		super.setEntity(entity);
42
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
43
		    text_idInSource.setText(entity.getIdInSource());
44
		}
45
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
46
		    text_idNamespace.setText(entity.getIdNamespace());
47
		}
48

    
49
		selection_reference.setEntity(entity.getCitation());
50
		text_referenceDetail.setText(entity.getCitationMicroReference());
51
		combo_origsourcetype.setSelection(entity.getType());
52
		text_originaleNameString.setText(entity.getOriginalNameString());
53
	}
54

    
55
	/** {@inheritDoc} */
56
	@Override
57
	public void handleEvent(Object eventSource) {
58
		if(eventSource == text_idInSource){
59
			getEntity().setIdInSource(text_idInSource.getText());
60
		}
61
		else if(eventSource == text_idNamespace){
62
			getEntity().setIdNamespace(text_idNamespace.getText());
63
		}
64
		if(eventSource == selection_reference){
65
			getEntity().setCitation(selection_reference.getSelection());
66
		}
67
		else if(eventSource == text_referenceDetail){
68
			getEntity().setCitationMicroReference(text_referenceDetail.getText());
69
		}
70
		else if(eventSource == text_originaleNameString){
71
			getEntity().setOriginalNameString(text_originaleNameString.getText());
72
		} else if(eventSource == combo_origsourcetype){
73
			getEntity().setType(combo_origsourcetype.getSelection());
74
		}
75
	}
76
}
(13-13/20)