Revision a223e56b
Added by Patrick Plitzner over 10 years ago
- changed layout so that two colums are used for label and text field
.gitattributes | ||
---|---|---|
1261 | 1261 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java -text |
1262 | 1262 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java -text |
1263 | 1263 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/BrowserElement.java -text |
1264 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java -text |
|
1264 | 1265 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java -text |
1266 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmNumberField.java -text |
|
1265 | 1267 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmPropertyChangeEvent.java -text |
1268 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmTextField.java -text |
|
1266 | 1269 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CheckboxElement.java -text |
1267 | 1270 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/DateDetailSection.java -text |
1268 | 1271 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ICdmFormElement.java -text |
... | ... | |
1283 | 1286 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/LayoutConstants.java -text |
1284 | 1287 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/MultilanguageTextElement.java -text |
1285 | 1288 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/NumberWithLabelElement.java -text |
1286 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/NumberWithLabelElementComposite.java -text |
|
1287 | 1289 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/PartialElement.java -text |
1288 | 1290 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/PointElement.java -text |
1289 | 1291 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/RootElement.java -text |
1290 | 1292 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/SelectionArbitrator.java -text |
1291 | 1293 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextActionElement.java -text |
1292 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextWithLabelComposite.java -text |
|
1293 | 1294 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextWithLabelElement.java -text |
1294 | 1295 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TimePeriodElement.java -text |
1295 | 1296 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java -text |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.ui.element; |
|
2 |
import org.eclipse.swt.widgets.Composite; |
|
3 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
4 |
|
|
5 |
public final class CdmElementFactory { |
|
6 |
/** |
|
7 |
* @wbp.factory |
|
8 |
* @wbp.factory.parameter.source formFactory formFactory |
|
9 |
* @wbp.factory.parameter.source parentFormElement (eu.etaxonomy.taxeditor.ui.element.ICdmFormElement) null |
|
10 |
* @wbp.factory.parameter.source initialInteger (java.lang.Integer) null |
|
11 |
* @wbp.factory.parameter.source style 0 |
|
12 |
*/ |
|
13 |
public static CdmNumberField createCdmNumberField(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, Integer initialInteger, int style) { |
|
14 |
CdmNumberField cdmNumberField = new CdmNumberField(parent, formFactory, parentFormElement, initialInteger, style); |
|
15 |
return cdmNumberField; |
|
16 |
} |
|
17 |
|
|
18 |
/** |
|
19 |
* @param gatheringEventDetailElementComposite |
|
20 |
* @param formFactory |
|
21 |
* @param gatheringEventDetailElementComposite2 |
|
22 |
* @param string |
|
23 |
* @param integer |
|
24 |
* @param i |
|
25 |
* @return |
|
26 |
*/ |
|
27 |
public static CdmTextField createCdmTextField(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String initialText, Integer textHeight, int style) { |
|
28 |
CdmTextField cdmNumberField = new CdmTextField(parent, formFactory, parentFormElement, initialText, textHeight, style); |
|
29 |
return cdmNumberField; |
|
30 |
} |
|
31 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
2285 | 2285 |
return text; |
2286 | 2286 |
} |
2287 | 2287 |
|
2288 |
/** |
|
2289 |
* @param formFactory |
|
2290 |
* @param parentElement |
|
2291 |
* @param element |
|
2292 |
*/ |
|
2293 |
private static void addAndAdapt(FormToolkit formFactory, ICdmFormElement parentElement, TextWithLabelComposite element) { |
|
2294 |
if(formFactory instanceof CdmFormFactory){ |
|
2295 |
((CdmFormFactory) formFactory).adapt(element); |
|
2296 |
parentElement.addElement(element); |
|
2297 |
} |
|
2298 |
} |
|
2299 |
/** |
|
2300 |
* @wbp.factory |
|
2301 |
* @wbp.factory.parameter.source formFactory formFactory |
|
2302 |
* @wbp.factory.parameter.source parentFormElement parentFormElement |
|
2303 |
* @wbp.factory.parameter.source labelString "Elevation Minimum (m)" |
|
2304 |
* @wbp.factory.parameter.source initialText (java.lang.String) null |
|
2305 |
* @wbp.factory.parameter.source textHeight (java.lang.Integer) null |
|
2306 |
* @wbp.factory.parameter.source style 0 |
|
2307 |
*/ |
|
2308 |
public static TextWithLabelComposite createTextWithLabelComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String labelString, String initialText, Integer textHeight, int style) { |
|
2309 |
TextWithLabelComposite textWithLabelComposite = new TextWithLabelComposite(parent, formFactory, parentFormElement, labelString, initialText, textHeight, style); |
|
2310 |
// addAndAdapt(formFactory, parentFormElement, textWithLabelComposite); |
|
2311 |
return textWithLabelComposite; |
|
2312 |
} |
|
2313 |
/** |
|
2314 |
* @wbp.factory |
|
2315 |
* @wbp.factory.parameter.source formFactory getFormFactory() |
|
2316 |
* @wbp.factory.parameter.source parentElement parentFormElement |
|
2317 |
* @wbp.factory.parameter.source labelString "Elevation Minimum (m)" |
|
2318 |
* @wbp.factory.parameter.source initialFloat new java.lang.Float(0) |
|
2319 |
* @wbp.factory.parameter.source style org.eclipse.swt.SWT.NONE |
|
2320 |
*/ |
|
2321 |
public static NumberWithLabelElementComposite createNumberWithLabelElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentElement, String labelString, Float initialFloat, int style) { |
|
2322 |
NumberWithLabelElementComposite numberWithLabelElementComposite = new NumberWithLabelElementComposite(parent, formFactory, parentElement, labelString, initialFloat, style); |
|
2323 |
return numberWithLabelElementComposite; |
|
2324 |
} |
|
2325 | 2288 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmNumberField.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.ModifyEvent; |
|
14 |
import org.eclipse.swt.widgets.Composite; |
|
15 |
import org.eclipse.swt.widgets.Display; |
|
16 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author pplitzner |
|
22 |
* @date 01.08.2013 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class CdmNumberField extends CdmTextField { |
|
26 |
|
|
27 |
private Float start; |
|
28 |
private Float end; |
|
29 |
|
|
30 |
private NumberFormatException exception; |
|
31 |
|
|
32 |
/** |
|
33 |
* <p>Constructor for NumberWithLabelElement.</p> |
|
34 |
* |
|
35 |
* @param toolkit a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. |
|
36 |
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. |
|
37 |
* @param labelString a {@link java.lang.String} object. |
|
38 |
* @param initialInteger a {@link java.lang.Integer} object. |
|
39 |
* @param style a int. |
|
40 |
*/ |
|
41 |
public CdmNumberField(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, Integer initialInteger, int style){ |
|
42 |
this(parent, formFactory, parentFormElement, new Float(initialInteger==null?0:initialInteger), style); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* <p>Constructor for NumberWithLabelElement.</p> |
|
47 |
* |
|
48 |
* @param toolkit a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. |
|
49 |
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. |
|
50 |
* @param labelString a {@link java.lang.String} object. |
|
51 |
* @param initialFloat a {@link java.lang.Float} object. |
|
52 |
* @param style a int. |
|
53 |
* @wbp.parser.constructor |
|
54 |
*/ |
|
55 |
public CdmNumberField(Composite parent, FormToolkit formFactory, |
|
56 |
ICdmFormElement parentElement, Float initialFloat, int style) { |
|
57 |
super(parent, formFactory, parentElement, null, null, style); |
|
58 |
//WindowBuilder exception handling |
|
59 |
if(initialFloat==null){ |
|
60 |
initialFloat = 0f; |
|
61 |
} |
|
62 |
setFloat(initialFloat); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* <p>setInteger</p> |
|
67 |
* |
|
68 |
* @param number a {@link java.lang.Integer} object. |
|
69 |
*/ |
|
70 |
public void setInteger(Integer number) { |
|
71 |
super.setText(getStringRepresentation(number)); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* <p>setFloat</p> |
|
76 |
* |
|
77 |
* @param number a {@link java.lang.Float} object. |
|
78 |
*/ |
|
79 |
public void setFloat(Float number) { |
|
80 |
super.setText(getStringRepresentation(number)); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* <p>getInteger</p> |
|
85 |
* |
|
86 |
* @return a {@link java.lang.Integer} object. |
|
87 |
*/ |
|
88 |
public Integer getInteger() { |
|
89 |
String text = super.getText().trim(); |
|
90 |
return text.equals("") ? 0 : new Integer(text); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* <p>getFloat</p> |
|
95 |
* |
|
96 |
* @return a {@link java.lang.Float} object. |
|
97 |
*/ |
|
98 |
public Float getFloat(){ |
|
99 |
String text = super.getText(); |
|
100 |
return new Float(text); |
|
101 |
} |
|
102 |
|
|
103 |
private String getStringRepresentation(Object number){ |
|
104 |
if(number != null){ |
|
105 |
return number.toString(); |
|
106 |
} |
|
107 |
return null; |
|
108 |
} |
|
109 |
|
|
110 |
/* (non-Javadoc) |
|
111 |
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) |
|
112 |
*/ |
|
113 |
/** {@inheritDoc} */ |
|
114 |
@Override |
|
115 |
public void modifyText(ModifyEvent event) { |
|
116 |
String value = text.getText(); |
|
117 |
if(CdmUtils.isEmpty(value)){ |
|
118 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); |
|
119 |
return; |
|
120 |
} |
|
121 |
|
|
122 |
try{ |
|
123 |
|
|
124 |
Float number = Float.parseFloat(value); |
|
125 |
|
|
126 |
if((start != null && number < start) || (end != null && number > end)){ |
|
127 |
throw new NumberFormatException("You entered a number that is not within the allowed bounds."); |
|
128 |
} |
|
129 |
|
|
130 |
}catch(NumberFormatException e){ |
|
131 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
132 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
133 |
exception = e; |
|
134 |
return; |
|
135 |
} |
|
136 |
|
|
137 |
exception = null; |
|
138 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); |
|
139 |
|
|
140 |
super.modifyText(event); |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* <p>setLimits</p> |
|
145 |
* |
|
146 |
* @param numberOfDigits a int. |
|
147 |
* @param start a {@link java.lang.Integer} object. |
|
148 |
* @param end a {@link java.lang.Integer} object. |
|
149 |
*/ |
|
150 |
public void setLimits(int numberOfDigits, Integer start, Integer end){ |
|
151 |
setLimits(numberOfDigits, start.floatValue(), end.floatValue()); |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* <p>setLimits</p> |
|
156 |
* |
|
157 |
* @param numberOfDigits a int. |
|
158 |
* @param start a {@link java.lang.Float} object. |
|
159 |
* @param end a {@link java.lang.Float} object. |
|
160 |
*/ |
|
161 |
public void setLimits(int numberOfDigits, Float start, Float end){ |
|
162 |
text.setTextLimit(numberOfDigits); |
|
163 |
this.start = start; |
|
164 |
this.end = end; |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* <p>Getter for the field <code>exception</code>.</p> |
|
169 |
* |
|
170 |
* @return the exception |
|
171 |
*/ |
|
172 |
public NumberFormatException getException() { |
|
173 |
return exception; |
|
174 |
} |
|
175 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmTextField.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.KeyAdapter; |
|
14 |
import org.eclipse.swt.events.KeyEvent; |
|
15 |
import org.eclipse.swt.events.ModifyEvent; |
|
16 |
import org.eclipse.swt.events.ModifyListener; |
|
17 |
import org.eclipse.swt.graphics.Color; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Control; |
|
20 |
import org.eclipse.swt.widgets.Listener; |
|
21 |
import org.eclipse.swt.widgets.Text; |
|
22 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
23 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
|
24 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
25 |
|
|
26 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
27 |
import eu.etaxonomy.taxeditor.preference.Resources; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author pplitzner |
|
31 |
* @date 01.08.2013 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class CdmTextField extends AbstractCdmFormElementComposite implements ModifyListener, IEnableableFormElement, ISelectable{ |
|
35 |
|
|
36 |
protected Text text; |
|
37 |
|
|
38 |
/** Constant <code>MAX_HEIGHT=0</code> */ |
|
39 |
public static final int MAX_HEIGHT = 0; |
|
40 |
/** Constant <code>SINGLE=-1</code> */ |
|
41 |
public static final int SINGLE = -1; |
|
42 |
|
|
43 |
/** |
|
44 |
* Create the composite. |
|
45 |
* @param parent |
|
46 |
* @param style |
|
47 |
* @param initialText |
|
48 |
* @param textHeight |
|
49 |
*/ |
|
50 |
public CdmTextField(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String initialText, Integer textHeight, int style) { |
|
51 |
super(parent, formFactory, parentFormElement, style); |
|
52 |
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); |
|
53 |
|
|
54 |
//vvvvvvvvvvvvv |
|
55 |
|
|
56 |
initialText = initialText==null?"":initialText; |
|
57 |
|
|
58 |
int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI); |
|
59 |
|
|
60 |
int combinedStyle = style | SWT.BORDER | scrollStyle; |
|
61 |
|
|
62 |
// SWT.PASSWORD does not work when SWT.WRAP is set. |
|
63 |
if (style != SWT.PASSWORD) { |
|
64 |
combinedStyle = combinedStyle | SWT.WRAP; |
|
65 |
} |
|
66 |
//^^^^^^^^^^^^^^ |
|
67 |
|
|
68 |
text = new Text(this, SWT.NONE); |
|
69 |
TableWrapData twd_text_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); |
|
70 |
twd_text_1.grabHorizontal = true; |
|
71 |
text.setText(initialText); |
|
72 |
text.setLayoutData(twd_text_1); |
|
73 |
|
|
74 |
|
|
75 |
//vvvvvvvvvvvvvvvvvv |
|
76 |
if (textHeight == null) { |
|
77 |
text.addKeyListener(new KeyAdapter() { |
|
78 |
@Override |
|
79 |
public void keyPressed(KeyEvent e) { |
|
80 |
if (e.character == SWT.CR) { |
|
81 |
// Don't accept carriage returns as input when in single |
|
82 |
// line mode |
|
83 |
e.doit = false; |
|
84 |
} else if (e.character == SWT.TAB) { |
|
85 |
// traverse is not working for wrapped text widgets so |
|
86 |
// we reintroduce it here |
|
87 |
e.doit = false; |
|
88 |
CdmTextField.this.text.traverse(SWT.TRAVERSE_TAB_NEXT); |
|
89 |
} |
|
90 |
} |
|
91 |
}); |
|
92 |
} |
|
93 |
|
|
94 |
TableWrapData layoutData = LayoutConstants.FILL(); |
|
95 |
if (textHeight != null && textHeight > 0) { |
|
96 |
(layoutData).heightHint = textHeight; |
|
97 |
} |
|
98 |
|
|
99 |
text.setLayoutData(layoutData); |
|
100 |
|
|
101 |
text.addModifyListener(this); |
|
102 |
|
|
103 |
addControl(text); |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
protected void checkSubclass() { |
|
109 |
// Disable the check that prevents subclassing of SWT components |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Get the text of this composites text composite |
|
114 |
* |
|
115 |
* @return a {@link java.lang.String} object. |
|
116 |
*/ |
|
117 |
public String getText() { |
|
118 |
return text.getText(); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Set the text of this composites text composite |
|
123 |
* |
|
124 |
* @param string |
|
125 |
* a {@link java.lang.String} object. |
|
126 |
*/ |
|
127 |
public void setText(String string) { |
|
128 |
Listener[] listeners = text.getListeners(SWT.Modify); |
|
129 |
|
|
130 |
for (Listener listener : listeners) { |
|
131 |
text.removeListener(SWT.Modify, listener); |
|
132 |
} |
|
133 |
|
|
134 |
text.setText(CdmUtils.Nz(string)); |
|
135 |
|
|
136 |
for (Listener listener : listeners) { |
|
137 |
text.addListener(SWT.Modify, listener); |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* (non-Javadoc) |
|
143 |
* |
|
144 |
* @see |
|
145 |
* org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events |
|
146 |
* .ModifyEvent) |
|
147 |
*/ |
|
148 |
/** {@inheritDoc} */ |
|
149 |
@Override |
|
150 |
public void modifyText(ModifyEvent e) { |
|
151 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
152 |
} |
|
153 |
|
|
154 |
/** {@inheritDoc} */ |
|
155 |
@Override |
|
156 |
public void setEnabled(boolean enabled) { |
|
157 |
text.setEnabled(enabled); |
|
158 |
String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED; |
|
159 |
text.setForeground(getColor(symbolicName)); |
|
160 |
} |
|
161 |
|
|
162 |
/** {@inheritDoc} */ |
|
163 |
@Override |
|
164 |
public void setIrrelevant(boolean irrelevant) { |
|
165 |
String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND; |
|
166 |
|
|
167 |
Color color = getColor(colorId); |
|
168 |
text.setBackground(color); |
|
169 |
} |
|
170 |
|
|
171 |
@Override |
|
172 |
public void setSelected(boolean selected) { |
|
173 |
setBackground(selected ? SELECTED : getPersistentBackground()); |
|
174 |
} |
|
175 |
|
|
176 |
/* |
|
177 |
* (non-Javadoc) |
|
178 |
* |
|
179 |
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus() |
|
180 |
*/ |
|
181 |
/** {@inheritDoc} |
|
182 |
* @return */ |
|
183 |
@Override |
|
184 |
public boolean setFocus() { |
|
185 |
return text.setFocus(); |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* <p> |
|
190 |
* getMainControl |
|
191 |
* </p> |
|
192 |
* |
|
193 |
* @return a {@link org.eclipse.swt.widgets.Control} object. |
|
194 |
*/ |
|
195 |
public Control getMainControl() { |
|
196 |
return text; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* <p> |
|
201 |
* setTextLimit |
|
202 |
* </p> |
|
203 |
* |
|
204 |
* @param limit |
|
205 |
* a int. |
|
206 |
*/ |
|
207 |
public void setTextLimit(int limit) { |
|
208 |
text.setTextLimit(limit); |
|
209 |
} |
|
210 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/NumberWithLabelElementComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.ModifyEvent; |
|
14 |
import org.eclipse.swt.widgets.Composite; |
|
15 |
import org.eclipse.swt.widgets.Display; |
|
16 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author pplitzner |
|
22 |
* @date 31.07.2013 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class NumberWithLabelElementComposite extends TextWithLabelComposite{ |
|
26 |
|
|
27 |
private Float start; |
|
28 |
private Float end; |
|
29 |
|
|
30 |
private NumberFormatException exception; |
|
31 |
|
|
32 |
/** |
|
33 |
* <p>Constructor for NumberWithLabelElement.</p> |
|
34 |
* |
|
35 |
* @param toolkit a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. |
|
36 |
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. |
|
37 |
* @param labelString a {@link java.lang.String} object. |
|
38 |
* @param initialInteger a {@link java.lang.Integer} object. |
|
39 |
* @param style a int. |
|
40 |
*/ |
|
41 |
public NumberWithLabelElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, |
|
42 |
String labelString, Integer initialInteger, int style){ |
|
43 |
this(parent, formFactory, parentFormElement, labelString, new Float(initialInteger), style); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* <p>Constructor for NumberWithLabelElement.</p> |
|
48 |
* |
|
49 |
* @param toolkit a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. |
|
50 |
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. |
|
51 |
* @param labelString a {@link java.lang.String} object. |
|
52 |
* @param initialFloat a {@link java.lang.Float} object. |
|
53 |
* @param style a int. |
|
54 |
* @wbp.parser.constructor |
|
55 |
*/ |
|
56 |
public NumberWithLabelElementComposite(Composite parent, FormToolkit formFactory, |
|
57 |
ICdmFormElement parentElement, String labelString, |
|
58 |
Float initialFloat, int style) { |
|
59 |
super(parent, formFactory, parentElement, labelString, null, null, style); |
|
60 |
setFloat(initialFloat); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* <p>setInteger</p> |
|
65 |
* |
|
66 |
* @param number a {@link java.lang.Integer} object. |
|
67 |
*/ |
|
68 |
public void setInteger(Integer number) { |
|
69 |
super.setText(getStringRepresentation(number)); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* <p>setFloat</p> |
|
74 |
* |
|
75 |
* @param number a {@link java.lang.Float} object. |
|
76 |
*/ |
|
77 |
public void setFloat(Float number) { |
|
78 |
super.setText(getStringRepresentation(number)); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* <p>getInteger</p> |
|
83 |
* |
|
84 |
* @return a {@link java.lang.Integer} object. |
|
85 |
*/ |
|
86 |
public Integer getInteger() { |
|
87 |
String text = super.getText().trim(); |
|
88 |
return text.equals("") ? 0 : new Integer(text); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* <p>getFloat</p> |
|
93 |
* |
|
94 |
* @return a {@link java.lang.Float} object. |
|
95 |
*/ |
|
96 |
public Float getFloat(){ |
|
97 |
String text = super.getText(); |
|
98 |
return new Float(text); |
|
99 |
} |
|
100 |
|
|
101 |
private String getStringRepresentation(Object number){ |
|
102 |
if(number != null){ |
|
103 |
return number.toString(); |
|
104 |
} |
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
108 |
/* (non-Javadoc) |
|
109 |
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) |
|
110 |
*/ |
|
111 |
/** {@inheritDoc} */ |
|
112 |
@Override |
|
113 |
public void modifyText(ModifyEvent event) { |
|
114 |
String value = text.getText(); |
|
115 |
if(CdmUtils.isEmpty(value)){ |
|
116 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); |
|
117 |
return; |
|
118 |
} |
|
119 |
|
|
120 |
try{ |
|
121 |
|
|
122 |
Float number = Float.parseFloat(value); |
|
123 |
|
|
124 |
if((start != null && number < start) || (end != null && number > end)){ |
|
125 |
throw new NumberFormatException("You entered a number that is not within the allowed bounds."); |
|
126 |
} |
|
127 |
|
|
128 |
}catch(NumberFormatException e){ |
|
129 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
130 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
131 |
exception = e; |
|
132 |
return; |
|
133 |
} |
|
134 |
|
|
135 |
exception = null; |
|
136 |
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); |
|
137 |
|
|
138 |
super.modifyText(event); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* <p>setLimits</p> |
|
143 |
* |
|
144 |
* @param numberOfDigits a int. |
|
145 |
* @param start a {@link java.lang.Integer} object. |
|
146 |
* @param end a {@link java.lang.Integer} object. |
|
147 |
*/ |
|
148 |
public void setLimits(int numberOfDigits, Integer start, Integer end){ |
|
149 |
setLimits(numberOfDigits, start.floatValue(), end.floatValue()); |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* <p>setLimits</p> |
|
154 |
* |
|
155 |
* @param numberOfDigits a int. |
|
156 |
* @param start a {@link java.lang.Float} object. |
|
157 |
* @param end a {@link java.lang.Float} object. |
|
158 |
*/ |
|
159 |
public void setLimits(int numberOfDigits, Float start, Float end){ |
|
160 |
text.setTextLimit(numberOfDigits); |
|
161 |
this.start = start; |
|
162 |
this.end = end; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* <p>Getter for the field <code>exception</code>.</p> |
|
167 |
* |
|
168 |
* @return the exception |
|
169 |
*/ |
|
170 |
public NumberFormatException getException() { |
|
171 |
return exception; |
|
172 |
} |
|
173 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextWithLabelComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.KeyAdapter; |
|
14 |
import org.eclipse.swt.events.KeyEvent; |
|
15 |
import org.eclipse.swt.events.ModifyEvent; |
|
16 |
import org.eclipse.swt.events.ModifyListener; |
|
17 |
import org.eclipse.swt.graphics.Color; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Control; |
|
20 |
import org.eclipse.swt.widgets.Label; |
|
21 |
import org.eclipse.swt.widgets.Listener; |
|
22 |
import org.eclipse.swt.widgets.Text; |
|
23 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
24 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
|
25 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
26 |
|
|
27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
28 |
import eu.etaxonomy.taxeditor.preference.Resources; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author pplitzner |
|
32 |
* @date 23.07.2013 |
|
33 |
* |
|
34 |
*/ |
|
35 |
public class TextWithLabelComposite extends AbstractCdmFormElementComposite implements ModifyListener, IEnableableFormElement, ISelectable { |
|
36 |
|
|
37 |
protected Text text; |
|
38 |
private final Label label; |
|
39 |
|
|
40 |
/** Constant <code>MAX_HEIGHT=0</code> */ |
|
41 |
public static final int MAX_HEIGHT = 0; |
|
42 |
/** Constant <code>SINGLE=-1</code> */ |
|
43 |
public static final int SINGLE = -1; |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* |
|
48 |
*/ |
|
49 |
public TextWithLabelComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String labelString, |
|
50 |
String initialText, Integer textHeight, int style) { |
|
51 |
super(parent, formFactory, parentFormElement, style); |
|
52 |
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); |
|
53 |
|
|
54 |
//vvvvvvvvvvvvv |
|
55 |
|
|
56 |
initialText = initialText==null?"":initialText; |
|
57 |
|
|
58 |
int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI); |
|
59 |
|
|
60 |
int combinedStyle = style | SWT.BORDER | scrollStyle; |
|
61 |
|
|
62 |
// SWT.PASSWORD does not work when SWT.WRAP is set. |
|
63 |
if (style != SWT.PASSWORD) { |
|
64 |
combinedStyle = combinedStyle | SWT.WRAP; |
|
65 |
} |
|
66 |
//^^^^^^^^^^^^^^ |
|
67 |
|
|
68 |
label = new Label(this, SWT.NONE); |
|
69 |
TableWrapData twd_lblNewLabel = new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP); |
|
70 |
twd_lblNewLabel.grabHorizontal = true; |
|
71 |
twd_lblNewLabel.align = TableWrapData.LEFT; |
|
72 |
label.setLayoutData(twd_lblNewLabel); |
|
73 |
label.setText(labelString); |
|
74 |
|
|
75 |
text = new Text(this, SWT.NONE); |
|
76 |
TableWrapData twd_text_1 = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP); |
|
77 |
twd_text_1.align = TableWrapData.RIGHT; |
|
78 |
twd_text_1.grabHorizontal = false; |
|
79 |
text.setText(initialText); |
|
80 |
text.setLayoutData(twd_text_1); |
|
81 |
|
|
82 |
|
|
83 |
//vvvvvvvvvvvvvvvvvv |
|
84 |
if (textHeight == null) { |
|
85 |
text.addKeyListener(new KeyAdapter() { |
|
86 |
@Override |
|
87 |
public void keyPressed(KeyEvent e) { |
|
88 |
if (e.character == SWT.CR) { |
|
89 |
// Don't accept carriage returns as input when in single |
|
90 |
// line mode |
|
91 |
e.doit = false; |
|
92 |
} else if (e.character == SWT.TAB) { |
|
93 |
// traverse is not working for wrapped text widgets so |
|
94 |
// we reintroduce it here |
|
95 |
e.doit = false; |
|
96 |
TextWithLabelComposite.this.text.traverse(SWT.TRAVERSE_TAB_NEXT); |
|
97 |
} |
|
98 |
} |
|
99 |
}); |
|
100 |
} |
|
101 |
|
|
102 |
TableWrapData layoutData = LayoutConstants.FILL(); |
|
103 |
if (textHeight != null && textHeight > 0) { |
|
104 |
(layoutData).heightHint = textHeight; |
|
105 |
} |
|
106 |
|
|
107 |
text.setLayoutData(layoutData); |
|
108 |
|
|
109 |
text.addModifyListener(this); |
|
110 |
|
|
111 |
addControl(label); |
|
112 |
addControl(text); |
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
/** |
|
117 |
* Get the text of this composites text composite |
|
118 |
* |
|
119 |
* @return a {@link java.lang.String} object. |
|
120 |
*/ |
|
121 |
public String getText() { |
|
122 |
return text.getText(); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Set the text of this composites text composite |
|
127 |
* |
|
128 |
* @param string |
|
129 |
* a {@link java.lang.String} object. |
|
130 |
*/ |
|
131 |
public void setText(String string) { |
|
132 |
Listener[] listeners = text.getListeners(SWT.Modify); |
|
133 |
|
|
134 |
for (Listener listener : listeners) { |
|
135 |
text.removeListener(SWT.Modify, listener); |
|
136 |
} |
|
137 |
|
|
138 |
text.setText(CdmUtils.Nz(string)); |
|
139 |
|
|
140 |
for (Listener listener : listeners) { |
|
141 |
text.addListener(SWT.Modify, listener); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
/* |
|
146 |
* (non-Javadoc) |
|
147 |
* |
|
148 |
* @see |
|
149 |
* org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events |
|
150 |
* .ModifyEvent) |
|
151 |
*/ |
|
152 |
/** {@inheritDoc} */ |
|
153 |
@Override |
|
154 |
public void modifyText(ModifyEvent e) { |
|
155 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
156 |
} |
|
157 |
|
|
158 |
/** {@inheritDoc} */ |
|
159 |
@Override |
|
160 |
public void setEnabled(boolean enabled) { |
|
161 |
text.setEnabled(enabled); |
|
162 |
String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED; |
|
163 |
text.setForeground(getColor(symbolicName)); |
|
164 |
} |
|
165 |
|
|
166 |
/** {@inheritDoc} */ |
|
167 |
@Override |
|
168 |
public void setIrrelevant(boolean irrelevant) { |
|
169 |
String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND; |
|
170 |
|
|
171 |
Color color = getColor(colorId); |
|
172 |
text.setBackground(color); |
|
173 |
} |
|
174 |
|
|
175 |
/** {@inheritDoc} */ |
|
176 |
@Override |
|
177 |
public void setBackground(Color color) { |
|
178 |
super.setBackground(color); |
|
179 |
if (label != null) { |
|
180 |
label.setBackground(color); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
@Override |
|
185 |
public void setSelected(boolean selected) { |
|
186 |
setBackground(selected ? SELECTED : getPersistentBackground()); |
|
187 |
} |
|
188 |
|
|
189 |
/* |
|
190 |
* (non-Javadoc) |
|
191 |
* |
|
192 |
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus() |
|
193 |
*/ |
|
194 |
/** {@inheritDoc} |
|
195 |
* @return */ |
|
196 |
@Override |
|
197 |
public boolean setFocus() { |
|
198 |
return text.setFocus(); |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* <p> |
|
203 |
* getMainControl |
|
204 |
* </p> |
|
205 |
* |
|
206 |
* @return a {@link org.eclipse.swt.widgets.Control} object. |
|
207 |
*/ |
|
208 |
public Control getMainControl() { |
|
209 |
return text; |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* <p> |
|
214 |
* setTextLimit |
|
215 |
* </p> |
|
216 |
* |
|
217 |
* @param limit |
|
218 |
* a int. |
|
219 |
*/ |
|
220 |
public void setTextLimit(int limit) { |
|
221 |
text.setTextLimit(limit); |
|
222 |
} |
|
223 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java | ||
---|---|---|
15 | 15 |
import org.eclipse.swt.SWT; |
16 | 16 |
import org.eclipse.swt.widgets.Composite; |
17 | 17 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
18 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
20 | 21 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
... | ... | |
53 | 54 |
*/ |
54 | 55 |
public AbstractCdmDetailElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, int style) { |
55 | 56 |
super(parent, formFactory, parentFormElement, style); |
57 |
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); |
|
56 | 58 |
// register as property change listener |
57 | 59 |
if(formFactory instanceof CdmFormFactory){ |
58 | 60 |
((CdmFormFactory) formFactory).addPropertyChangeListener(this); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GatheringEventDetailElementComposite.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import org.eclipse.swt.SWT; |
13 | 13 |
import org.eclipse.swt.widgets.Composite; |
14 |
import org.eclipse.swt.widgets.Label; |
|
14 | 15 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
15 | 16 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
16 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
17 | 17 |
|
18 | 18 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
19 | 19 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
20 | 20 |
import eu.etaxonomy.taxeditor.preference.Resources; |
21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.CdmElementFactory; |
|
22 |
import eu.etaxonomy.taxeditor.ui.element.CdmNumberField; |
|
23 |
import eu.etaxonomy.taxeditor.ui.element.CdmTextField; |
|
22 | 24 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
23 |
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElementComposite; |
|
24 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelComposite; |
|
25 | 25 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElementComposite; |
26 | 26 |
|
27 | 27 |
/** |
... | ... | |
33 | 33 |
|
34 | 34 |
|
35 | 35 |
|
36 |
private final CdmNumberField absoluteElevationError; |
|
37 |
private final CdmNumberField number_absoluteElevationMinimum; |
|
38 |
private final CdmNumberField number_absoluteElevationMaximum; |
|
39 |
private final CdmTextField collectingMethod; |
|
40 |
private final CdmNumberField number_distanceToGround; |
|
41 |
private final CdmNumberField number_distanceToWaterSurface; |
|
42 |
private final CdmTextField gatheringEventDescription; |
|
36 | 43 |
// private CollectingAreasDetailSection section_collectingAreas; |
37 |
private final NumberWithLabelElementComposite absoluteElevationError; |
|
38 |
private final NumberWithLabelElementComposite number_absoluteElevationMinimum; |
|
39 |
private final NumberWithLabelElementComposite number_absoluteElevationMaximum; |
|
40 |
private final TextWithLabelComposite collectingMethod; |
|
41 |
private final NumberWithLabelElementComposite number_distanceToGround; |
|
42 |
private final NumberWithLabelElementComposite number_distanceToWaterSurface; |
|
43 |
private final TextWithLabelComposite gatheringEventDescription; |
|
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* <p> |
... | ... | |
56 | 56 |
*/ |
57 | 57 |
public GatheringEventDetailElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, int style) { |
58 | 58 |
super(parent, formFactory, parentFormElement, style); |
59 |
TableWrapLayout tableWrapLayout = (TableWrapLayout) getLayout(); |
|
60 |
tableWrapLayout.numColumns = 1; |
|
61 |
|
|
62 |
absoluteElevationError = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), this, "Elevation Error", new Float(0), SWT.NONE); |
|
63 |
TableWrapData twd_absoluteElevationError = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
64 |
twd_absoluteElevationError.grabHorizontal = true; |
|
65 |
absoluteElevationError.setLayoutData(twd_absoluteElevationError); |
|
66 |
getFormFactory().adapt(absoluteElevationError); |
|
67 |
getFormFactory().paintBordersFor(absoluteElevationError); |
|
68 |
|
|
69 |
number_absoluteElevationMinimum = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), this, "Elevation Minimum (m)", new Float(0), SWT.NONE); |
|
70 |
TableWrapData twd_number_absoluteElevationMinimum = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
71 |
twd_number_absoluteElevationMinimum.grabHorizontal = true; |
|
72 |
number_absoluteElevationMinimum.setLayoutData(twd_number_absoluteElevationMinimum); |
|
59 |
|
|
60 |
Label lblNewLabel_4 = new Label(this, SWT.NONE); |
|
61 |
formFactory.adapt(lblNewLabel_4, true, true); |
|
62 |
lblNewLabel_4.setText("Elevation Error"); |
|
63 |
|
|
64 |
absoluteElevationError = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); |
|
65 |
((TableWrapData) absoluteElevationError.getMainControl().getLayoutData()).grabVertical = false; |
|
66 |
TableWrapData twd_cdmNumberField = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
67 |
twd_cdmNumberField.grabHorizontal = true; |
|
68 |
absoluteElevationError.setLayoutData(twd_cdmNumberField); |
|
69 |
formFactory.adapt(absoluteElevationError); |
|
70 |
formFactory.paintBordersFor(absoluteElevationError); |
|
71 |
|
|
72 |
Label lblNewLabel_3 = new Label(this, SWT.NONE); |
|
73 |
formFactory.adapt(lblNewLabel_3, true, true); |
|
74 |
lblNewLabel_3.setText("Elevation Error Minumum (m)"); |
|
75 |
|
|
76 |
number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); |
|
77 |
TableWrapData tableWrapData = (TableWrapData) number_absoluteElevationMinimum.getMainControl().getLayoutData(); |
|
78 |
tableWrapData.valign = TableWrapData.TOP; |
|
79 |
tableWrapData.grabVertical = false; |
|
80 |
TableWrapData twd_cdmNumberField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
81 |
twd_cdmNumberField_1.grabHorizontal = true; |
|
82 |
number_absoluteElevationMinimum.setLayoutData(twd_cdmNumberField_1); |
|
73 | 83 |
formFactory.paintBordersFor(number_absoluteElevationMinimum); |
74 | 84 |
|
75 |
number_absoluteElevationMaximum = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Elevation Maximum (m)", new Float(0), SWT.NONE); |
|
76 |
TableWrapData twd_numberWithLabelElementComposite = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
77 |
twd_numberWithLabelElementComposite.grabVertical = true; |
|
78 |
twd_numberWithLabelElementComposite.grabHorizontal = true; |
|
79 |
number_absoluteElevationMaximum.setLayoutData(twd_numberWithLabelElementComposite); |
|
80 |
formFactory.paintBordersFor(number_absoluteElevationMaximum); |
|
85 |
Label lblNewLabel_2 = new Label(this, SWT.NONE); |
|
86 |
formFactory.adapt(lblNewLabel_2, true, true); |
|
87 |
lblNewLabel_2.setText("Elevation Maximum (m)"); |
|
81 | 88 |
|
82 |
collectingMethod = CdmFormFactory.createTextWithLabelComposite(this, getFormFactory(), this, "Collecting Method", "", (Integer) null, SWT.NONE);
|
|
83 |
TableWrapData twd_collectingMethod = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
|
|
84 |
twd_collectingMethod.grabHorizontal = true;
|
|
85 |
collectingMethod.setLayoutData(twd_collectingMethod);
|
|
86 |
getFormFactory().adapt(collectingMethod);
|
|
87 |
getFormFactory().paintBordersFor(collectingMethod);
|
|
89 |
number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
90 |
TableWrapData twd_cdmNumberField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
|
|
91 |
twd_cdmNumberField_2.grabHorizontal = true;
|
|
92 |
number_absoluteElevationMaximum.setLayoutData(twd_cdmNumberField_2);
|
|
93 |
formFactory.adapt(number_absoluteElevationMaximum);
|
|
94 |
formFactory.paintBordersFor(number_absoluteElevationMaximum);
|
|
88 | 95 |
|
89 |
number_distanceToGround = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Distance To Ground (m)", new Float(0), SWT.NONE); |
|
96 |
Label lblTestLabel = new Label(this, SWT.NONE); |
|
97 |
formFactory.adapt(lblTestLabel, true, true); |
|
98 |
lblTestLabel.setText("Collecting Method"); |
|
99 |
|
|
100 |
collectingMethod = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0); |
|
101 |
TableWrapData twd_cdmTextField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
102 |
twd_cdmTextField_1.grabHorizontal = true; |
|
103 |
collectingMethod.setLayoutData(twd_cdmTextField_1); |
|
104 |
formFactory.adapt(collectingMethod); |
|
105 |
formFactory.paintBordersFor(collectingMethod); |
|
106 |
|
|
107 |
Label lblNewLabel_5 = new Label(this, SWT.NONE); |
|
108 |
formFactory.adapt(lblNewLabel_5, true, true); |
|
109 |
lblNewLabel_5.setText("Distance To Ground (m)"); |
|
110 |
|
|
111 |
number_distanceToGround = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); |
|
112 |
TableWrapData twd_cdmNumberField_3 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
113 |
twd_cdmNumberField_3.grabHorizontal = true; |
|
114 |
number_distanceToGround.setLayoutData(twd_cdmNumberField_3); |
|
115 |
formFactory.adapt(number_distanceToGround); |
|
90 | 116 |
formFactory.paintBordersFor(number_distanceToGround); |
91 | 117 |
|
92 |
number_distanceToWaterSurface = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Distance To Water Surface (m)", new Float(0), SWT.NONE); |
|
118 |
Label lblNewLabel_6 = new Label(this, SWT.NONE); |
|
119 |
formFactory.adapt(lblNewLabel_6, true, true); |
|
120 |
lblNewLabel_6.setText("Distance To Water Surface"); |
|
121 |
|
|
122 |
number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); |
|
123 |
TableWrapData twd_cdmNumberField_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
124 |
twd_cdmNumberField_4.grabHorizontal = true; |
|
125 |
number_distanceToWaterSurface.setLayoutData(twd_cdmNumberField_4); |
|
126 |
formFactory.adapt(number_distanceToWaterSurface); |
|
93 | 127 |
formFactory.paintBordersFor(number_distanceToWaterSurface); |
94 | 128 |
|
95 |
gatheringEventDescription = CdmFormFactory.createTextWithLabelComposite(this, getFormFactory(), this, "Gathering Event Description", "", (Integer) null, SWT.NONE); |
|
96 |
TableWrapData twd_gatheringEventDescription = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
97 |
twd_gatheringEventDescription.grabHorizontal = true; |
|
98 |
gatheringEventDescription.setLayoutData(twd_gatheringEventDescription); |
|
99 |
getFormFactory().adapt(gatheringEventDescription); |
|
100 |
getFormFactory().paintBordersFor(gatheringEventDescription); |
|
129 |
Label lblNewLabel = new Label(this, SWT.NONE); |
|
130 |
formFactory.adapt(lblNewLabel, true, true); |
|
131 |
lblNewLabel.setText("Gathering Event Description"); |
|
132 |
|
|
133 |
gatheringEventDescription = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0); |
|
134 |
TableWrapData twd_cdmTextField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
|
135 |
twd_cdmTextField_2.grabHorizontal = true; |
|
136 |
gatheringEventDescription.setLayoutData(twd_cdmTextField_2); |
|
137 |
formFactory.adapt(gatheringEventDescription); |
|
138 |
formFactory.paintBordersFor(gatheringEventDescription); |
|
101 | 139 |
|
102 | 140 |
} |
103 | 141 |
|
... | ... | |
151 | 189 |
number_absoluteElevationMaximum.setBackground(getColor(Resources.COLOR_PARSE_ERROR)); |
152 | 190 |
AbstractUtility.warn(getClass(), e.getLocalizedMessage()); |
153 | 191 |
} |
154 |
} else if (eventSource == getCollectingMethod()) {
|
|
155 |
getEntity().setCollectingMethod(getCollectingMethod().getText());
|
|
192 |
} else if (eventSource == collectingMethod) {
|
|
193 |
getEntity().setCollectingMethod(collectingMethod.getText());
|
|
156 | 194 |
} else if (eventSource == number_distanceToGround) { |
157 | 195 |
getEntity().setDistanceToGround(number_distanceToGround.getInteger()); |
158 | 196 |
} else if (eventSource == number_distanceToWaterSurface) { |
159 | 197 |
getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface.getInteger()); |
160 |
} else if (eventSource == getGatheringEventDescription()) {
|
|
161 |
getEntity().setGatheringEventDescription(getGatheringEventDescription().getText());
|
|
198 |
} else if (eventSource == gatheringEventDescription) {
|
|
199 |
getEntity().setGatheringEventDescription(gatheringEventDescription.getText());
|
|
162 | 200 |
} |
163 | 201 |
} |
164 |
public TextWithLabelComposite getGatheringEventDescription() { |
|
165 |
return gatheringEventDescription; |
|
166 |
} |
|
167 |
public TextWithLabelComposite getCollectingMethod() { |
|
168 |
return collectingMethod; |
|
169 |
} |
|
170 | 202 |
} |
Also available in: Unified diff