KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > wizards > NewConnectionMainWizardPage


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
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.BrowserCommonConstants;
26 import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionPageModifyListener;
27 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
28 import org.eclipse.jface.wizard.WizardPage;
29 import org.eclipse.swt.SWT;
30 import org.eclipse.swt.layout.GridLayout;
31 import org.eclipse.swt.widgets.Composite;
32
33
34 /**
35  * The NewConnectionMainWizardPage is used to specify the connection name
36  * and the network parameters of the new connection.
37  *
38  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
39  * @version $Rev$, $Date$
40  */

41 public class NewConnectionMainWizardPage extends WizardPage implements ConnectionPageModifyListener
42 {
43
44     /** The wizard. */
45     private NewConnectionWizard wizard;
46
47
48     /**
49      * Creates a new instance of NewConnectionMainWizardPage.
50      *
51      * @param pageName the page name
52      * @param wizard the wizard
53      */

54     public NewConnectionMainWizardPage( String JavaDoc pageName, NewConnectionWizard wizard )
55     {
56         super( pageName );
57         setTitle( "New LDAP Connection" );
58         setDescription( "Please enter connection name and network parameters." );
59         setImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_CONNECTION_WIZARD ) );
60         setPageComplete( false );
61
62         this.wizard = wizard;
63         wizard.getCpw().addConnectionPageModifyListener( this );
64     }
65
66
67     /**
68      * {@inheritDoc}
69      */

70     public void connectionPageModified()
71     {
72         if ( isCurrentPage() )
73         {
74             validate();
75         }
76     }
77
78
79     /**
80      * {@inheritDoc}
81      */

82     public void setMessage( String JavaDoc message )
83     {
84         if ( isCurrentPage() )
85         {
86             super.setMessage( message );
87             validate();
88         }
89     }
90
91
92     /**
93      * {@inheritDoc}
94      */

95     public void setErrorMessage( String JavaDoc errorMessage )
96     {
97         if ( isCurrentPage() )
98         {
99             super.setErrorMessage( errorMessage );
100             validate();
101         }
102     }
103
104
105     /**
106      * {@inheritDoc}
107      */

108     public IConnection getRealConnection()
109     {
110         return null;
111     }
112
113
114     /**
115      * Validates this page.
116      */

117     private void validate()
118     {
119         setPageComplete( getMessage() == null );
120         getContainer().updateButtons();
121     }
122
123
124     /**
125      * {@inheritDoc}
126      */

127     public void createControl( Composite parent )
128     {
129         Composite composite = new Composite( parent, SWT.NONE );
130         GridLayout gl = new GridLayout( 1, false );
131         composite.setLayout( gl );
132
133         wizard.getCpw().addMainInput( "", "", 389, IConnection.ENCYRPTION_NONE, composite );
134         wizard.getCpw().addOpenConnectionInput( true, composite );
135
136         setControl( composite );
137     }
138
139 }
Popular Tags