1 8 package com.nightlabs.editor2d.properties; 9 10 import org.eclipse.jface.util.Assert; 11 import org.eclipse.jface.viewers.CellEditor; 12 import org.eclipse.swt.widgets.Composite; 13 import org.eclipse.swt.widgets.Control; 14 import org.eclipse.swt.widgets.Text; 15 16 17 public class IntCellEditor 18 extends CellEditor 19 { 20 protected Text text; 21 22 25 public IntCellEditor(Composite parent) { 26 super(parent); 27 } 28 29 33 public IntCellEditor(Composite parent, int style) { 34 super(parent, style); 35 } 36 37 40 protected Control createControl(Composite parent) { 41 text = new Text(parent, getStyle()); 42 return text; 43 } 44 45 48 protected Object doGetValue() 49 { 50 String stringVal = text.getText(); 51 Integer i = new Integer (stringVal); 52 return i; 53 } 54 55 58 protected void doSetFocus() 59 { 60 if (text != null) { 61 text.selectAll(); 62 text.setFocus(); 63 } 64 } 65 66 69 protected void doSetValue(Object value) 70 { 71 Assert.isTrue(text != null && (value instanceof Integer )); 72 Integer val = (Integer ) value; 73 String stringVal = Integer.toString(val.intValue()); 74 text.setText(stringVal); 75 } 76 77 } 78 | Popular Tags |