📄 integercelleditor.java
字号:
package com.cownew.eclipse.properties;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.widgets.Composite;
public class IntegerCellEditor extends TextCellEditor
{
public IntegerCellEditor(Composite composite)
{
super(composite);
setValidator(new ICellEditorValidator() {
public String isValid(Object object)
{
if (object instanceof Integer)
return null;
String string = (String) object;
try
{
Integer.parseInt(string);
} catch (NumberFormatException exception)
{
return exception.getMessage();
}
return null;
}
});
}
protected Object doGetValue()
{
Object obj = super.doGetValue();
if(obj==null||obj.toString().trim().length()<=0)
{
return Integer.valueOf(0);
}
return Integer.valueOf(obj.toString());
}
protected void doSetValue(Object value)
{
if(value==null)
{
super.doSetValue(null);
}
super.doSetValue(value.toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -