4 package eu
.etaxonomy
.taxeditor
.forms
.selectioncomposites
;
6 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
7 import org
.eclipse
.swt
.SWT
;
8 import org
.eclipse
.swt
.events
.SelectionEvent
;
9 import org
.eclipse
.swt
.events
.SelectionListener
;
10 import org
.eclipse
.swt
.layout
.GridData
;
11 import org
.eclipse
.swt
.layout
.GridLayout
;
12 import org
.eclipse
.swt
.widgets
.Button
;
13 import org
.eclipse
.swt
.widgets
.Composite
;
14 import org
.eclipse
.swt
.widgets
.Label
;
15 import org
.eclipse
.swt
.widgets
.Text
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
18 import eu
.etaxonomy
.taxeditor
.forms
.AbstractFormComposite
;
23 * @created Nov 17, 2009
27 public abstract class AbstractSelectionComposite
<T
extends IdentifiableEntity
> extends AbstractFormComposite
implements SelectionListener
{
29 protected T selection
;
31 protected Label label
;
33 protected Button button
;
39 public AbstractSelectionComposite(Composite parent
, String labelString
, T selection
, IPropertyChangeListener listener
, int style
) {
40 super(parent
, listener
, style
);
42 this.selection
= selection
;
44 this.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
45 GridLayout layout
= (GridLayout
) this.getLayout();
46 layout
.numColumns
= 2;
48 if(labelString
!= null){
49 label
= toolkit
.createLabel(this, labelString
, SWT
.WRAP
);
50 GridData labelData
= new GridData();
51 labelData
.horizontalSpan
= 2;
52 label
.setLayoutData(labelData
);
55 text
= toolkit
.createText(this, "", SWT
.BORDER
| SWT
.WRAP
);
56 text
.setEditable(false);
57 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
59 button
= toolkit
.createButton(this, "Browse", SWT
.PUSH
);
60 button
.addSelectionListener(this);
66 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
68 public void widgetDefaultSelected(SelectionEvent e
) {
73 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
75 public void widgetSelected(SelectionEvent e
) {
76 firePropertyChangeEvent(null);
80 * Return the selected object
84 public T
getSelection(){
92 public void setSelection(T selection
){
93 this.selection
= selection
;
97 protected void updateText(){
99 text
.setText(selection
.getTitleCache());