1 20 21 package org.apache.directory.ldapstudio.browser.common.wizards; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionPageWrapper; 26 import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin; 27 import org.apache.directory.ldapstudio.browser.core.jobs.OpenConnectionsJob; 28 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 29 import org.eclipse.jface.viewers.IStructuredSelection; 30 import org.eclipse.jface.wizard.Wizard; 31 import org.eclipse.swt.widgets.Composite; 32 import org.eclipse.ui.INewWizard; 33 import org.eclipse.ui.IWorkbench; 34 import org.eclipse.ui.PlatformUI; 35 36 37 43 public class NewConnectionWizard extends Wizard implements INewWizard 44 { 45 46 47 private ConnectionPageWrapper cpw; 48 49 50 private NewConnectionMainWizardPage mainPage; 51 52 53 private NewConnectionAuthWizardPage authPage; 54 55 56 private NewConnectionOptionsWizardPage optionsPage; 57 58 59 62 public NewConnectionWizard() 63 { 64 setWindowTitle( "New LDAP Connection" ); 65 setNeedsProgressMonitor( true ); 66 } 67 68 69 74 public static String getId() 75 { 76 return NewConnectionWizard.class.getName(); 77 } 78 79 80 83 public void init( IWorkbench workbench, IStructuredSelection selection ) 84 { 85 } 86 87 88 91 public void addPages() 92 { 93 cpw = new ConnectionPageWrapper( null, getContainer() ); 94 95 mainPage = new NewConnectionMainWizardPage( NewConnectionMainWizardPage.class.getName(), this ); 96 addPage( mainPage ); 97 98 authPage = new NewConnectionAuthWizardPage( NewConnectionAuthWizardPage.class.getName(), this ); 99 addPage( authPage ); 100 101 optionsPage = new NewConnectionOptionsWizardPage( NewConnectionOptionsWizardPage.class.getName(), this ); 102 addPage( optionsPage ); 103 } 104 105 106 109 public void createPageControls( Composite pageContainer ) 110 { 111 super.createPageControls( pageContainer ); 112 113 PlatformUI.getWorkbench().getHelpSystem().setHelp( mainPage.getControl(), 115 BrowserCommonActivator.PLUGIN_ID + "." + "tools_newconnection_wizard" ); 116 PlatformUI.getWorkbench().getHelpSystem().setHelp( authPage.getControl(), 117 BrowserCommonActivator.PLUGIN_ID + "." + "tools_newconnection_wizard" ); 118 PlatformUI.getWorkbench().getHelpSystem().setHelp( optionsPage.getControl(), 119 BrowserCommonActivator.PLUGIN_ID + "." + "tools_newconnection_wizard" ); 120 } 121 122 123 126 public boolean canFinish() 127 { 128 if ( cpw.getAuthenticationMethod() == IConnection.AUTH_ANONYMOUS ) 129 { 130 return mainPage.isPageComplete() && optionsPage.isPageComplete(); 131 } 132 else if ( cpw.getAuthenticationMethod() == IConnection.AUTH_SIMPLE ) 133 { 134 return mainPage.isPageComplete() && authPage.isPageComplete() && optionsPage.isPageComplete(); 135 } 136 else 137 { 138 return false; 139 } 140 } 141 142 143 146 public boolean performFinish() 147 { 148 final IConnection conn = cpw.getTestConnection(); 149 conn.setName( cpw.getName() ); 150 if ( conn != null ) 151 { 152 BrowserCorePlugin.getDefault().getConnectionManager().addConnection( conn ); 153 if ( cpw.isOpenConnectionOnFinish() ) 154 { 155 new OpenConnectionsJob( conn ).execute(); 156 } 157 cpw.saveDialogSettings(); 158 return true; 159 } 160 return false; 161 } 162 163 164 169 public ConnectionPageWrapper getCpw() 170 { 171 return cpw; 172 } 173 174 } 175 | Popular Tags |