KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > service > eclipse > ui > WizardPane1


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

16 package org.apache.axis.tool.service.eclipse.ui;
17
18
19 import org.apache.axis.tool.service.bean.Page1Bean;
20 import org.apache.axis.tool.service.eclipse.plugin.ServiceArchiver;
21 import org.eclipse.jface.wizard.WizardPage;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.ModifyEvent;
24 import org.eclipse.swt.events.ModifyListener;
25 import org.eclipse.swt.events.MouseAdapter;
26 import org.eclipse.swt.events.MouseEvent;
27 import org.eclipse.swt.layout.GridData;
28 import org.eclipse.swt.layout.GridLayout;
29 import org.eclipse.swt.widgets.Button;
30 import org.eclipse.swt.widgets.Composite;
31 import org.eclipse.swt.widgets.DirectoryDialog;
32 import org.eclipse.swt.widgets.Label;
33 import org.eclipse.swt.widgets.Text;
34
35
36 public class WizardPane1 extends WizardPage {
37
38     private Text classFileLocationText;
39     private Button browseButton;
40     
41     private boolean pageComplete;
42     
43     public WizardPane1(){
44         super("page1");
45         this.setTitle(ServiceArchiver.getResourceString("page1.title"));
46         this.setDescription(ServiceArchiver.getResourceString("page1.welcometext"));
47         this.setImageDescriptor(ServiceArchiver.getWizardImageDescriptor());
48     }
49    
50
51     /* (non-Javadoc)
52      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
53      */

54     public void createControl(Composite parent) {
55         Composite container = new Composite(parent, SWT.NULL);
56         GridLayout layout = new GridLayout();
57         layout.numColumns=3;
58         container.setLayout(layout);
59         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
60         Label lable = new Label(container,SWT.NULL);
61         lable.setText(ServiceArchiver.getResourceString("page1.fileLocationLabel"));
62         
63         classFileLocationText = new Text(container,SWT.BORDER);
64         classFileLocationText.setLayoutData(gd);
65         classFileLocationText.addModifyListener(new ModifyListener(){
66             public void modifyText(ModifyEvent e){
67                 handleModify();
68             }
69         });
70         
71         browseButton = new Button(container,SWT.PUSH);
72         browseButton.setText(ServiceArchiver.getResourceString("general.browse"));
73         browseButton.addMouseListener(new MouseAdapter(){
74             public void mouseUp(MouseEvent e) {
75                 handleBrowse();
76             }
77         });
78         
79         setControl(container);
80         setPageComplete(false);
81     }
82     
83     
84     private void handleBrowse(){
85        DirectoryDialog dirDialog = new DirectoryDialog(this.getShell());
86        dirDialog.setMessage(ServiceArchiver.getResourceString("page1.filedialogTitle"));
87        String JavaDoc returnText = dirDialog.open();
88        if (returnText!=null){
89            this.classFileLocationText.setText(returnText);
90        }
91     }
92     
93     private void handleModify(){
94         String JavaDoc classLocationText = this.classFileLocationText.getText().trim();
95         if (classLocationText.equals("")){
96             updateMessage("Filename should not be empty");
97             return;
98         }else{
99             updateMessage(null);
100         }
101     }
102     
103     private void updateMessage(String JavaDoc str){
104         this.setErrorMessage(str);
105         setPageComplete(str==null);
106     }
107     
108     public Page1Bean getBean(){
109         Page1Bean pageBean = new Page1Bean();
110         pageBean.setFileLocation(this.classFileLocationText.getText());
111         return pageBean;
112     }
113 }
114
Popular Tags