ref #7086, #7095 Implement working set navigator
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / CheckboxElement.java
index fdb7b36d4b92e5896829a6c311fa2b3f6467eb81..adec1e278d14725be20bb50e1be465394d1268bc 100644 (file)
@@ -1,9 +1,8 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -18,7 +17,6 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Label;
 
 import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
 
 /**
  * <p>CheckboxElement class.</p>
@@ -28,11 +26,11 @@ import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
  * @version 1.0
  */
 public class CheckboxElement extends AbstractCdmFormElement implements SelectionListener, IEnableableFormElement, ISelectable {
-       
-       private Button checkbox;
+
+       private final Button checkbox;
 
        private Label label;
-       
+
        /**
         * <p>Constructor for CheckboxElement.</p>
         *
@@ -45,17 +43,17 @@ public class CheckboxElement extends AbstractCdmFormElement implements Selection
        protected CheckboxElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString, boolean initialState,
                        int style) {
                super(formFactory, parentElement);
-               
+
                if(labelString != null){
                        label = formFactory.createLabel(getLayoutComposite(), labelString);
                        addControl(label);
                }
-               
+
                checkbox = formFactory.createButton(getLayoutComposite(), null, SWT.CHECK | style);
                checkbox.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
-               
+
                checkbox.setSelection(initialState);
-               
+
                checkbox.addSelectionListener(this);
                addControl(checkbox);
        }
@@ -70,7 +68,7 @@ public class CheckboxElement extends AbstractCdmFormElement implements Selection
                checkbox.setSelection(selected);
                checkbox.addSelectionListener(this);
        }
-       
+
        /**
         * <p>getSelection</p>
         *
@@ -84,31 +82,45 @@ public class CheckboxElement extends AbstractCdmFormElement implements Selection
         * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        /** {@inheritDoc} */
-       public void widgetSelected(SelectionEvent e) {
+       @Override
+    public void widgetSelected(SelectionEvent e) {
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
        }
-       
+
        /** {@inheritDoc} */
-       public void widgetDefaultSelected(SelectionEvent e) {}
+       @Override
+    public void widgetDefaultSelected(SelectionEvent e) {}
 
        /** {@inheritDoc} */
-       public void setSelected(boolean selected) {
+       @Override
+    public void setSelected(boolean selected) {
                setBackground(selected ? SELECTED : getPersistentBackground());
        }
 
        /** {@inheritDoc} */
-       public void setEnabled(boolean enabled) {
+       @Override
+    public void setEnabled(boolean enabled) {
                checkbox.setEnabled(enabled);
+               label.setEnabled(enabled);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled()
+        */
+       @Override
+       public boolean isEnabled() {
+           return checkbox.isEnabled();
        }
 
        /** {@inheritDoc} */
-       public void setIrrelevant(boolean irrelevant) {
+       @Override
+    public void setIrrelevant(boolean irrelevant) {
                String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND;
-               
+
                Color color = getColor(colorId);
                setBackground(color);
        }
-       
+
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setBackground(org.eclipse.swt.graphics.Color)
         */
@@ -116,6 +128,8 @@ public class CheckboxElement extends AbstractCdmFormElement implements Selection
        @Override
        public void setBackground(Color color) {
                checkbox.setBackground(color);
-               if (label != null) label.setBackground(color);
+               if (label != null) {
+            label.setBackground(color);
+        }
        }
 }