Community
Participate
Working Groups
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java?view=markup When using the booleanCellEditor in combination with a databinding the cell gets empty if i am changing the checkbox to the origin value (like from true to false to true). here is my code for fixing this problem: public class BooleanCellEditor extends CellEditor { private Button button; private ViewerRow row; private int index; private String restoredText; private Image restoredImage; private Boolean oldValue; /** * @param parent */ public BooleanCellEditor(Composite parent) { super(parent); } /** * @param parent * @param style */ public BooleanCellEditor(Composite parent, int style) { super(parent, style); } public LayoutData getLayoutData() { LayoutData data = super.getLayoutData(); data.horizontalAlignment = SWT.CENTER; data.grabHorizontal = false; return data; } protected Control createControl(Composite parent) { Font font = parent.getFont(); Color bg = parent.getBackground(); button = new Button(parent, getStyle() | SWT.CHECK); button.setFont(font); button.setBackground(bg); button.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent) */ public void keyReleased(KeyEvent e) { if (e.character == SWT.ESC) { fireCancelEditor(); } } }); return button; } protected Object doGetValue() { return new Boolean(button.getSelection()); } protected void doSetValue(Object value) { boolean selection = Boolean.TRUE.equals(value); button.setSelection(selection); } protected void doSetFocus() { if (button != null) { button.setFocus(); } } protected void deactivate(ColumnViewerEditorDeactivationEvent event) { super.deactivate(event); if (event.eventType == ColumnViewerEditorDeactivationEvent.EDITOR_CANCELED || oldValue == button.getSelection()) { row.setImage(index, restoredImage); row.setText(index, restoredText); } row = null; restoredImage = null; restoredText = null; } public void activate(ColumnViewerEditorActivationEvent activationEvent) { ViewerCell cell = (ViewerCell) activationEvent.getSource(); index = cell.getColumnIndex(); row = (ViewerRow) cell.getViewerRow().clone(); restoredImage = row.getImage(index); restoredText = row.getText(index); row.setImage(index, null); row.setText(index, ""); //$NON-NLS-1$ super.activate(activationEvent); oldValue = button.getSelection(); } /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.CellEditor#getDoubleClickTimeout() */ protected int getDoubleClickTimeout() { return 0; } }
That's me and this part of the Snippets who hold this class. I think Databinding does the right thing ;-)
multi change because of intenion of stepping back as platform-ui committer
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.