public void loadConnectionData() {

    // HACK: need to check if onload event was already fired.
    // It is called from XulDatabaseDialog from dcDialog.getSwtInstance(shell); AND dialog.show();
    // Multiple calls lead to multiple numbers of database types.
    // Therefore we check if the connectionBox was already filled.
    if ( connectionBox != null ) {
      return;
    }

    getControls();

    // Add sorted types to the listbox now.

    final SortedSet<String> keys = new TreeSet<String>( connectionMap.keySet() );
    for ( String key : keys ) {
      connectionBox.addItem( key );
    }
    PluginRegistry registry = PluginRegistry.getInstance();
    registry.addPluginListener( DatabasePluginType.class, new DatabaseTypeListener( registry ) {
      @Override
      public void databaseTypeAdded( String pluginName, DatabaseInterface databaseInterface ) {
        if ( keys.add( pluginName ) ) {
          update();
        }
      }

      @Override
      public void databaseTypeRemoved( String pluginName ) {
        if ( keys.remove( pluginName ) ) {
          update();
        }
      }

      private void update() {
        Display.getDefault().syncExec( new Runnable() {
          @Override
          public void run() {
            connectionBox.removeItems();
            for ( String key : keys ) {
              connectionBox.addItem( key );
            }
          }
        } );
      }
    } );

    // HACK: Need to force height of list control, as it does not behave
    // well when using relative layouting

    connectionBox.setRows( connectionBox.getRows() );

    Object key = connectionBox.getSelectedItem();

    // Nothing selected yet...select first item.

    // TODO Implement a connection type preference,
    // and use that type as the default for
    // new databases.

    if ( key == null ) {
      key = connectionMap.firstKey();
      connectionBox.setSelectedItem( key );
    }

    // HACK: Need to force selection of first panel

    if ( dialogDeck != null ) {
      setDeckChildIndex();
    }

    setDefaultPoolParameters();
    // HACK: reDim the pooling table
    if ( poolParameterTree != null ) {
      poolParameterTree.setRows( poolParameterTree.getRows() );
    }
  }
@Test
  public void testLoadConnectionData() throws Exception {

    DatabaseInterface dbInterface = mock( DatabaseInterface.class );
    when( dbInterface.getDefaultDatabasePort() ).thenReturn( 5309 );
    DataHandler.connectionMap.put( "myDb", dbInterface );
    dataHandler.loadConnectionData();

    // Should immediately return if called again since the connectionBox will have been loaded
    dataHandler.loadConnectionData();
  }