KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > codegen > eclipse > ui > OutputPage


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.codegen.eclipse.ui;
17
18 import org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
19 import org.eclipse.core.resources.ResourcesPlugin;
20 import org.eclipse.core.runtime.Path;
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.SelectionAdapter;
26 import org.eclipse.swt.events.SelectionEvent;
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 import org.eclipse.ui.dialogs.ContainerSelectionDialog;
35
36 public class OutputPage extends WizardPage {
37     private Text outputLocation;
38     private Button browseButton;
39     private Button locationSelectCheckBox;
40
41     /**
42      * @param pageName
43      */

44     public OutputPage() {
45         super(CodegenWizardPlugin.getResourceString("page3.name"));
46         setTitle(CodegenWizardPlugin.getResourceString("page3.title"));
47         setDescription(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.desc"));
48         setImageDescriptor(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getWizardImageDescriptor());
49         //set the page complete status to false at initilaization
50
setPageComplete(false);
51
52     }
53
54     /*
55      * (non-Javadoc)
56      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
57      */

58     public void createControl(Composite parent) {
59         Composite container = new Composite(parent, SWT.NULL);
60         GridLayout layout = new GridLayout();
61         container.setLayout(layout);
62         layout.numColumns = 3;
63         layout.verticalSpacing = 9;
64
65         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
66         Label label = new Label(container, SWT.NULL);
67         label.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
68                 .getResourceString("page3.output.caption"));
69
70         outputLocation = new Text(container, SWT.BORDER);
71         outputLocation.setLayoutData(gd);
72         outputLocation.addModifyListener(new ModifyListener() {
73             public void modifyText(ModifyEvent e) {
74                 handleModifyEvent();
75             }
76         });
77
78         browseButton = new Button(container, SWT.PUSH);
79         browseButton.setText(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
80                 .getResourceString("page3.outselection.browse"));
81         browseButton.addSelectionListener(new SelectionAdapter() {
82             public void widgetSelected(SelectionEvent e) {
83                 handleBrowse();
84             }
85         });
86
87 // locationSelectCheckBox = new Button(container, SWT.CHECK);
88
// locationSelectCheckBox.setText("Workspace projects only");
89

90         setControl(container);
91         
92
93     }
94     
95     /**
96      * get the output location
97      * @return
98      */

99     public String JavaDoc getOutputLocation() {
100         return outputLocation.getText();
101     }
102
103     /**
104      * Worker method for handling modifications to the
105      * textbox
106      *
107      */

108     private void handleModifyEvent() {
109         String JavaDoc text = this.outputLocation.getText();
110         if ((text == null) || (text.trim().equals(""))) {
111             updateStatus(org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin
112                     .getResourceString("page3.error.nolocation"));
113             return;
114         }
115         updateStatus(null);
116     }
117
118     /**
119      * Updates the wizard page error messages
120      * @param message
121      */

122     private void updateStatus(String JavaDoc message) {
123         setErrorMessage(message);
124         setPageComplete(message == null);
125     }
126
127     /**
128      * Handle the browse button events
129      *
130      */

131     private void handleBrowse() {
132         boolean location = false;//locationSelectCheckBox.getSelection();
133
if (!location) {
134             DirectoryDialog dialog = new DirectoryDialog(this.getShell());
135             String JavaDoc returnString = dialog.open();
136             if (returnString != null) {
137                 outputLocation.setText(returnString);
138             }
139         } else {
140             ContainerSelectionDialog dialog =
141                 new ContainerSelectionDialog(
142                     getShell(),
143                     ResourcesPlugin.getWorkspace().getRoot(),
144                     false,
145                     org.apache.axis.tool.codegen.eclipse.plugin.CodegenWizardPlugin.getResourceString("page3.containerbox.title"));
146             if (dialog.open() == ContainerSelectionDialog.OK) {
147                 Object JavaDoc[] result = dialog.getResult();
148                 if (result.length == 1) {
149                     outputLocation.setText(((Path)result[0]).toOSString());
150                 }
151             }
152         }
153     }
154 }
155
Popular Tags