2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.mvc
.element
;
11 import org
.eclipse
.swt
.events
.ModifyEvent
;
12 import org
.eclipse
.swt
.events
.ModifyListener
;
13 import org
.eclipse
.swt
.widgets
.Text
;
14 import org
.joda
.time
.DateTime
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractRelevanceFormElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmPropertyChangeEvent
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.IEnableableFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.mvc
.interfaces
.CdmCompositeController
;
27 public class DateElementController
28 extends AbstractRelevanceFormElement
29 implements IEnableableFormElement
, CdmCompositeController
, ModifyListener
{
31 private final Text textDate
;
32 private DateTime dateTime
;
34 public DateElementController(DateElement dateTimeElement
, CdmFormFactory formFactory
,
35 ICdmFormElement parentElement
, DateTime initialDateTime
) {
36 super(formFactory
, parentElement
);
37 this.textDate
= dateTimeElement
.getTextDate();
38 // if (initialDateTime != null){
39 // this.textDate.setText(initialDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));
41 this.textDate
.setText(initialDateTime
!=null?initialDateTime
.toString("yyyy-MM-dd HH:mm"):"");
43 dateTime
= initialDateTime
;
44 textDate
.addModifyListener(this);
47 // public DateElementController(DateElementFormElement dateTimeElement, CdmFormFactory formFactory, DateTime initialDateTime) {
48 // super(formFactory, dateTimeElement);
49 // this.textDate = dateTimeElement.getTextDate();
50 // this.textDate.setText(initialDateTime!=null?initialDateTime.toString("yyyy-MM-dd"):"");
51 // addControl(textDate);
52 // textDate.addModifyListener(this);
57 public void modifyText(ModifyEvent e
) {
59 // String text = textDate.getText();
60 // DateTime parsedDateTime = DateTime.parse(text);
61 // this.dateTime = parsedDateTime;
62 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e
));
63 } catch (IllegalArgumentException iae
) {
64 System
.err
.println(iae
.getMessage());
68 public DateTime
getDateTime(){
71 public void setDateTime(DateTime date
){
76 public void setEnabled(boolean enabled
) {
77 textDate
.setEnabled(enabled
);
81 public boolean isEnabled() {
82 return textDate
.isEnabled();
86 public void updateCacheRelevance() {
87 System
.out
.println("updateCacheRelevance not yet implemented for " + this.getClass().getName());