1 20 21 package org.apache.directory.ldapstudio.valueeditors.integer; 22 23 24 import org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor; 25 import org.eclipse.swt.widgets.Shell; 26 27 28 34 public class IntegerValueEditor extends AbstractDialogStringValueEditor 35 { 36 37 42 public boolean openDialog( Shell shell ) 43 { 44 Object value = getValue(); 45 if ( value != null && value instanceof String ) 46 { 47 String stringValue = ( String ) value; 48 int intValue; 49 try 50 { 51 intValue = Integer.valueOf( stringValue ); 52 } 53 catch ( NumberFormatException e ) 54 { 55 intValue = 0; 56 } 57 IntegerDialog dialog = new IntegerDialog( shell, intValue ); 58 if ( dialog.open() == IntegerDialog.OK && dialog.getInteger() != -1 ) 59 { 60 setValue( Integer.toString( dialog.getInteger() ) ); 61 return true; 62 } 63 } 64 return false; 65 } 66 67 } 68 | Popular Tags |