3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.forms
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.events
.SelectionListener
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.widgets
.Button
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
24 * @created Nov 5, 2009
27 public class CheckboxComposite
extends AbstractFormComposite
implements SelectionListener
{
29 private static final Logger logger
= Logger
30 .getLogger(CheckboxComposite
.class);
32 private Button checkbox
;
42 public CheckboxComposite(Composite parent
, String label
, boolean initialState
,
43 IPropertyChangeListener listener
, int style
) {
44 super(parent
, listener
, style
);
46 checkbox
= toolkit
.createButton(this, label
, SWT
.CHECK
| style
);
47 checkbox
.setLayoutData(new GridData(SWT
.LEFT
, SWT
.TOP
, false, false));
49 checkbox
.setSelection(initialState
);
51 checkbox
.addSelectionListener(this);
54 public void setSelection(boolean selected
){
55 checkbox
.removeSelectionListener(this);
56 checkbox
.setSelection(selected
);
57 checkbox
.addSelectionListener(this);
60 public boolean getSelection(){
61 return checkbox
.getSelection();
65 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
67 public void widgetSelected(SelectionEvent e
) {
68 firePropertyChangeEvent(null);
71 public void widgetDefaultSelected(SelectionEvent e
) {}