KickJava   Java API By Example, From Geeks To Geeks.

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


1  /*
2   * Copyright 2004,2005 The Apache Software Foundation.
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of 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,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */

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

50      public void createControl(Composite parent) {
51          Composite container = new Composite(parent, SWT.NULL);
52          GridLayout layout = new GridLayout();
53          layout.numColumns=3;
54          container.setLayout(layout);
55          
56          GridData gd = new GridData(GridData.FILL_HORIZONTAL);
57          gd.grabExcessHorizontalSpace = true;
58          
59         Label lable = new Label(container,SWT.NULL);
60         lable.setText(ServiceArchiver.getResourceString("page4.outputlocation.label"));
61         
62         outputFileLocationTextBox = new Text(container,SWT.BORDER);
63         outputFileLocationTextBox.setLayoutData(gd);
64         outputFileLocationTextBox.addModifyListener(new ModifyListener(){
65             public void modifyText(ModifyEvent e){
66                 handleModify();
67             }
68         });
69         
70         gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
71                 
72         browseButton = new Button(container,SWT.PUSH);
73         browseButton.setText(ServiceArchiver.getResourceString("general.browse"));
74         browseButton.setLayoutData(gd);
75         browseButton.addMouseListener(new MouseAdapter(){
76             public void mouseUp(MouseEvent e) {
77                 handleBrowse();
78             }
79         });
80         
81         lable = new Label(container,SWT.NULL);
82         lable.setText(ServiceArchiver.getResourceString("page4.outputname.label"));
83         
84         gd = new GridData(GridData.FILL_HORIZONTAL);
85         gd.horizontalSpan = 2;
86         
87         outputFileNameTextbox = new Text(container,SWT.BORDER);
88         outputFileNameTextbox.setLayoutData(gd);
89         outputFileNameTextbox.addModifyListener(new ModifyListener(){
90             public void modifyText(ModifyEvent e){
91                 handleModify();
92             }
93         });
94         
95         //Fill the name with the default name
96
outputFileNameTextbox.setText("my_service.jar");
97         setControl(container);
98
99
100      }
101      
102      private void handleBrowse(){
103          DirectoryDialog dirDialog = new DirectoryDialog(this.getShell());
104          dirDialog.setMessage(ServiceArchiver.getResourceString("page4.dirdialog.caption"));
105          String JavaDoc returnText = dirDialog.open();
106          if (returnText!=null){
107              this.outputFileLocationTextBox.setText(returnText);
108              this.outputFileLocationTextBox.setToolTipText(returnText);
109          }
110       }
111      
112      private void handleModify(){
113          String JavaDoc outputLocationText = outputFileLocationTextBox.getText();
114          String JavaDoc outputFilenameText = outputFileNameTextbox.getText();
115          if (outputLocationText==null ||outputLocationText.trim().equals("")){
116              this.updateMessage("");
117          }else if (outputLocationText==null ||outputLocationText.trim().equals("")){
118              this.updateMessage("");
119          }else{
120              updateMessage(null);
121          }
122      }
123      
124      private void updateMessage(String JavaDoc str){
125          this.setErrorMessage(str);
126          setPageComplete(str==null);
127      }
128      
129      public Page3Bean getBean(){
130          Page3Bean pageBean = new Page3Bean();
131          pageBean.setOutputFolderName(this.outputFileLocationTextBox.getText().trim());
132          pageBean.setOutputFileName(this.outputFileNameTextbox.getText().trim());
133          return pageBean;
134      }
135  }
136
Popular Tags