Project

General

Profile

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

    
6
import org.eclipse.swt.SWT;
7

    
8
import eu.etaxonomy.cdm.model.description.PolytomousKey;
9
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
10
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
11
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
12
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
13
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
14
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
15
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
16
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
17

    
18
/**
19
 * @author n.hoffmann
20
 *
21
 */
22
public class PolytomousKeyDetailElement extends
23
		AbstractCdmDetailElement<PolytomousKey> {
24

    
25
    private TextWithLabelElement textLabel;
26
    private NumberWithLabelElement numberStartNumber;
27
    private TaxonomicScopeSection sectionTaxonomicScope;
28
    private GeoScopePolyKeyDetailSection sectionGeoScopes;
29
    private ScopeRestrictionSection sectionScopeRestriction;
30

    
31
	public PolytomousKeyDetailElement(CdmFormFactory formFactory,
32
			ICdmFormElement formElement) {
33
		super(formFactory, formElement);
34
	}
35

    
36
	@Override
37
	protected void createControls(ICdmFormElement formElement,
38
			PolytomousKey entity, int style) {
39
	    textLabel = formFactory.createTextWithLabelElement(formElement, "Title", entity.getTitleCache(), style);
40

    
41
	    numberStartNumber = formFactory.createNumberTextWithLabelElement(formElement, "Start Number", entity.getStartNumber(), style);
42

    
43
	    sectionTaxonomicScope = formFactory.createTaxonomicScopeSection(getConversationHolder(), formElement, style);
44
	    sectionTaxonomicScope.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
45
	    sectionTaxonomicScope.setEntity(entity);
46

    
47
	    sectionGeoScopes = formFactory.createGeoScopePolyKeyDetailSection(getConversationHolder(), formElement, SWT.NULL);
48
	    sectionGeoScopes.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
49
	    sectionGeoScopes.setEntity(entity);
50

    
51
	    sectionScopeRestriction = formFactory.createScopeRestrictionSection(getConversationHolder(), formElement, SWT.NULL);
52
	    sectionScopeRestriction.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
53
	    sectionScopeRestriction.setEntity(entity);
54
	}
55

    
56
	public String getText() {
57
	    return textLabel.getText();
58
	}
59

    
60
	@Override
61
	public void handleEvent(Object eventSource) {
62
		if(eventSource==textLabel){
63
		    getEntity().setTitleCache(textLabel.getText(), true);
64
		}
65
		else if(eventSource==numberStartNumber){
66
		    getEntity().setStartNumber(numberStartNumber.getInteger());
67
		}
68
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
69
	}
70
}
(1-1/6)