Revision f34721b8
Added by Patrick Plitzner about 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/PartialElement.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
13 | 13 |
import org.eclipse.jface.util.PropertyChangeEvent; |
14 | 14 |
import org.eclipse.swt.graphics.Color; |
15 | 15 |
import org.eclipse.swt.widgets.Label; |
16 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
16 | 17 |
import org.joda.time.Partial; |
17 | 18 |
|
18 | 19 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
... | ... | |
31 | 32 |
private NumberWithLabelElement number_month; |
32 | 33 |
private NumberWithLabelElement number_year; |
33 | 34 |
private Partial partial; |
34 |
|
|
35 |
|
|
35 | 36 |
/** |
36 | 37 |
* <p>Constructor for PartialElement.</p> |
37 | 38 |
* |
... | ... | |
43 | 44 |
public PartialElement(CdmFormFactory formFactory, |
44 | 45 |
ICdmFormElement formElement, String labelString, int style) { |
45 | 46 |
super(formFactory, formElement); |
46 |
|
|
47 |
formElement.getLayoutComposite().setLayout(LayoutConstants.LAYOUT(7, false)); |
|
48 |
|
|
47 |
|
|
48 |
TableWrapLayout layout = LayoutConstants.LAYOUT(7, false); |
|
49 |
layout.horizontalSpacing = 5; |
|
50 |
formElement.getLayoutComposite().setLayout(layout); |
|
51 |
|
|
49 | 52 |
label = formFactory.createLabel(getLayoutComposite(), labelString); |
50 | 53 |
addControl(label); |
51 |
|
|
54 |
|
|
52 | 55 |
number_year = formFactory.createNumberTextWithLabelElement(this, "Year", null, style); |
53 | 56 |
number_year.setLimits(4, -9999, 9999); |
54 |
|
|
55 |
number_month = formFactory.createNumberTextWithLabelElement(this, "Month", null, style);
|
|
57 |
|
|
58 |
number_month = formFactory.createNumberTextWithLabelElement(this, "Month", null, style); |
|
56 | 59 |
number_month.setLimits(2, 1, 12); |
57 |
|
|
60 |
|
|
58 | 61 |
number_day = formFactory.createNumberTextWithLabelElement(this, "Day", null, style); |
59 | 62 |
number_day.setLimits(2, 1, 31); |
60 |
|
|
61 |
|
|
62 |
formFactory.addPropertyChangeListener(this);
|
|
63 |
|
|
64 |
|
|
65 |
formFactory.addPropertyChangeListener(this); |
|
63 | 66 |
} |
64 |
|
|
67 |
|
|
65 | 68 |
/** |
66 | 69 |
* <p>Setter for the field <code>partial</code>.</p> |
67 | 70 |
* |
... | ... | |
69 | 72 |
*/ |
70 | 73 |
public void setPartial(Partial partial){ |
71 | 74 |
this.partial = partial; |
72 |
|
|
75 |
|
|
73 | 76 |
if(partial != null){ |
74 | 77 |
number_day.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.DAY_TYPE)); |
75 | 78 |
number_month.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.MONTH_TYPE)); |
... | ... | |
95 | 98 |
if(event == null){ |
96 | 99 |
return; |
97 | 100 |
} |
98 |
|
|
101 |
|
|
99 | 102 |
Object eventSource = event.getSource(); |
100 |
|
|
103 |
|
|
101 | 104 |
if(getElements().contains(eventSource)){ |
102 | 105 |
if(event instanceof CdmPropertyChangeEvent){ |
103 | 106 |
if(((CdmPropertyChangeEvent) event).hasException()){ |
... | ... | |
106 | 109 |
} |
107 | 110 |
} |
108 | 111 |
handleEvent(eventSource); |
109 |
}
|
|
112 |
} |
|
110 | 113 |
} |
111 |
|
|
114 |
|
|
112 | 115 |
/** |
113 | 116 |
* @param event |
114 | 117 |
*/ |
... | ... | |
123 | 126 |
} else{ |
124 | 127 |
partial = TimePeriod.setPartialField(partial, number_month.getInteger(), TimePeriod.MONTH_TYPE); |
125 | 128 |
} |
126 |
|
|
129 |
|
|
127 | 130 |
}else if(eventSource == number_day){ |
128 | 131 |
if (number_day.getInteger() == 0){ |
129 | 132 |
partial = TimePeriod.setPartialField(partial, null, TimePeriod.DAY_TYPE); |
130 | 133 |
} else{ |
131 | 134 |
partial = TimePeriod.setPartialField(partial, number_day.getInteger(), TimePeriod.DAY_TYPE); |
132 | 135 |
} |
133 |
|
|
134 |
|
|
136 |
|
|
137 |
|
|
135 | 138 |
}else if(eventSource == number_year){ |
136 | 139 |
if (number_year.getInteger() == 0){ |
137 | 140 |
partial = TimePeriod.setPartialField(partial, null, TimePeriod.YEAR_TYPE); |
138 | 141 |
} else{ |
139 | 142 |
partial = TimePeriod.setPartialField(partial, number_year.getInteger(), TimePeriod.YEAR_TYPE); |
140 | 143 |
} |
141 |
|
|
144 |
|
|
142 | 145 |
} |
143 | 146 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
144 | 147 |
} |
145 |
|
|
148 |
|
|
146 | 149 |
/** {@inheritDoc} */ |
147 | 150 |
@Override |
148 | 151 |
public void setBackground(Color color) { |
Also available in: Unified diff
Fix spacing for detail view elements #5436