@Test public void testLoadConnectionData() throws Exception { DatabaseInterface dbInterface = mock( DatabaseInterface.class ); when( dbInterface.getDefaultDatabasePort() ).thenReturn( 5309 ); DataHandler.connectionMap.put( "myDb", dbInterface ); dataHandler.loadConnectionData(); dataHandler.loadConnectionData(); }
public void loadConnectionData() { if ( connectionBox != null ) { return; } getControls(); 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 ); } } } ); } } ); connectionBox.setRows( connectionBox.getRows() ); Object key = connectionBox.getSelectedItem(); if ( key == null ) { key = connectionMap.firstKey(); connectionBox.setSelectedItem( key ); } if ( dialogDeck != null ) { setDeckChildIndex(); } setDefaultPoolParameters(); if ( poolParameterTree != null ) { poolParameterTree.setRows( poolParameterTree.getRows() ); } }
DataHandler extends AbstractXulEventHandler { public void loadConnectionData() { if ( connectionBox != null ) { return; } getControls(); 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 ); } } } ); } } ); connectionBox.setRows( connectionBox.getRows() ); Object key = connectionBox.getSelectedItem(); if ( key == null ) { key = connectionMap.firstKey(); connectionBox.setSelectedItem( key ); } if ( dialogDeck != null ) { setDeckChildIndex(); } setDefaultPoolParameters(); if ( poolParameterTree != null ) { poolParameterTree.setRows( poolParameterTree.getRows() ); } } }
DataHandler extends AbstractXulEventHandler { public void loadConnectionData() { if ( connectionBox != null ) { return; } getControls(); 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 ); } } } ); } } ); connectionBox.setRows( connectionBox.getRows() ); Object key = connectionBox.getSelectedItem(); if ( key == null ) { key = connectionMap.firstKey(); connectionBox.setSelectedItem( key ); } if ( dialogDeck != null ) { setDeckChildIndex(); } setDefaultPoolParameters(); if ( poolParameterTree != null ) { poolParameterTree.setRows( poolParameterTree.getRows() ); } } DataHandler(); }
DataHandler extends AbstractXulEventHandler { public void loadConnectionData() { if ( connectionBox != null ) { return; } getControls(); 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 ); } } } ); } } ); connectionBox.setRows( connectionBox.getRows() ); Object key = connectionBox.getSelectedItem(); if ( key == null ) { key = connectionMap.firstKey(); connectionBox.setSelectedItem( key ); } if ( dialogDeck != null ) { setDeckChildIndex(); } setDefaultPoolParameters(); if ( poolParameterTree != null ) { poolParameterTree.setRows( poolParameterTree.getRows() ); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); }
DataHandler extends AbstractXulEventHandler { public void loadConnectionData() { if ( connectionBox != null ) { return; } getControls(); 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 ); } } } ); } } ); connectionBox.setRows( connectionBox.getRows() ); Object key = connectionBox.getSelectedItem(); if ( key == null ) { key = connectionMap.firstKey(); connectionBox.setSelectedItem( key ); } if ( dialogDeck != null ) { setDeckChildIndex(); } setDefaultPoolParameters(); if ( poolParameterTree != null ) { poolParameterTree.setRows( poolParameterTree.getRows() ); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }