Project

General

Profile

« Previous | Next » 

Revision 86d58314

Added by Niels Hoffmann about 13 years ago

New wizards are not finishable when no data was entered

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.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.name;
12 12

  
......
17 17

  
18 18
import eu.etaxonomy.cdm.model.name.NonViralName;
19 19
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
22 20
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
23 21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EnumComboType;
22
import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
23
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
24 25
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
25 26
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
26 27
import eu.etaxonomy.taxeditor.ui.term.NomenclaturalCodeComboElement;
27 28

  
28 29
/**
29
 * <p>NonViralNameDetailElement class.</p>
30
 *
30
 * <p>
31
 * NonViralNameDetailElement class.
32
 * </p>
33
 * 
31 34
 * @author n.hoffmann
32 35
 * @created May 20, 2010
33 36
 * @version 1.0
34 37
 */
35
public class NonViralNameDetailElement extends AbstractCdmDetailElement<NonViralName> {
38
public class NonViralNameDetailElement extends
39
		AbstractCdmDetailElement<NonViralName> {
36 40

  
37 41
	private NameDetailSection section_name;
38 42
	private AuthorshipDetailSection section_author;
......
40 44
	private NomenclaturalCodeComboElement combo_nomenclaturalCode;
41 45

  
42 46
	/**
43
	 * <p>Constructor for NonViralNameDetailElement.</p>
44
	 *
45
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
46
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
47
	 * <p>
48
	 * Constructor for NonViralNameDetailElement.
49
	 * </p>
50
	 * 
51
	 * @param formFactory
52
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
53
	 *            object.
54
	 * @param formElement
55
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
56
	 *            object.
47 57
	 */
48 58
	public NonViralNameDetailElement(CdmFormFactory formFactory,
49 59
			ICdmFormElement formElement) {
50 60
		super(formFactory, formElement);
51 61
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement, eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
62

  
63
	/*
64
	 * (non-Javadoc)
65
	 * 
66
	 * @see
67
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
68
	 * (eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement,
69
	 * eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
55 70
	 */
56 71
	/** {@inheritDoc} */
57 72
	@Override
58 73
	protected void createControls(ICdmFormElement formElement,
59 74
			final NonViralName entity, int style) {
60
		
61
		toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
62
		
63
		combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory.createEnumComboElement(EnumComboType.NOMENCLATURALCODE, formElement, style);
75

  
76
		toggleable_cache = formFactory.createToggleableTextField(formElement,
77
				"Cache", entity.getTitleCache(), entity.isProtectedTitleCache()
78
						|| entity.isProtectedFullTitleCache(), style);
79

  
80
		combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory
81
				.createEnumComboElement(EnumComboType.NOMENCLATURALCODE,
82
						formElement, style);
64 83
		combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
65
		
66
		section_name = (NameDetailSection) formFactory.createCdmDetailSection(DetailType.SCIENTIFICNAME, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
84

  
85
		section_name = (NameDetailSection) formFactory.createCdmDetailSection(
86
				DetailType.SCIENTIFICNAME, getConversationHolder(),
87
				formElement, null, Section.TWISTIE | Section.EXPANDED);
67 88
		section_name.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
68 89
		addControl(section_name);
69 90
		addElement(section_name);
70
		section_author = (AuthorshipDetailSection) formFactory.createCdmDetailSection(DetailType.AUTHORSHIP, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
91
		section_author = (AuthorshipDetailSection) formFactory
92
				.createCdmDetailSection(DetailType.AUTHORSHIP,
93
						getConversationHolder(), formElement, null,
94
						Section.TWISTIE | Section.EXPANDED);
71 95
		section_author.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
72 96
		addControl(section_author);
73 97
		addElement(section_author);
74 98
	}
75 99

  
76
	
77 100
	/** {@inheritDoc} */
78 101
	@Override
79 102
	protected void updateContent() {
80 103
		super.updateContent();
81
		
82
		// disable nomenclatural code, because changing of nom.code is not implemented on library side
104

  
105
		// disable nomenclatural code, because changing of nom.code is not
106
		// implemented on library side
83 107
		combo_nomenclaturalCode.setEnabled(false);
84
		
85
		setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
108

  
109
		setIrrelevant(toggleable_cache.getState(),
110
				Arrays.asList(new Object[] { toggleable_cache }));
86 111
	}
87
	
112

  
88 113
	/** {@inheritDoc} */
89 114
	@Override
90 115
	public void setEntity(NonViralName entity) {
......
92 117
		section_name.setEntity(entity);
93 118
		section_author.setEntity(entity);
94 119
	}
95
	
120

  
96 121
	/** {@inheritDoc} */
97 122
	@Override
98 123
	public void removeElements() {
99 124
		super.removeElements();
100
		if(section_name != null){
125
		if (section_name != null) {
101 126
			section_name.removeElements();
102 127
			removeControl(section_name);
103 128
			section_name.dispose();
104 129
			section_name = null;
105 130
		}
106
		if(section_author != null){
131
		if (section_author != null) {
107 132
			section_author.removeElements();
108 133
			removeControl(section_author);
109 134
			section_author.dispose();
110 135
			section_author = null;
111 136
		}
112 137
	}
113
	
114
	/* (non-Javadoc)
115
	 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
138

  
139
	/*
140
	 * (non-Javadoc)
141
	 * 
142
	 * @see
143
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
144
	 * .lang.Object)
116 145
	 */
117 146
	/** {@inheritDoc} */
118 147
	@Override
119 148
	public void handleEvent(Object eventSource) {
120
		if(eventSource == toggleable_cache){
121
			getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
122
			// we never want the fullTitleCache to be protected since we only use it for 
149
		if (eventSource == toggleable_cache) {
150
			getEntity().setTitleCache(toggleable_cache.getText(),
151
					toggleable_cache.getState());
152
			// we never want the fullTitleCache to be protected since we only
153
			// use it for
123 154
			// initiating the free text name editor
124 155
			getEntity().setProtectedFullTitleCache(false);
125 156
			boolean irrelevant = toggleable_cache.getState();
126
			List<Object> except = Arrays.asList(new Object[]{toggleable_cache});
157
			List<Object> except = Arrays
158
					.asList(new Object[] { toggleable_cache });
127 159
			setIrrelevant(irrelevant, except);
128
		}
129
		else if(eventSource == section_name || eventSource == section_author){
130
			if(getParentElement() instanceof AbstractCdmDetailSection)
160
		} else if (eventSource == section_name || eventSource == section_author) {
161
			if (getParentElement() instanceof AbstractCdmDetailSection)
131 162
				((AbstractCdmDetailSection) getParentElement()).updateTitle();
132
			if(! toggleable_cache.getState()){
163
			if (!toggleable_cache.getState()) {
133 164
				toggleable_cache.setText(getEntity().getTitleCache());
134 165
			}
135 166
		}
136
		if(eventSource == section_name){
167
		if (eventSource == section_name) {
137 168
			section_name.setEntity(getEntity());
138 169
			getLayoutComposite().layout();
139 170
		}
171

  
172
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
140 173
	}
141 174
}

Also available in: Unified diff