Project

General

Profile

Download (2.83 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.agent.AgentBase;
9
import eu.etaxonomy.cdm.model.media.Rights;
10
import eu.etaxonomy.cdm.model.media.RightsType;
11
import eu.etaxonomy.cdm.model.term.TermType;
12
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
13
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
17
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
18
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
19
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
20

    
21
/**
22
 * @author n.hoffmann
23
 * @created Nov 16, 2009
24
 */
25
public class RightsElement extends AbstractEntityCollectionElement<Rights>{
26

    
27
	private TermComboElement<RightsType> combo_rightsType;
28
	private EntitySelectionElement<AgentBase> selection_agent;
29
	private TextWithLabelElement text;
30
	private TextWithLabelElement abbrev;
31
	private UriWithLabelElement uri;
32

    
33
	public RightsElement(CdmFormFactory cdmFormFactory,
34
			AbstractFormSection formElement, Rights element,
35
			SelectionListener removeListener, int style) {
36
		super(cdmFormFactory, formElement, element, removeListener, null, style);
37
	}
38

    
39
	@Override
40
	public void createControls(ICdmFormElement element, int style) {
41
		combo_rightsType = formFactory.createDefinedTermComboElement(TermType.RightsType, this, "Rights Type", null, style);
42
		selection_agent = formFactory.createSelectionElement(
43
				AgentBase.class,
44
				this, "Agent",
45
				null, EntitySelectionElement.ALL, style);
46
		text = formFactory.createMultiLineTextWithLabel(this, "Text", 100,
47
				style);
48
		abbrev = formFactory.createTextWithLabelElement(element, "Abbrev. Text", null, style);
49

    
50
		uri = formFactory.createUriWithLabelElement(element, "Uri", null, style);
51
		if (entity != null){
52
			setEntity(entity);
53
		}
54

    
55
	}
56

    
57
	@Override
58
	public void setEntity(Rights element) {
59
		this.entity = element;
60
		if(combo_rightsType != null){
61
			combo_rightsType.setSelection(element.getType());
62
			selection_agent.setEntity(element.getAgent());
63
			text.setText(element.getText());
64
			abbrev.setText(element.getAbbreviatedText());
65
			uri.setParsedText(element.getUri());
66
		}
67
	}
68

    
69
	@Override
70
	public void handleEvent(Object eventSource) {
71
		if (eventSource == combo_rightsType) {
72
			entity.setType(combo_rightsType.getSelection());
73
		} else if (eventSource == selection_agent) {
74
			entity.setAgent(selection_agent.getSelection());
75
		} else if (eventSource == text) {
76
			entity.setText(text.getText());
77
		}else if (eventSource == abbrev) {
78
            entity.setAbbreviatedText(abbrev.getText());
79
        }else if (eventSource == uri) {
80
            entity.setUri(uri.parseText());
81
        }
82
	}
83
}
(17-17/21)