KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > proxy > controller > actions > ConnectAction


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.proxy.controller.actions;
21
22
23 import java.io.IOException JavaDoc;
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 /**
38  * This class implements the Connect action.
39  *
40  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
41  * @version $Rev$, $Date$
42  */

43 public class ConnectAction extends Action
44 {
45     /** The associated view */
46     private ProxyView view;
47
48
49     /**
50      * Creates a new instance of ConnectAction.
51      *
52      * @param view
53      * the associated view
54      */

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     /* (non-Javadoc)
66      * @see org.eclipse.jface.action.Action#run()
67      */

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 JavaDoc e )
85             {
86                 // TODO Auto-generated catch block
87
e.printStackTrace();
88             }
89         }
90     }
91 }
92
Popular Tags