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