@ -25,6 +25,7 @@ import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.design.gui.icombobox.UIComboBoxRenderer ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayoutHelper ;
@ -39,7 +40,16 @@ import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext ;
import com.fr.workspace.server.connection.DBConnectAuth ;
import javax.swing.* ;
import java.awt.BorderLayout ;
import java.awt.Component ;
import java.awt.Dimension ;
import java.util.Collections ;
import java.util.concurrent.CancellationException ;
import javax.swing.JList ;
import javax.swing.JOptionPane ;
import javax.swing.JPanel ;
import javax.swing.JTree ;
import javax.swing.SwingWorker ;
import javax.swing.event.ChangeEvent ;
import javax.swing.event.ChangeListener ;
import javax.swing.event.PopupMenuEvent ;
@ -50,7 +60,6 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer ;
import javax.swing.tree.TreeNode ;
import javax.swing.tree.TreePath ;
import java.awt.* ;
import java.awt.event.FocusAdapter ;
import java.awt.event.FocusEvent ;
import java.awt.event.ItemEvent ;
@ -70,6 +79,9 @@ import java.util.concurrent.FutureTask;
* @since 2012 - 7 - 11下午4 : 49 : 39
* /
public class ChoosePane extends BasicBeanPane < DataBaseItems > implements Refreshable , Previewable , Prepare4DataSourceChange {
private static final List < String > PENDING_CONTENT = new ArrayList < > ( Collections . singletonList ( Toolkit . i18nText ( "Fine-Design_Basic_Loading" ) + "..." ) ) ;
private static final double COLUMN_SIZE = 24 ;
/ * *
@ -91,6 +103,8 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
private SwingWorker populateWorker ;
private SwingWorker < List < String > , Void > initWorker ;
private PopupMenuListener popupMenuListener = new PopupMenuListener ( ) {
@Override
@ -213,10 +227,34 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
@SuppressWarnings ( "unchecked" )
protected void initDsNameComboBox ( ) {
if ( initWorker ! = null & & ! initWorker . isDone ( ) ) {
initWorker . cancel ( true ) ;
}
dsNameComboBox . setRefreshingModel ( true ) ;
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel ( getHasAuthConnections ( ) ) ;
dsNameComboBox . setModel ( dsNameComboBoxModel ) ;
dsNameComboBox . setRefreshingModel ( false ) ;
dsNameComboBox . setModel ( new FilterableComboBoxModel ( PENDING_CONTENT ) ) ;
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 . setSelectedItem ( selected ) ;
dsNameComboBox . setRefreshingModel ( false ) ;
} catch ( Exception e ) {
if ( ! ( e instanceof CancellationException ) ) {
FineLoggerFactory . getLogger ( ) . error ( e . getMessage ( ) , e ) ;
}
}
}
} ;
initWorker . execute ( ) ;
}
protected void initComponentsLayout ( PreviewLabel previewLabel , int labelSize ) {