1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 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.campanula.basicFields;
|
11
|
|
12
|
import org.eclipse.swt.SWT;
|
13
|
import org.eclipse.swt.widgets.Button;
|
14
|
import org.eclipse.swt.widgets.Composite;
|
15
|
import org.eclipse.swt.widgets.Display;
|
16
|
import org.eclipse.swt.widgets.Label;
|
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
|
import org.eclipse.wb.swt.ResourceManager;
|
21
|
|
22
|
/**
|
23
|
* @author pplitzner
|
24
|
* @date 13.08.2013
|
25
|
*
|
26
|
*/
|
27
|
public class EntitySelectionField extends Composite {
|
28
|
private FormToolkit formToolkit = new FormToolkit(Display.getDefault());
|
29
|
private Label text;
|
30
|
private Button button_selection;
|
31
|
private Button button_edit;
|
32
|
private Button button_remove;
|
33
|
|
34
|
/**
|
35
|
* Create the composite.
|
36
|
* @param parent
|
37
|
* @param style
|
38
|
*/
|
39
|
public EntitySelectionField(Composite parent, int style) {
|
40
|
super(parent, style);
|
41
|
setBackgroundMode(SWT.INHERIT_DEFAULT);
|
42
|
{
|
43
|
TableWrapLayout tableWrapLayout = new TableWrapLayout();
|
44
|
tableWrapLayout.verticalSpacing = 0;
|
45
|
tableWrapLayout.topMargin = 0;
|
46
|
tableWrapLayout.rightMargin = 0;
|
47
|
tableWrapLayout.numColumns = 4;
|
48
|
tableWrapLayout.leftMargin = 0;
|
49
|
tableWrapLayout.horizontalSpacing = 0;
|
50
|
tableWrapLayout.bottomMargin = 0;
|
51
|
setLayout(tableWrapLayout);
|
52
|
}
|
53
|
|
54
|
text = formToolkit.createLabel(this, "", SWT.WRAP);
|
55
|
TableWrapData twd_text = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1);
|
56
|
twd_text.align = TableWrapData.LEFT;
|
57
|
text.setLayoutData(twd_text);
|
58
|
|
59
|
button_selection = formToolkit.createButton(this, "", SWT.NONE);
|
60
|
button_selection.setToolTipText("Browse existing");
|
61
|
button_selection.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif"));
|
62
|
|
63
|
button_edit = formToolkit.createButton(this, "", SWT.NONE);
|
64
|
button_edit.setToolTipText("Edit");
|
65
|
button_edit.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/text.gif"));
|
66
|
|
67
|
button_remove = formToolkit.createButton(this, "", SWT.NONE);
|
68
|
button_remove.setToolTipText("Remove");
|
69
|
button_remove.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
|
70
|
}
|
71
|
|
72
|
@Override
|
73
|
protected void checkSubclass() {
|
74
|
// Disable the check that prevents subclassing of SWT components
|
75
|
}
|
76
|
public Label getText() {
|
77
|
return text;
|
78
|
}
|
79
|
public Button getButton_selection() {
|
80
|
return button_selection;
|
81
|
}
|
82
|
public Button getButton_edit() {
|
83
|
return button_edit;
|
84
|
}
|
85
|
public Button getButton_remove() {
|
86
|
return button_remove;
|
87
|
}
|
88
|
|
89
|
/* (non-Javadoc)
|
90
|
* @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
|
91
|
*/
|
92
|
@Override
|
93
|
public void setEnabled(boolean enabled) {
|
94
|
super.setEnabled(enabled);
|
95
|
text.setEnabled(enabled);
|
96
|
button_selection.setEnabled(enabled);
|
97
|
button_edit.setEnabled(enabled);
|
98
|
button_remove.setEnabled(enabled);
|
99
|
}
|
100
|
}
|