@ -649,12 +649,49 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
* /
@Override
public void registerDSChangeListener ( ) {
this . addAncestorListener ( new ManageDsListenerRegisterListener ( new ChangeListener ( ) {
@Override
public void stateChanged ( ChangeEvent e ) {
initDsNameComboBox ( ) ;
}
} ) ) ;
// 还是需要保留 恶心
// 1. 切换工作目录需要依赖这个监听 切换工作目录没有一个数据连接的刷新触发 就很坑
// 2. DesignerContext.getDesignerBean("databasename").refreshBeanElement()有坑 a.调用不全 b.某些场景下 因为注册覆盖 会失效
// 监听内容变成刷新模式 不会覆盖 populate填充内容
this . addAncestorListener ( new ManageDsListenerRegisterListener ( new ChangeListener ( ) {
@Override
public void stateChanged ( ChangeEvent e ) {
refreshDsNameComboBox ( ) ;
}
} ) ) ;
}
@SuppressWarnings ( "unchecked" )
private void refreshDsNameComboBox ( ) {
if ( initWorker ! = null & & ! initWorker . isDone ( ) ) {
initWorker . cancel ( true ) ;
}
dsNameComboBox . setRefreshingModel ( true ) ;
initWorker = new SwingWorker < List < String > , Void > ( ) {
@Override
protected List < String > doInBackground ( ) throws Exception {
return getHasAuthConnections ( ) ;
}
@Override
protected void done ( ) {
try {
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel ( get ( ) ) ;
String selected = dsNameComboBox . getSelectedItem ( ) ;
dsNameComboBox . setModel ( dsNameComboBoxModel ) ;
dsNameComboBox . setRefreshingModel ( true ) ;
dsNameComboBox . setSelectedItem ( selected ) ;
dsNameComboBox . setRefreshingModel ( false ) ;
} catch ( Exception e ) {
if ( ! ( e instanceof CancellationException ) ) {
FineLoggerFactory . getLogger ( ) . error ( e . getMessage ( ) , e ) ;
}
}
}
} ;
initWorker . execute ( ) ;
}
/ * *