1
我有一個代碼添加了四個複選框按鈕到SWT外殼,我添加了選擇監聽器到checkBox按鈕,我想要刪除點擊確定,取消和關閉按鈕SWT殼牌,我該怎麼處理這樣的事件,這是我的代碼處理SelectionListener在SWT上點擊另一個按鈕
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));
}
這是我的選擇Adapter方法
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);
}
}
}
};
}
和確定取消按鈕以這種方式加入
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();
}
});
}
}
所以我怎樣才能消除這種選擇監聽器
問候