我有一个代码,它向 SWT shell 添加了四个复选框按钮,我在复选框按钮中添加了选择侦听器,我想在单击 SWT Shell 的 OK、CANCEL 和 CLOSE 按钮时将其删除,我该如何处理这样的事件,这个是我的代码
grpVersionTreeComponents.setLayoutData(componentsRenderer.createGridData(490, 220, 4));
for(int versionCount = 0; versionCount < versionSplitters.length ; versionCount++ ){
String splitter= versionSplitters[versionCount];
Button cbVersionSplitter = new CheckBoxWrapper().getButton(grpVersionTreeComponents,splitter.toString() , "");
cbVersionSplitter.setEnabled(true);
versionSplitterCheckBoxList.add(cbVersionSplitter);
versionSplitterCheckBoxList.get(versionCount).addSelectionListener(addSplitterCheckBoxListner(cbVersionSplitter));
}
这是我的选择适配器方法
public SelectionAdapter addSplitterCheckBoxListner(final Button button){
return new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String[] defaultVersionSplitters = PropertyClass.getPropertyLabel(QTLConstants.VERSIONING_ASSISTENT_PAGE_SPLLITER).split(QTLConstants.MULTIPLE_EXTENSIONS_SPLITER);
//check if button.getText() is equal to "Custom Splitter" String
if(button.getText().equalsIgnoreCase(defaultVersionSplitters[3])){
if(button.getSelection()){
customVersionSplitterText.setEnabled(true);
}else{
customVersionSplitterText.setEnabled(false);
}
}
}
};
}
和 OK 取消按钮以这种方式添加
private void addOkCancelButtonOnVersionTreePopup(final Shell versionTreeComponentsShell){
Button ok = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.OK_BUTTON));
Button cancel = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.CANCEL_BUTTON));
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
}
cancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*disposeSelectionListener(cbVersionSplitter);*/
versionTreeComponentsShell.close();
}
});
}
}
那么我怎样才能删除这个选择监听器
问候