1 11 package org.eclipse.jface.viewers; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.widgets.Composite; 16 import org.eclipse.swt.widgets.Control; 17 18 31 public class CheckboxCellEditor extends CellEditor { 32 33 36 37 boolean value = false; 38 39 42 private static final int defaultStyle = SWT.NONE; 43 44 48 public CheckboxCellEditor() { 49 setStyle(defaultStyle); 50 } 51 52 59 public CheckboxCellEditor(Composite parent) { 60 this(parent, defaultStyle); 61 } 62 63 72 public CheckboxCellEditor(Composite parent, int style) { 73 super(parent, style); 74 } 75 76 82 public void activate() { 83 value = !value; 84 fireApplyEditorValue(); 85 } 86 87 92 protected Control createControl(Composite parent) { 93 return null; 94 } 95 96 103 protected Object doGetValue() { 104 return value ? Boolean.TRUE : Boolean.FALSE; 105 } 106 107 110 protected void doSetFocus() { 111 } 113 114 121 protected void doSetValue(Object value) { 122 Assert.isTrue(value instanceof Boolean ); 123 this.value = ((Boolean ) value).booleanValue(); 124 } 125 126 public void activate(ColumnViewerEditorActivationEvent activationEvent) { 127 if (activationEvent.eventType != ColumnViewerEditorActivationEvent.TRAVERSAL) { 128 super.activate(activationEvent); 129 } 130 } 131 } 132 | Popular Tags |