Project

General

Profile

Revision 4883173c

ID4883173caa636fa9ad88b7e9506bcb319680c686
Parent c2d7c588
Child c089b4e4

Added by Katja Luther over 3 years ago

revert ZOnedDateTime to joda.DateTime

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElement.java
9 9
package eu.etaxonomy.taxeditor.ui.mvc.element;
10 10

  
11 11

  
12
import java.time.ZoneId;
13
import java.time.ZonedDateTime;
14
import java.time.format.DateTimeFormatter;
12

  
15 13

  
16 14
import org.apache.lucene.analysis.shingle.ShingleMatrixFilter.OneDimensionalNonWeightedTokenSettingsCodec;
17 15
import org.eclipse.swt.SWT;
......
31 29
import org.eclipse.swt.widgets.Text;
32 30
import org.eclipse.ui.forms.widgets.FormToolkit;
33 31
import org.eclipse.ui.forms.widgets.TableWrapLayout;
34
//import org.joda.time.DateTime;
32
import org.joda.time.DateTimeZone;
33
import org.joda.time.format.DateTimeFormatter;
35 34

  
36 35
import eu.etaxonomy.taxeditor.model.ImageResources;
37 36
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
46 45
public class DateElement extends AbstractCdmComposite<DateElementController>  {
47 46

  
48 47
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
49
    private ZonedDateTime initialDateTime;
48
    private org.joda.time.DateTime initialDateTime;
50 49
    private Text textDate;
51 50
    private final Button openDateDialog;
52 51
    
......
58 57
     * @param parent
59 58
     * @param style
60 59
     */
61
    public DateElement(Composite parent, ZonedDateTime initDateTime, String label, int style, boolean editableText) {
60
    public DateElement(Composite parent, org.joda.time.DateTime initDateTime, String label, int style, boolean editableText) {
62 61
        super(parent, style);
63 62
        this.initialDateTime = initDateTime;
64 63
        
......
116 115
    			
117 116
    			final DateTime time = new DateTime (dialog, SWT.TIME | SWT.SHORT);
118 117
    			if (initialDateTime != null){
119
    				calendar.setDate(initialDateTime.getYear(), initialDateTime.getMonthValue()-1, initialDateTime.getDayOfMonth());
120
    				time.setHours(initialDateTime.getHour());
121
        			time.setMinutes(initialDateTime.getMinute());
118
    				calendar.setDate(initialDateTime.getYear(), initialDateTime.getMonthOfYear()-1, initialDateTime.getDayOfMonth());
119
    				time.setHours(initialDateTime.getHourOfDay());
120
        			time.setMinutes(initialDateTime.getMinuteOfHour());
122 121
//        			time.setSeconds(initialDateTime.getSecondOfMinute());
123 122
    			}
124 123
    			
......
156 155
   
157 156
    
158 157
	
159
    public static ZonedDateTime makeZonedTimeFromSWT(
158
    public static org.joda.time.DateTime makeZonedTimeFromSWT(
160 159
	                                org.eclipse.swt.widgets.DateTime widget, 
161 160
	                                org.eclipse.swt.widgets.DateTime dateTime) {
162 161
		  //the first month of the year is 0			  
163
		  return ZonedDateTime.of(widget.getYear(),
162
		  return new org.joda.time.DateTime(widget.getYear(),
164 163
				  widget.getMonth()+1,
165 164
				  widget.getDay(),
166 165
				  dateTime.getHours(),
167 166
				  dateTime.getMinutes(),
168 167
                  0,
169 168
                  0,
170
                  ZoneId.of("UTC"));
169
                  DateTimeZone.UTC);
171 170
	}
172 171

  
173 172
	public static void updateSWTwithJoda(
174 173
	                                org.eclipse.swt.widgets.DateTime widget,
175
	                                ZonedDateTime dateTime) {
174
	                                DateTime dateTime) {
176 175
		  widget.setYear(dateTime.getYear());
177
		  widget.setMonth(dateTime.getMonthValue() -1);
178
		  widget.setDay(dateTime.getDayOfMonth());
179
		  widget.setHours(dateTime.getHour());
180
		  widget.setMinutes(dateTime.getMinute());
181
		  widget.setSeconds(dateTime.getSecond());
176
		  widget.setMonth(dateTime.getMonth() -1);
177
		  widget.setDay(dateTime.getDay());
178
		  widget.setHours(dateTime.getHours());
179
		  widget.setMinutes(dateTime.getMinutes());
180
		  
182 181
	}
183 182
		
184
	public void setData (ZonedDateTime data) {
183
	public void setData (org.joda.time.DateTime data) {
185 184
			this.initialDateTime = data;
186 185
			this.controller.setDateTime(data);
187
			this.textDate.setText(initialDateTime.format(DateTimeFormatter.ofPattern(pattern)));
186
			this.textDate.setText(initialDateTime.toString(pattern));
188 187
	}
189 188

  
190 189
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElementController.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.ui.mvc.element;
10 10

  
11

  
11 12
import java.time.ZonedDateTime;
12 13
import java.time.format.DateTimeFormatter;
13 14

  
......
15 16
import org.eclipse.swt.events.ModifyListener;
16 17
import org.eclipse.swt.widgets.Text;
17 18
import org.joda.time.DateTime;
19
import org.joda.time.LocalDateTime;
18 20

  
19 21
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
20 22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
31 33
public class DateElementController extends AbstractCdmFormElement implements IEnableableFormElement, CdmCompositeController, ModifyListener{
32 34

  
33 35
    private final Text textDate;
34
    private ZonedDateTime dateTime;
36
    private DateTime dateTime;
35 37

  
36 38
    /**
37 39
     * @param dateTimeElement
......
41 43
     * @param none
42 44
     */
43 45
    public DateElementController(DateElement dateTimeElement, CdmFormFactory formFactory, 
44
    		ICdmFormElement parentElement, ZonedDateTime initialDateTime) {
46
    		ICdmFormElement parentElement, DateTime initialDateTime) {
45 47
        super(formFactory, parentElement);
46 48
        this.textDate = dateTimeElement.getTextDate();
47 49
//        if (initialDateTime != null){
48 50
//        	this.textDate.setText(initialDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));
49 51
//        }
50
         this.textDate.setText(initialDateTime!=null?initialDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")):"");
52
         this.textDate.setText(initialDateTime!=null?initialDateTime.toString("yyyy-MM-dd HH:mm"):"");
51 53
        addControl(textDate);
52 54
        dateTime = initialDateTime;
53 55
        textDate.addModifyListener(this);
......
74 76
        }
75 77
    }
76 78

  
77
    public ZonedDateTime getDateTime(){
79
    public DateTime getDateTime(){
78 80
        return dateTime;
79 81
    } 
80
    public void setDateTime(ZonedDateTime date){
82
    public void setDateTime(DateTime date){
81 83
       dateTime = date;
82 84
    } 
83 85

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java
78 78
        text_title = formFactory.createLanguageStringWithLabelElement(element, "Title", null, style);
79 79
        selection_artist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Artist", null, EntitySelectionElement.ALL, style);
80 80
        addElement(selection_artist);
81
        ZonedDateTime mediaCreatedValue = null;
81
        DateTime mediaCreatedValue = null;
82 82
        if (getEntity().getMediaCreated() != null){
83
        	mediaCreatedValue =  DateConverter.convertJoda2ZonedDateTime(getEntity().getMediaCreated());
83
        	mediaCreatedValue =  getEntity().getMediaCreated();
84 84
        }
85 85
        mediaCreated = formFactory.createDateElement(element, "Media Created", mediaCreatedValue, style, false);
86 86
        addElement(mediaCreated.getController());
......
147 147
                ((AbstractCdmDetailSection<?>) getParentElement()).updateTitle();
148 148
            }
149 149
        } else if (eventSource == mediaCreated.getController()){
150
        	DateTime date = DateConverter.convertZonedDateTime2Joda(mediaCreated.getController().getDateTime());
150
        	DateTime date = mediaCreated.getController().getDateTime();
151 151
        	getEntity().setMediaCreated(date);
152 152
        }
153 153
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractSpecimenOrObservationDetailElement.java
3 3
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
4 4
import eu.etaxonomy.cdm.model.common.DefinedTerm;
5 5
import eu.etaxonomy.cdm.model.common.TermType;
6
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
7
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
8
import eu.etaxonomy.taxeditor.store.CdmStore;
6

  
9 7
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
10 8
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
11 9
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/dna/DnaQualityDetailElement.java
11 11
import java.time.ZonedDateTime;
12 12

  
13 13
import org.joda.time.DateTime;
14
import org.joda.time.LocalDateTime;
14 15

  
15 16
import eu.etaxonomy.cdm.model.common.OrderedTerm;
16 17
import eu.etaxonomy.cdm.model.common.TermType;
......
71 72
        numberRatioOfAbsorbance260_230 = formFactory.createNumberTextWithLabelElement(formElement, "Ratio of absorbance 260-230", ratioOfAbsorbance260_230, style);
72 73
        numberConcentration = formFactory.createNumberTextWithLabelElement(formElement, "Concentration", concentration, style);
73 74
        comboQualityTerm = formFactory.createDefinedTermComboElement(TermType.DnaQualityType, formElement, "Quality Term", qualityTerm, style);
74
        ZonedDateTime qualityCheckedDate = null;
75
        if (dnaQuality.getQualityCheckDate() != null){
76
        	qualityCheckedDate = DateConverter.convertJoda2ZonedDateTime(dnaQuality.getQualityCheckDate());
77
        }
75
        DateTime qualityCheckedDate = dnaQuality.getQualityCheckDate();
76
        
78 77
        dateQualityCheck = formFactory.createDateElement(formElement, "Quality Check", qualityCheckedDate, style, false);
79 78
    }
80 79

  
......
104 103
            dnaQuality.setQualityTerm(comboQualityTerm.getSelection());
105 104
        }
106 105
        else if(eventSource==dateQualityCheck.getController()){
107
            DateTime dateTime = DateConverter.convertZonedDateTime2Joda(dateQualityCheck.getController().getDateTime());
106
            DateTime dateTime = dateQualityCheck.getController().getDateTime();
108 107
            
109 108
            dnaQuality.setQualityCheckDate(dateTime);
110 109
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/media/MediaSpecimenGeneralDetailElement.java
76 76
            comboKindOfUnit = formFactory.createDefinedTermComboElement(mediaSpecimenVocabulary, formElement, "Kind of Media", entity.getKindOfUnit(), style);
77 77
            textTitleLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Motif", media.getTitle(), style);
78 78
            selectionArtist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Prepared by", media.getArtist(), EntitySelectionElement.ALL, style);
79
            ZonedDateTime mediaCreated = null;
80
            if (entity.getMediaSpecimen().getMediaCreated() != null){
81
            	mediaCreated = DateConverter.convertJoda2ZonedDateTime(entity.getMediaSpecimen().getMediaCreated());
82
            }
79
            DateTime mediaCreated = entity.getMediaSpecimen().getMediaCreated();
80
            
83 81
            date = formFactory.createDateElement(formElement, "Preparation Date", mediaCreated, style, true);
84 82
            textMethodLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Method", media.getDescription(Language.getDefaultLanguage()), style);
85 83
            selection_collection = formFactory.createSelectionElement(Collection.class, getConversationHolder(), formElement, "Collection", entity.getCollection(), EntitySelectionElement.ALL, style);
......
115 113
            media.putTitle(textTitleLanguageString.getLanguageString());
116 114
        }
117 115
        else if(eventSource==date.getController()){
118
            DateTime dateTime = DateConverter.convertZonedDateTime2Joda(date.getController().getDateTime());
116
            DateTime dateTime = date.getController().getDateTime();
119 117
            media.setMediaCreated(dateTime);
120 118
        }
121 119
        else if(eventSource==selectionArtist){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)