Revision 68d5a162
Added by Katja Luther almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/DateDetailSection.java | ||
---|---|---|
34 | 34 |
private TextWithLabelElement text_parseText; |
35 | 35 |
private int cursorPosition; |
36 | 36 |
|
37 |
/** |
|
37 |
public int getCursorPosition() { |
|
38 |
return cursorPosition; |
|
39 |
} |
|
40 |
|
|
41 |
public void setCursorPosition(int cursorPosition) { |
|
42 |
this.cursorPosition = cursorPosition; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
38 | 46 |
* <p> |
39 | 47 |
* Constructor for DateDetailSection. |
40 | 48 |
* </p> |
... | ... | |
98 | 106 |
* When setting the entity through parsing we do not want to alter the parse field |
99 | 107 |
* @param timePeriod |
100 | 108 |
*/ |
101 |
private void setEntityInternally(TimePeriod timePeriod){
|
|
109 |
protected void setEntityInternally(TimePeriod timePeriod){
|
|
102 | 110 |
Partial start = timePeriod.getStart(); |
103 | 111 |
partialElement_start.setPartial(start); |
104 | 112 |
Partial end = timePeriod.getEnd(); |
... | ... | |
155 | 163 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
156 | 164 |
} |
157 | 165 |
|
158 |
private void updateTitle(){
|
|
166 |
protected void updateTitle(){
|
|
159 | 167 |
String title = CdmUtils.Nz(getEntity().toString()); |
160 | 168 |
this.setText(title); |
161 | 169 |
layout(); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/VerbatimDateDetailSection.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.element; |
10 | 10 |
|
11 |
import org.eclipse.swt.widgets.Text; |
|
12 |
|
|
11 | 13 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
12 | 14 |
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod; |
13 | 15 |
|
... | ... | |
60 | 62 |
*/ |
61 | 63 |
@Override |
62 | 64 |
public void setEntity(TimePeriod timePeriod) { |
65 |
setEntityInternally(timePeriod); |
|
66 |
updateTitle(); |
|
67 |
getText_parseText().setText(timePeriod.toString()); |
|
63 | 68 |
if (timePeriod instanceof VerbatimTimePeriod){ |
64 | 69 |
text_VerbatimDate.setText(((VerbatimTimePeriod)timePeriod).getVerbatimDate()); |
65 | 70 |
} |
... | ... | |
68 | 73 |
protected void handleEvent(Object eventSource) { |
69 | 74 |
|
70 | 75 |
if (eventSource == text_VerbatimDate) { |
71 |
|
|
72 |
((VerbatimTimePeriod)getEntity()).setVerbatimDate(text_VerbatimDate.getText()); |
|
76 |
TimePeriod entity = getEntity(); |
|
77 |
if(entity instanceof VerbatimTimePeriod){ |
|
78 |
((VerbatimTimePeriod)entity).setVerbatimDate(text_VerbatimDate.getText()); |
|
79 |
}else{ |
|
80 |
VerbatimTimePeriod newEntity = VerbatimTimePeriod.NewVerbatimInstance(); |
|
81 |
newEntity.setEnd(entity.getEnd()); |
|
82 |
newEntity.setStart(entity.getStart()); |
|
83 |
newEntity.setFreeText(entity.getFreeText()); |
|
84 |
setEntity(newEntity); |
|
85 |
((VerbatimTimePeriod)getEntity()).setVerbatimDate(text_VerbatimDate.getText()); |
|
86 |
} |
|
73 | 87 |
} |
74 | 88 |
super.handleEvent(eventSource); |
75 | 89 |
|
76 | 90 |
} |
77 | 91 |
|
92 |
@Override |
|
93 |
public TimePeriod getEntity() { |
|
94 |
if(super.getEntity() == null){ |
|
95 |
setEntity(VerbatimTimePeriod.NewVerbatimInstance()); |
|
96 |
} |
|
97 |
return super.getEntity(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* When setting the entity through parsing we do not want to alter the parse field |
|
102 |
* @param timePeriod |
|
103 |
*/ |
|
104 |
|
|
105 |
private void setEntityInternally(VerbatimTimePeriod timePeriod){ |
|
106 |
super.setEntityInternally(timePeriod); |
|
107 |
((Text) text_VerbatimDate.getMainControl()).setSelection(super.getCursorPosition()); |
|
108 |
text_VerbatimDate.setText(timePeriod.getVerbatimDate()); |
|
109 |
super.setEntity(timePeriod); |
|
110 |
} |
|
111 |
|
|
78 | 112 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java | ||
---|---|---|
31 | 31 |
import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement; |
32 | 32 |
import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler; |
33 | 33 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
34 |
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement; |
|
35 | 34 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
36 | 35 |
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement; |
36 |
import eu.etaxonomy.taxeditor.ui.element.VerbatimTimePeriodElement; |
|
37 | 37 |
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement; |
38 | 38 |
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement; |
39 | 39 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
... | ... | |
71 | 71 |
private UriWithLabelElement text_uri; |
72 | 72 |
private DateElement text_accessed; |
73 | 73 |
private EntitySelectionElement<AgentBase> selection_authorTeam; |
74 |
private TimePeriodElement element_timePeriod; |
|
74 |
private VerbatimTimePeriodElement element_timePeriod;
|
|
75 | 75 |
private EntitySelectionElement<Reference> selection_inReference; |
76 | 76 |
private EntitySelectionElement<Institution> selection_institution; |
77 | 77 |
private EnumComboElement<ReferenceType> combo_referenceType; |
... | ... | |
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
// date published |
177 |
element_timePeriod = formFactory.createTimePeriodElement(formElement, |
|
177 |
element_timePeriod = formFactory.createVerbatimTimePeriodElement(formElement,
|
|
178 | 178 |
"Date Published", entity.getDatePublished(), style); |
179 | 179 |
|
180 | 180 |
createUriAndAbstract(this, entity, SWT.NULL); |
Also available in: Unified diff
further implementation for verbatimdate