1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.mvc.element;
|
10
|
|
11
|
import org.eclipse.swt.SWT;
|
12
|
import org.eclipse.swt.events.DisposeEvent;
|
13
|
import org.eclipse.swt.events.DisposeListener;
|
14
|
import org.eclipse.swt.widgets.Composite;
|
15
|
import org.eclipse.swt.widgets.Display;
|
16
|
import org.eclipse.swt.widgets.Text;
|
17
|
import org.eclipse.ui.forms.widgets.FormToolkit;
|
18
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
19
|
import org.eclipse.ui.forms.widgets.TableWrapLayout;
|
20
|
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite;
|
24
|
|
25
|
/**
|
26
|
* @author pplitzner
|
27
|
* @date 11.02.2014
|
28
|
*
|
29
|
*/
|
30
|
public class TextWithLabelElementMVC extends AbstractCdmComposite<TextWithLabelElementController> {
|
31
|
|
32
|
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
|
33
|
private final Text text;
|
34
|
private final String initialText;
|
35
|
private final Integer textHeight;
|
36
|
|
37
|
/**
|
38
|
* Create the composite.
|
39
|
* @param parent
|
40
|
* @param style
|
41
|
*/
|
42
|
public TextWithLabelElementMVC(Composite parent, String initialText, Integer textHeight, int style) {
|
43
|
super(parent, SWT.BORDER);
|
44
|
this.initialText = initialText;
|
45
|
this.textHeight = textHeight;
|
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.horizontalSpacing = 0;
|
59
|
tableWrapLayout.bottomMargin = 0;
|
60
|
tableWrapLayout.rightMargin = 0;
|
61
|
tableWrapLayout.leftMargin = 0;
|
62
|
setLayout(tableWrapLayout);
|
63
|
}
|
64
|
|
65
|
text = new Text(this, SWT.WRAP);
|
66
|
text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
67
|
toolkit.adapt(text, true, true);
|
68
|
|
69
|
}
|
70
|
|
71
|
public Text getText() {
|
72
|
return text;
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
protected void initInternalController(CdmFormFactory formFactory, ICdmFormElement parentElement){
|
77
|
controller = new TextWithLabelElementController(this, formFactory, parentElement, this.initialText, this.textHeight, SWT.NONE);
|
78
|
}
|
79
|
}
|