1 20 package org.apache.directory.ldapstudio.proxy.controller.actions; 21 22 23 import java.io.IOException ; 24 25 import org.apache.directory.ldapstudio.proxy.Activator; 26 import org.apache.directory.ldapstudio.proxy.model.LdapProxy; 27 import org.apache.directory.ldapstudio.proxy.view.IImageKeys; 28 import org.apache.directory.ldapstudio.proxy.view.ProxyView; 29 import org.apache.directory.ldapstudio.proxy.view.wizards.ConnectWizard; 30 import org.eclipse.jface.action.Action; 31 import org.eclipse.jface.window.Window; 32 import org.eclipse.jface.wizard.WizardDialog; 33 import org.eclipse.ui.PlatformUI; 34 import org.eclipse.ui.plugin.AbstractUIPlugin; 35 36 37 43 public class ConnectAction extends Action 44 { 45 46 private ProxyView view; 47 48 49 55 public ConnectAction( ProxyView view ) 56 { 57 super( "Connect" ); 58 setToolTipText( getText() ); 59 setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.CONNECT ) ); 60 setEnabled( true ); 61 this.view = view; 62 } 63 64 65 68 public void run() 69 { 70 ConnectWizard connectWizard = new ConnectWizard(); 71 72 WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 73 connectWizard ); 74 dialog.create(); 75 if ( dialog.open() == Window.OK ) 76 { 77 LdapProxy ldapProxy = new LdapProxy( connectWizard.getLocalPort(), connectWizard.getRemoteHost(), 78 connectWizard.getRemotePort() ); 79 view.setLdapProxy( ldapProxy ); 80 try 81 { 82 ldapProxy.connect(); 83 } 84 catch ( IOException e ) 85 { 86 e.printStackTrace(); 88 } 89 } 90 } 91 } 92 | Popular Tags |