// Checking if we are already in the LDAP perspective
if ( ( ldapPerspective != null ) && ( ldapPerspective.equals( currentPerspective ) ) )
{
// As we're already in the LDAP perspective, we only indicate to the user
// the name of the connection that has been created
MessageDialog dialog = new MessageDialog( window.getShell(), "Connection created", null,
"A connection called '" + connection.getName() + "' has been created.", MessageDialog.INFORMATION,
new String[]
{ IDialogConstants.OK_LABEL }, MessageDialog.OK );
dialog.open();
}
else
{
// We're not already in the LDAP perspective, we indicate to the user
// the name of the connection that has been created and we ask him
// if we wants to switch to the LDAP perspective
MessageDialog dialog = new MessageDialog( window.getShell(), "Connection created", null,
"A connection called '" + connection.getName()
+ "' has been created.\n\nDo you want to switch to the LDAP perspective ?",
MessageDialog.INFORMATION, new String[]
{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, MessageDialog.OK );
if ( dialog.open() == MessageDialog.OK )
{
// Switching to the LDAP perspective
window.getActivePage().setPerspective( ldapPerspective );
}
}