KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > wizards > BatchOperationFinishWizardPage


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.ui.wizards;
22
23
24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
25 import org.eclipse.jface.wizard.WizardPage;
26 import org.eclipse.swt.SWT;
27 import org.eclipse.swt.events.SelectionAdapter;
28 import org.eclipse.swt.events.SelectionEvent;
29 import org.eclipse.swt.layout.GridData;
30 import org.eclipse.swt.layout.GridLayout;
31 import org.eclipse.swt.widgets.Button;
32 import org.eclipse.swt.widgets.Composite;
33
34
35 public class BatchOperationFinishWizardPage extends WizardPage
36 {
37
38     public final static int EXECUTION_METHOD_NONE = -1;
39
40     public final static int EXECUTION_METHOD_LDIF = 0;
41
42     public final static int EXECUTION_METHOD_ONLINE = 1;
43
44     private Button executeOnlineButton;
45
46     private Button generateLdifButton;
47
48
49     public BatchOperationFinishWizardPage( String JavaDoc pageName, BatchOperationWizard wizard )
50     {
51         super( pageName );
52         super.setTitle( "Select Execution Method" );
53         super
54             .setDescription( "Please select if the batch operation should be executed online or a LDIF should be generated." );
55         super.setPageComplete( false );
56     }
57
58
59     private void validate()
60     {
61         setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE );
62     }
63
64
65     public void createControl( Composite parent )
66     {
67
68         Composite composite = new Composite( parent, SWT.NONE );
69         GridLayout gl = new GridLayout( 1, false );
70         composite.setLayout( gl );
71         composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
72
73         generateLdifButton = BaseWidgetUtils.createRadiobutton( composite, "Generate LDIF", 1 );
74         generateLdifButton.setSelection( true );
75         generateLdifButton.addSelectionListener( new SelectionAdapter()
76         {
77             public void widgetSelected( SelectionEvent e )
78             {
79                 validate();
80             }
81         } );
82
83         executeOnlineButton = BaseWidgetUtils.createRadiobutton( composite, "Excecute online", 1 );
84         executeOnlineButton.setEnabled( false );
85         executeOnlineButton.addSelectionListener( new SelectionAdapter()
86         {
87             public void widgetSelected( SelectionEvent e )
88             {
89                 validate();
90             }
91         } );
92
93         validate();
94
95         setControl( composite );
96     }
97
98
99     public int getExecutionMethod()
100     {
101         if ( executeOnlineButton.getSelection() )
102         {
103             return EXECUTION_METHOD_ONLINE;
104         }
105         else if ( generateLdifButton.getSelection() )
106         {
107             return EXECUTION_METHOD_LDIF;
108         }
109         else
110         {
111             return EXECUTION_METHOD_NONE;
112         }
113     }
114
115 }
116
Popular Tags