KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > wizard > NewJonasProjectWizardPage


1 package com.bull.eclipse.jonas.wizard;
2
3 /*
4  * (c) Copyright Bull SA 2003.
5  * All Rights Reserved.
6  */

7
8
9 import org.eclipse.jface.viewers.ISelection;
10 import org.eclipse.jface.wizard.WizardPage;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.events.SelectionAdapter;
13 import org.eclipse.swt.events.SelectionEvent;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Button;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Label;
19 import org.eclipse.swt.widgets.Text;
20
21 import com.bull.eclipse.jonas.JonasPluginResources;
22
23
24 public class NewJonasProjectWizardPage extends WizardPage implements JonasPluginResources {
25
26     private Button createWebApp;
27     private Button createEJB;
28     private Text webcontextText;
29     private Text webnameText;
30     private Text websrcText;
31     private String JavaDoc warLocation;
32     private Button createSample;
33     private ISelection selection;
34     private Button ejbInProject;
35
36     
37     private Text srcDirEJB;
38
39     //private Text rootDirText;
40
private JonasProjectCreationWizard wizard;
41
42     // See JonasProjectCreationWizard.getNextPage
43
private boolean displayedOnce = false;
44
45     private static final int TEXT_FIELD_WIDTH = 200;
46
47     /**
48      * Creates a new project creation wizard page.
49      *
50      * @param pageName the name of this page
51      */

52     public NewJonasProjectWizardPage(ISelection selection, String JavaDoc pageName) {
53         super(pageName);
54         this.selection = selection;
55     }
56
57     /*
58      * @see IDialogPage#createControl(Composite)
59      */

60     public void createControl(Composite parent) {
61
62         Composite composite = new Composite(parent, SWT.NULL);
63
64         composite.setLayout(new GridLayout());
65         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
66         
67         createWebGroup(composite);
68         createEJBGroup(composite);
69
70
71         setErrorMessage(null);
72         setMessage(null);
73         setControl(composite);
74     }
75
76
77     public void createWebGroup(Composite parent) {
78
79         Composite webGroup = new Composite(parent,SWT.LEFT);
80         GridLayout layout = new GridLayout();
81         layout.numColumns = 2;
82         webGroup.setLayout(layout);
83         webGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
84
85         // project location entry field
86
createWebApp = new Button(webGroup, SWT.CHECK | SWT.LEFT);
87         createWebApp.setText(WIZARD_PROJECT_CREATEWEBAPP_LABEL);
88         createWebApp.setEnabled(true);
89         createWebApp.setSelection(true);
90         createWebApp.addSelectionListener(new SelectionAdapter() {
91                     public void widgetSelected(SelectionEvent ev) {
92                         if (createWebApp.getSelection()) {
93                             webcontextText.setEnabled(true);
94                             webnameText.setEnabled(true);
95                             websrcText.setEnabled(true);
96                         } else {
97                             webcontextText.setEnabled(false);
98                             webnameText.setEnabled(false);
99                             websrcText.setEnabled(false);
100                         }
101                     }});
102
103
104         new Label(webGroup, SWT.NULL);
105
106         // location label
107
Label webpathLabel = new Label(webGroup,SWT.LEFT);
108         webpathLabel.setText(WIZARD_PROJECT_WEBPATH_LABEL);
109         webpathLabel.setEnabled(true);
110
111         // project location entry field
112
webcontextText = new Text(webGroup, SWT.BORDER);
113         GridData data = new GridData(GridData.FILL_HORIZONTAL);
114         data.widthHint = TEXT_FIELD_WIDTH;
115         webcontextText.setLayoutData(data);
116         webcontextText.setText(""); // see JonasProjectCreationWizard.nextPage
117

118
119         //location label
120
Label webnameLabel = new Label(webGroup,SWT.LEFT);
121         webnameLabel.setText(WIZARD_PROJECT_WEBNAME_LABEL);
122
123         // project location entry field
124
webnameText = new Text(webGroup, SWT.BORDER);
125         GridData dataname = new GridData(GridData.FILL_HORIZONTAL);
126         data.widthHint = TEXT_FIELD_WIDTH;
127         webnameText.setLayoutData(dataname);
128         webnameText.setText(""); // see JonasProjectCreationWizard.nextPage
129

130
131         // location label
132
Label websrcLabel = new Label(webGroup,SWT.LEFT);
133         websrcLabel.setText(WIZARD_PROJECT_WEBSRC_LABEL);
134         websrcLabel.setEnabled(true);
135
136         // project location entry field
137
websrcText = new Text(webGroup, SWT.BORDER);
138         GridData datasrc = new GridData(GridData.FILL_HORIZONTAL);
139         data.widthHint = TEXT_FIELD_WIDTH;
140         websrcText.setLayoutData(datasrc);
141         websrcText.setText(""); // see JonasProjectCreationWizard.nextPage
142

143         createSample = new Button( webGroup, SWT.CHECK | SWT.LEFT );
144         createSample.setText(WIZARD_PROJECT_CREATESRC_LABEL);
145         createSample.setEnabled(true);
146         createSample.setSelection(false);
147
148
149     }
150
151     public void createEJBGroup(Composite parent) {
152         Composite ejbGroup = new Composite(parent,SWT.LEFT);
153         GridLayout layout = new GridLayout();
154         layout.numColumns = 2;
155         ejbGroup.setLayout(layout);
156         ejbGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
157
158         ejbInProject = new Button( ejbGroup, SWT.CHECK | SWT.LEFT );
159         ejbInProject.setText(WIZARD_PROJECT_EJBINPROJECT_LABEL);
160         ejbInProject.setEnabled(true);
161         ejbInProject.setSelection(false);
162         ejbInProject.addSelectionListener(new SelectionAdapter() {
163                     public void widgetSelected(SelectionEvent ev) {
164                         if (ejbInProject.getSelection()) {
165                             srcDirEJB.setEnabled(true);
166                         } else {
167                             srcDirEJB.setEnabled(false);
168                         }
169                     }});
170
171         new Label(ejbGroup, SWT.NULL);
172
173         // location label
174
Label ejbsrcLabel = new Label(ejbGroup,SWT.LEFT);
175         ejbsrcLabel.setText(WIZARD_PROJECT_EJBSRC_LABEL);
176
177         // project location entry field
178
srcDirEJB = new Text(ejbGroup, SWT.BORDER);
179         GridData datasrc = new GridData(GridData.FILL_HORIZONTAL);
180         datasrc.widthHint = TEXT_FIELD_WIDTH;
181         srcDirEJB.setLayoutData(datasrc);
182         srcDirEJB.setText("components"); // see JonasProjectCreationWizard.nextPage
183
srcDirEJB.setEnabled(false);
184
185     }
186
187
188     public boolean isWebApp() {
189             return createWebApp.getSelection();
190     }
191
192     public String JavaDoc getWebcontext() {
193         return webcontextText.getText();
194     }
195
196     public String JavaDoc getSrcpath() {
197             return websrcText.getText();
198     }
199
200     public String JavaDoc getWebname() {
201             return webnameText.getText();
202     }
203
204     public String JavaDoc getWarlocation() {
205             return warLocation;
206     }
207
208
209     public void setWebcontext(String JavaDoc path) {
210         warLocation = path + ".war";
211         webcontextText.setText(path);
212     }
213
214     public void setSrcpath(String JavaDoc path) {
215         websrcText.setText(path);
216     }
217
218     public void setWebname(String JavaDoc name) {
219         webnameText.setText(name);
220     }
221
222     public boolean isCreateWebApp() {
223         return createWebApp.getSelection();
224     }
225
226     public boolean isEJBApp() {
227         return createEJB.getSelection();
228     }
229
230     public String JavaDoc getSrcEJBpath() {
231         return srcDirEJB.getText();
232     }
233
234
235     public boolean isSample() {
236
237             return createSample.getSelection();
238     }
239
240     public boolean isEJBPrj() {
241         return ejbInProject.getSelection();
242     }
243
244
245
246     /*
247      * @see IWizardPage#canFlipToNextPage()
248      */

249     public boolean canFlipToNextPage() {
250         displayedOnce = true;
251         return super.canFlipToNextPage();
252     }
253
254
255     /**
256      * Gets the wasDisplayedOnce.
257      * @return Returns a boolean
258      */

259     public boolean wasDisplayedOnce() {
260         return displayedOnce;
261     }
262
263
264 }
265
Popular Tags