PhotovaultSettings settings = PhotovaultSettings.getSettings();
Collection databases = settings.getDatabases();
Vector dbNames = new Vector();
Iterator iter = databases.iterator();
while ( iter.hasNext() ) {
PVDatabase db = (PVDatabase) iter.next();
dbNames.add( db.getName() );
}
Collections.sort( dbNames, Collator.getInstance() );
Object[] dbs = dbNames.toArray();
JLabel dbLabel = new JLabel( "Database" );
gb.setConstraints( dbLabel, labelConstraints );
loginPane.add( dbLabel );
dbField = new JComboBox( dbs );
dbField.addItemListener( new ItemListener() {
public void itemStateChanged(ItemEvent itemEvent) {
if ( itemEvent.getStateChange() == ItemEvent.SELECTED ) {
// Enable/disable the username & password fields based on
// database type
Object item = itemEvent.getItem();
String dbName = item.toString();
PhotovaultSettings settings = PhotovaultSettings.getSettings();
PVDatabase db = settings.getDatabase( dbName );
if ( db != null ) {
setCredentialsEnabled(
db.getInstanceType() == PVDatabase.TYPE_SERVER );
}
}
}
});