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/supplemental/AbstractReferencedEntityElement.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.supplemental;
12 12

  
......
16 16
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
17 17
import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
18 18
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
19 20
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
20 21
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
22 22
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
23 23
import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
24 24

  
25 25
/**
26
 * <p>Abstract AbstractReferencedEntityElement class.</p>
27
 *
26
 * <p>
27
 * Abstract AbstractReferencedEntityElement class.
28
 * </p>
29
 * 
28 30
 * @author n.hoffmann
29 31
 * @created Mar 25, 2010
30 32
 * @version 1.0
31 33
 */
32
public abstract class AbstractReferencedEntityElement<T extends ReferencedEntityBase> extends
33
		AbstractEntityCollectionElement<T> {
34
	
34
public abstract class AbstractReferencedEntityElement<T extends ReferencedEntityBase>
35
		extends AbstractEntityCollectionElement<T> {
36

  
35 37
	protected ReferenceSelectionElement selection_reference;
36 38
	protected TextWithLabelElement text_referenceDetail;
37 39

  
38

  
39 40
	protected TextWithLabelElement text_originaleNameString;
40 41

  
41

  
42 42
	private boolean hasOriginalNameString = false;
43 43

  
44 44
	/**
45
	 * <p>Constructor for AbstractReferencedEntityElement.</p>
46
	 *
47
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
48
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
49
	 * @param entity a T object.
50
	 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
51
	 * @param style a int.
52
	 * @param <T> a T object.
45
	 * <p>
46
	 * Constructor for AbstractReferencedEntityElement.
47
	 * </p>
48
	 * 
49
	 * @param formFactory
50
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
51
	 *            object.
52
	 * @param section
53
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
54
	 *            object.
55
	 * @param entity
56
	 *            a T object.
57
	 * @param removeListener
58
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
59
	 * @param style
60
	 *            a int.
61
	 * @param <T>
62
	 *            a T object.
53 63
	 */
54 64
	public AbstractReferencedEntityElement(CdmFormFactory formFactory,
55 65
			AbstractFormSection section, T entity,
56
			SelectionListener removeListener,
57
			int style) {
66
			SelectionListener removeListener, int style) {
58 67
		super(formFactory, section, entity, removeListener, null, style);
59 68
	}
60
	
61
	/* (non-Javadoc)
62
	 * @see eu.etaxonomy.taxeditor.forms.section.AbstractEntityCollectionElement#createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * 
73
	 * @see
74
	 * eu.etaxonomy.taxeditor.forms.section.AbstractEntityCollectionElement#
75
	 * createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
63 76
	 */
64 77
	/** {@inheritDoc} */
65 78
	@Override
66 79
	public void createControls(ICdmFormElement formElement, int style) {
67
		selection_reference = (ReferenceSelectionElement) formFactory.createSelectionElement(SelectionType.REFERENCE, getConversationHolder(), formElement, "Reference", null, style);
68
		text_referenceDetail = formFactory.createTextWithLabelElement(formElement, "Reference Detail", null, SWT.NULL);
69
		if(hasOriginalNameString) text_originaleNameString = formFactory.createTextWithLabelElement(formElement, "Original Name", null, SWT.NULL);
80
		selection_reference = (ReferenceSelectionElement) formFactory
81
				.createSelectionElement(SelectionType.REFERENCE,
82
						getConversationHolder(), formElement, "Reference",
83
						null, ReferenceSelectionElement.DEFAULT, style);
84
		text_referenceDetail = formFactory.createTextWithLabelElement(
85
				formElement, "Reference Detail", null, SWT.NULL);
86
		if (hasOriginalNameString)
87
			text_originaleNameString = formFactory.createTextWithLabelElement(
88
					formElement, "Original Name", null, SWT.NULL);
70 89
	}
71
	
90

  
72 91
	/**
73
	 * <p>setEntity</p>
74
	 *
75
	 * @param entity a T object.
92
	 * <p>
93
	 * setEntity
94
	 * </p>
95
	 * 
96
	 * @param entity
97
	 *            a T object.
76 98
	 */
99
	@Override
77 100
	public void setEntity(T entity) {
78 101
		this.entity = entity;
79
		
102

  
80 103
		selection_reference.setEntity(entity.getCitation());
81 104
		text_referenceDetail.setText(entity.getCitationMicroReference());
82
		if(hasOriginalNameString) text_originaleNameString.setText(entity.getOriginalNameString());
83
//		// remove old listeners
84
//		clearEditButtonSelectionListener();
85
//		
86
//		addEditButtonSelectionListener(new BulkEditorOpeningSelectionListener(entity.getCitation()));
87
//		
105
		if (hasOriginalNameString)
106
			text_originaleNameString.setText(entity.getOriginalNameString());
107
		// // remove old listeners
108
		// clearEditButtonSelectionListener();
109
		//
110
		// addEditButtonSelectionListener(new
111
		// BulkEditorOpeningSelectionListener(entity.getCitation()));
112
		//
88 113
	};
89
//	
90
//	public void addEditButtonSelectionListener(SelectionListener listener){
91
//		selection_reference.addEditButtonSelectionListener(listener);
92
//	}
93
//	
94
//	public void removeEditButtonSelectionListener(SelectionListener listener){
95
//		selection_reference.removeEditorButtonSelectionListener(listener);
96
//	}
97
//	
98
//	public void clearEditButtonSelectionListener(){
99
//		selection_reference.clearEditButtonSelectionListener();
100
//	}
114

  
115
	//
116
	// public void addEditButtonSelectionListener(SelectionListener listener){
117
	// selection_reference.addEditButtonSelectionListener(listener);
118
	// }
119
	//
120
	// public void removeEditButtonSelectionListener(SelectionListener
121
	// listener){
122
	// selection_reference.removeEditorButtonSelectionListener(listener);
123
	// }
124
	//
125
	// public void clearEditButtonSelectionListener(){
126
	// selection_reference.clearEditButtonSelectionListener();
127
	// }
101 128

  
102 129
	/**
103
	 * <p>Setter for the field <code>hasOriginalNameString</code>.</p>
104
	 *
105
	 * @param hasOriginalNameString a boolean.
130
	 * <p>
131
	 * Setter for the field <code>hasOriginalNameString</code>.
132
	 * </p>
133
	 * 
134
	 * @param hasOriginalNameString
135
	 *            a boolean.
106 136
	 */
107 137
	public void setHasOriginalNameString(boolean hasOriginalNameString) {
108 138
		this.hasOriginalNameString = hasOriginalNameString;
109 139
	}
110 140

  
111 141
	/**
112
	 * <p>hasOriginalNameString</p>
113
	 *
142
	 * <p>
143
	 * hasOriginalNameString
144
	 * </p>
145
	 * 
114 146
	 * @return a boolean.
115 147
	 */
116 148
	public boolean hasOriginalNameString() {

Also available in: Unified diff