KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > properties > CheckboxCellEditor


1 /**
2  * <p> Project: com.nightlabs.base </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 24.01.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.properties;
9
10 import org.eclipse.jface.viewers.CellEditor;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.widgets.Button;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
15
16
17 public class CheckboxCellEditor
18 extends CellEditor
19 {
20   protected Button checkbox;
21     
22   /**
23    *
24    */

25   public CheckboxCellEditor() {
26     super();
27   }
28
29   /**
30    * @param parent
31    */

32   public CheckboxCellEditor(Composite parent) {
33     super(parent);
34   }
35
36   /**
37    * @param parent
38    * @param style
39    */

40   public CheckboxCellEditor(Composite parent, int style) {
41     super(parent, style);
42   }
43   
44     /**
45      * The <code>CheckboxCellEditor</code> implementation of
46      * this <code>CellEditor</code> framework method does
47      * nothing and returns <code>null</code>.
48      */

49     protected Control createControl(Composite parent)
50     {
51        checkbox = new Button(parent, SWT.CHECK);
52        return checkbox;
53     }
54     
55     /**
56      * The <code>CheckboxCellEditor</code> implementation of
57      * this <code>CellEditor</code> framework method returns
58      * the checkbox setting wrapped as a <code>Boolean</code>.
59      *
60      * @return the Boolean checkbox value
61      */

62     protected Object JavaDoc doGetValue() {
63         return new Boolean JavaDoc(checkbox.getSelection());
64     }
65     
66     /* (non-Javadoc)
67      * Method declared on CellEditor.
68      */

69     protected void doSetFocus()
70     {
71       checkbox.setFocus();
72     }
73     
74     /**
75      * The <code>CheckboxCellEditor</code> implementation of
76      * this <code>CellEditor</code> framework method accepts
77      * a value wrapped as a <code>Boolean</code>.
78      *
79      * @param value a Boolean value
80      */

81     protected void doSetValue(Object JavaDoc value)
82     {
83       if (value instanceof Boolean JavaDoc)
84         checkbox.setSelection(((Boolean JavaDoc) value).booleanValue());
85     }
86     
87 }
88
Popular Tags