3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.campanula
.basicFields
;
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
;
27 public class EntitySelectionField
extends Composite
{
28 private FormToolkit formToolkit
= new FormToolkit(Display
.getDefault());
30 private Button button_selection
;
31 private Button button_edit
;
32 private Button button_remove
;
35 * Create the composite.
39 public EntitySelectionField(Composite parent
, int style
) {
41 setBackgroundMode(SWT
.INHERIT_DEFAULT
);
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
);
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
);
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"));
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"));
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"));
73 protected void checkSubclass() {
74 // Disable the check that prevents subclassing of SWT components
76 public Label
getText() {
79 public Button
getButton_selection() {
80 return button_selection
;
82 public Button
getButton_edit() {
85 public Button
getButton_remove() {
90 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
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
);