Project

General

Profile

« Previous | Next » 

Revision f561b00c

Added by Niels Hoffmann about 13 years ago

Refactoring selection elements so they can be configured

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionDetailElement.java
1 1
// $Id$
2 2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy 
5
 * http://www.e-taxonomy.eu
6
 * 
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10 10

  
11 11
package eu.etaxonomy.taxeditor.ui.section.occurrence;
12 12

  
13 13
import eu.etaxonomy.cdm.model.occurrence.Collection;
14 14
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
15
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
15 16
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
16 17
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
17 18
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
18
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
19 19
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
20 20
import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
21 21
import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
22 22

  
23 23
/**
24
 * <p>CollectionDetailElement class.</p>
25
 *
24
 * <p>
25
 * CollectionDetailElement class.
26
 * </p>
27
 * 
26 28
 * @author n.hoffmann
27 29
 * @created Oct 13, 2010
28 30
 * @version 1.0
29 31
 */
30
public class CollectionDetailElement extends AbstractCdmDetailElement<Collection> {
32
public class CollectionDetailElement extends
33
		AbstractCdmDetailElement<Collection> {
31 34

  
32 35
	private ToggleableTextElement text_titleCache;
33 36

  
34 37
	private TextWithLabelElement text_code;
35
	
38

  
36 39
	private TextWithLabelElement text_codeStandard;
37 40

  
38 41
	private TextWithLabelElement text_name;
......
42 45
	private InstitutionSelectionElement selection_institute;
43 46

  
44 47
	private CollectionSelectionElement selection_superCollection;
45
	
48

  
46 49
	/**
47
	 * <p>Constructor for CollectionDetailElement.</p>
48
	 *
49
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
50
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
50
	 * <p>
51
	 * Constructor for CollectionDetailElement.
52
	 * </p>
53
	 * 
54
	 * @param formFactory
55
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
56
	 *            object.
57
	 * @param formElement
58
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
59
	 *            object.
51 60
	 */
52 61
	public CollectionDetailElement(CdmFormFactory formFactory,
53 62
			ICdmFormElement formElement) {
54 63
		super(formFactory, formElement);
55 64
	}
56 65

  
57
	/* (non-Javadoc)
58
	 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
66
	/*
67
	 * (non-Javadoc)
68
	 * 
69
	 * @see
70
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
71
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
72
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
59 73
	 */
60 74
	/** {@inheritDoc} */
61 75
	@Override
62 76
	protected void createControls(ICdmFormElement formElement,
63 77
			Collection entity, int style) {
64
		text_titleCache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
65
		
66
		text_code = formFactory.createTextWithLabelElement(formElement, "Code", entity.getCode(), style);
67
		text_codeStandard = formFactory.createTextWithLabelElement(formElement, "Code Standard", entity.getCodeStandard(), style);
68
		text_name = formFactory.createTextWithLabelElement(formElement, "Name", entity.getName(), style);
69
		text_townOrLocation = formFactory.createTextWithLabelElement(formElement, "Town Or Location", entity.getTownOrLocation(), style);
70
		selection_institute = (InstitutionSelectionElement) formFactory.createSelectionElement(SelectionType.INSTITUTION, getConversationHolder(), formElement, "Institute", entity.getInstitute(), style);
71
		selection_superCollection = (CollectionSelectionElement) formFactory.createSelectionElement(SelectionType.COLLECTION, getConversationHolder(), formElement, "Super Collection", entity.getSuperCollection(), style);
78
		text_titleCache = formFactory.createToggleableTextField(formElement,
79
				"Title Cache", entity.getTitleCache(),
80
				entity.isProtectedTitleCache(), style);
81

  
82
		text_code = formFactory.createTextWithLabelElement(formElement, "Code",
83
				entity.getCode(), style);
84
		text_codeStandard = formFactory.createTextWithLabelElement(formElement,
85
				"Code Standard", entity.getCodeStandard(), style);
86
		text_name = formFactory.createTextWithLabelElement(formElement, "Name",
87
				entity.getName(), style);
88
		text_townOrLocation = formFactory.createTextWithLabelElement(
89
				formElement, "Town Or Location", entity.getTownOrLocation(),
90
				style);
91
		selection_institute = (InstitutionSelectionElement) formFactory
92
				.createSelectionElement(SelectionType.INSTITUTION,
93
						getConversationHolder(), formElement, "Institute",
94
						entity.getInstitute(),
95
						InstitutionSelectionElement.DEFAULT, style);
96
		selection_superCollection = (CollectionSelectionElement) formFactory
97
				.createSelectionElement(SelectionType.COLLECTION,
98
						getConversationHolder(), formElement,
99
						"Super Collection", entity.getSuperCollection(),
100
						CollectionSelectionElement.DEFAULT, style);
72 101
	}
73 102

  
74
	/* (non-Javadoc)
75
	 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
103
	/*
104
	 * (non-Javadoc)
105
	 * 
106
	 * @see
107
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
108
	 * .lang.Object)
76 109
	 */
77 110
	/** {@inheritDoc} */
78 111
	@Override
79 112
	public void handleEvent(Object eventSource) {
80
		if(eventSource == text_titleCache){
81
			getEntity().setTitleCache(text_titleCache.getText(), text_titleCache.getState());
82
		}
83
		else if(eventSource == text_code){
113
		if (eventSource == text_titleCache) {
114
			getEntity().setTitleCache(text_titleCache.getText(),
115
					text_titleCache.getState());
116
		} else if (eventSource == text_code) {
84 117
			getEntity().setCode(text_code.getText());
85
		}
86
		else if(eventSource == text_codeStandard){
118
		} else if (eventSource == text_codeStandard) {
87 119
			getEntity().setCodeStandard(text_codeStandard.getText());
88
		}
89
		else if(eventSource == text_name){
120
		} else if (eventSource == text_name) {
90 121
			getEntity().setName(text_name.getText());
91
		}
92
		else if(eventSource == text_townOrLocation){
122
		} else if (eventSource == text_townOrLocation) {
93 123
			getEntity().setTownOrLocation(text_townOrLocation.getText());
94
		}
95
		else if(eventSource == selection_institute){
124
		} else if (eventSource == selection_institute) {
96 125
			getEntity().setInstitute(selection_institute.getSelection());
97
		}
98
		else if(eventSource == selection_superCollection){
99
			getEntity().setSuperCollection(selection_superCollection.getSelection());
126
		} else if (eventSource == selection_superCollection) {
127
			getEntity().setSuperCollection(
128
					selection_superCollection.getSelection());
100 129
		}
101 130
	}
102 131

  

Also available in: Unified diff