1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2014 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.mvc.element;
|
11
|
|
12
|
import org.eclipse.swt.SWT;
|
13
|
import org.eclipse.swt.events.DisposeEvent;
|
14
|
import org.eclipse.swt.events.DisposeListener;
|
15
|
import org.eclipse.swt.widgets.Composite;
|
16
|
import org.eclipse.swt.widgets.DateTime;
|
17
|
import org.eclipse.swt.widgets.Display;
|
18
|
import org.eclipse.ui.forms.widgets.FormToolkit;
|
19
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
20
|
import org.eclipse.ui.forms.widgets.TableWrapLayout;
|
21
|
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @date 16.06.2014
|
29
|
*
|
30
|
*/
|
31
|
public class DateTimeElement extends AbstractCdmComposite {
|
32
|
|
33
|
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
|
34
|
private final DateTime dateTime;
|
35
|
private final org.joda.time.DateTime initialDateTime;
|
36
|
|
37
|
/**
|
38
|
* Create the composite.
|
39
|
* @param parent
|
40
|
* @param style
|
41
|
*/
|
42
|
public DateTimeElement(Composite parent, org.joda.time.DateTime initialDateTime, int style) {
|
43
|
super(parent, style);
|
44
|
this.initialDateTime = initialDateTime;
|
45
|
addDisposeListener(new DisposeListener() {
|
46
|
@Override
|
47
|
public void widgetDisposed(DisposeEvent e) {
|
48
|
toolkit.dispose();
|
49
|
}
|
50
|
});
|
51
|
toolkit.adapt(this);
|
52
|
toolkit.paintBordersFor(this);
|
53
|
{
|
54
|
TableWrapLayout tableWrapLayout = new TableWrapLayout();
|
55
|
tableWrapLayout.verticalSpacing = 0;
|
56
|
tableWrapLayout.topMargin = 0;
|
57
|
tableWrapLayout.rightMargin = 0;
|
58
|
tableWrapLayout.leftMargin = 0;
|
59
|
tableWrapLayout.horizontalSpacing = 0;
|
60
|
tableWrapLayout.bottomMargin = 0;
|
61
|
tableWrapLayout.numColumns = 1;
|
62
|
setLayout(tableWrapLayout);
|
63
|
}
|
64
|
|
65
|
dateTime = new DateTime(this, SWT.BORDER | SWT.DROP_DOWN);
|
66
|
dateTime.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
67
|
toolkit.adapt(dateTime);
|
68
|
toolkit.paintBordersFor(dateTime);
|
69
|
}
|
70
|
|
71
|
public DateTime getDateTime() {
|
72
|
return dateTime;
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite#initInternalController(eu.etaxonomy.taxeditor.ui.element.CdmFormFactory, eu.etaxonomy.taxeditor.ui.element.ICdmFormElement)
|
77
|
*/
|
78
|
@Override
|
79
|
protected void initInternalController(CdmFormFactory formFactory, ICdmFormElement parentElement) {
|
80
|
controller = new DateTimeController(this, formFactory, parentElement, initialDateTime, SWT.NONE);
|
81
|
formFactory.adapt(controller);
|
82
|
}
|
83
|
}
|