课程 9:为 CheckboxOptionControl 类创建代码
CheckboxOptionControl 类将 CARMA 缺省文本字段更改为 "选项" 参数上的复选框。 由于此参数是 yes 或 no 参数,因此复选框对用户更方便。
过程
结果
CheckBoxOptionControl 创建的代码看起来应当类似于:package com.ibm.carma.plugin.howto.action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
import com.ibm.carma.model.*;
import com.ibm.carma.ui.action.custom.AbstractCustomParameterControl;
public class CheckboxOptionAction extends AbstractCustomParameterControl {
//Add the button to the instance data
Button theButton;
/* Create a checkbox for the yes/no option */
public Control createControl(Composite parent,
RepositoryManager repositoryManager,
Parameter param,
Action action,
CustomActionAccepter customActionAccepter,
Object defaultValue) {
theButton = new Button(parent, SWT.CHECK);
theButton.setText("Check me!");
return theButton;
}
@Override
public Object getValue() {
if(theButton.getSelection())
return "Y";
else
return "N";
}
@Override
public boolean isUsingDefaultLabel() {
return true;
}
}