OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, the Dart project authors. | 2 * Copyright (c) 2011, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not |
5 * use this file except in compliance with the License. You may obtain a copy of | 5 * use this file except in compliance with the License. You may obtain a copy of |
6 * the License at | 6 * the License at |
7 * | 7 * |
8 * http://www.eclipse.org/legal/epl-v10.html | 8 * http://www.eclipse.org/legal/epl-v10.html |
9 * | 9 * |
10 * Unless required by applicable law or agreed to in writing, software | 10 * Unless required by applicable law or agreed to in writing, software |
(...skipping 15 matching lines...) Expand all Loading... |
26 import org.eclipse.swt.events.FocusEvent; | 26 import org.eclipse.swt.events.FocusEvent; |
27 import org.eclipse.swt.events.ModifyEvent; | 27 import org.eclipse.swt.events.ModifyEvent; |
28 import org.eclipse.swt.events.ModifyListener; | 28 import org.eclipse.swt.events.ModifyListener; |
29 import org.eclipse.swt.events.SelectionAdapter; | 29 import org.eclipse.swt.events.SelectionAdapter; |
30 import org.eclipse.swt.events.SelectionEvent; | 30 import org.eclipse.swt.events.SelectionEvent; |
31 import org.eclipse.swt.layout.GridData; | 31 import org.eclipse.swt.layout.GridData; |
32 import org.eclipse.swt.layout.GridLayout; | 32 import org.eclipse.swt.layout.GridLayout; |
33 import org.eclipse.swt.widgets.Button; | 33 import org.eclipse.swt.widgets.Button; |
34 import org.eclipse.swt.widgets.Composite; | 34 import org.eclipse.swt.widgets.Composite; |
35 import org.eclipse.swt.widgets.DirectoryDialog; | 35 import org.eclipse.swt.widgets.DirectoryDialog; |
| 36 import org.eclipse.swt.widgets.Group; |
36 import org.eclipse.swt.widgets.Label; | 37 import org.eclipse.swt.widgets.Label; |
37 import org.eclipse.swt.widgets.Text; | 38 import org.eclipse.swt.widgets.Text; |
38 | 39 |
39 import java.io.File; | 40 import java.io.File; |
40 | 41 |
41 /** | 42 /** |
42 * The New Application wizard page. | 43 * The New Application wizard page. |
43 * | 44 * |
44 * @see NewApplicationWizard | 45 * @see NewApplicationWizard |
45 * @see ApplicationGenerator | 46 * @see ApplicationGenerator |
46 */ | 47 */ |
47 public class NewApplicationWizardPage extends AbstractDartWizardPage { | 48 public class NewApplicationWizardPage extends AbstractDartWizardPage { |
48 | 49 |
49 private final boolean DEBUG = false; | 50 private final boolean DEBUG = false; |
50 | 51 |
51 private final ApplicationGenerator applicationGenerator; | 52 private final ApplicationGenerator applicationGenerator; |
52 | 53 |
53 private Text applicationLocationField; | 54 private Text applicationLocationField; |
54 | 55 |
55 private Text applicationNameField; | 56 private Text applicationNameField; |
56 | 57 |
| 58 private Button webApplicationButton; |
| 59 |
57 private boolean useDefaultLocation = true; | 60 private boolean useDefaultLocation = true; |
58 private String defaultLocation; | 61 private String defaultLocation; |
59 | 62 |
60 protected NewApplicationWizardPage(ApplicationGenerator applicationGenerator)
{ | 63 protected NewApplicationWizardPage(ApplicationGenerator applicationGenerator)
{ |
61 super("newApplicationWizardPage1"); | 64 super("newApplicationWizardPage1"); //$NON-NLS-1$ |
62 Assert.isNotNull(applicationGenerator); | 65 Assert.isNotNull(applicationGenerator); |
63 this.applicationGenerator = applicationGenerator; | 66 this.applicationGenerator = applicationGenerator; |
64 setTitle(WizardMessages.NewApplicationWizardPage_title); | 67 setTitle(WizardMessages.NewApplicationWizardPage_title); |
65 setDescription(ApplicationGenerator.DESCRIPTION); | 68 setDescription(ApplicationGenerator.DESCRIPTION); |
66 defaultLocation = getDefaultFolder(); | 69 defaultLocation = getDefaultFolder(); |
67 } | 70 } |
68 | 71 |
69 @Override | 72 @Override |
70 public void createControl(Composite parent) { | 73 public void createControl(Composite parent) { |
71 Composite container = new Composite(parent, SWT.NULL); | 74 Composite container = new Composite(parent, SWT.NULL); |
72 setControl(container); | |
73 container.setLayout(new GridLayout(1, false)); | |
74 | 75 |
75 GridData gd_composite_1 = new GridData(SWT.CENTER, SWT.CENTER, false, false,
1, 1); | 76 GridData gd_composite_1 = new GridData(SWT.CENTER, SWT.CENTER, false, false,
1, 1); |
76 container.setLayoutData(gd_composite_1); | 77 container.setLayoutData(gd_composite_1); |
77 container.setLayout(new GridLayout(3, false)); | 78 container.setLayout(new GridLayout(3, false)); |
78 | 79 |
79 Label nameLabel = new Label(container, SWT.NONE); | 80 Label nameLabel = new Label(container, SWT.NONE); |
80 nameLabel.setText(WizardMessages.NewApplicationWizardPage_name); | 81 nameLabel.setText(WizardMessages.NewApplicationWizardPage_name); |
81 | 82 |
82 applicationNameField = new Text(container, SWT.BORDER); | 83 applicationNameField = new Text(container, SWT.BORDER); |
83 applicationNameField.setText(""); | 84 applicationNameField.setText(""); //$NON-NLS-1$ |
84 applicationNameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false, 2, 1)); | 85 applicationNameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false, 2, 1)); |
85 applicationNameField.addFocusListener(new FocusAdapter() { | 86 applicationNameField.addFocusListener(new FocusAdapter() { |
86 @Override | 87 @Override |
87 public void focusGained(FocusEvent e) { | 88 public void focusGained(FocusEvent e) { |
88 applicationNameField.selectAll(); | 89 applicationNameField.selectAll(); |
89 } | 90 } |
90 }); | 91 }); |
91 applicationNameField.addModifyListener(new ModifyListener() { | 92 applicationNameField.addModifyListener(new ModifyListener() { |
92 @Override | 93 @Override |
93 public void modifyText(ModifyEvent e) { | 94 public void modifyText(ModifyEvent e) { |
(...skipping 23 matching lines...) Expand all Loading... |
117 | 118 |
118 Button browseButton = new Button(container, SWT.NONE); | 119 Button browseButton = new Button(container, SWT.NONE); |
119 browseButton.setText(WizardMessages.NewApplicationWizardPage_browse); | 120 browseButton.setText(WizardMessages.NewApplicationWizardPage_browse); |
120 browseButton.addSelectionListener(new SelectionAdapter() { | 121 browseButton.addSelectionListener(new SelectionAdapter() { |
121 @Override | 122 @Override |
122 public void widgetSelected(SelectionEvent e) { | 123 public void widgetSelected(SelectionEvent e) { |
123 handleBrowseButton(applicationLocationField); | 124 handleBrowseButton(applicationLocationField); |
124 } | 125 } |
125 }); | 126 }); |
126 | 127 |
| 128 Label label = new Label(container, SWT.NONE); |
| 129 label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); |
| 130 Group group = new Group(container, SWT.NONE); |
| 131 group.setText(WizardMessages.NewApplicationWizardPage_ApplicationType_Title)
; |
| 132 group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); |
| 133 group.setLayout(new GridLayout(1, false)); |
| 134 |
| 135 webApplicationButton = new Button(group, SWT.RADIO); |
| 136 webApplicationButton.setText(WizardMessages.NewApplicationWizardPage_WebAppl
ication); |
| 137 webApplicationButton.setToolTipText(WizardMessages.NewApplicationWizardPage_
WebButtonToolTip); |
| 138 webApplicationButton.setSelection(applicationGenerator.isWebApplication()); |
| 139 webApplicationButton.addSelectionListener(new SelectionAdapter() { |
| 140 @Override |
| 141 public void widgetSelected(SelectionEvent e) { |
| 142 updateApplicationType(); |
| 143 } |
| 144 }); |
| 145 Button serverApplicationButton = new Button(group, SWT.RADIO); |
| 146 serverApplicationButton.setText(WizardMessages.NewApplicationWizardPage_Comm
andLineApplication); |
| 147 serverApplicationButton.setToolTipText(WizardMessages.NewApplicationWizardPa
ge_CommandLineButtonToolTip); |
| 148 serverApplicationButton.setSelection(!applicationGenerator.isWebApplication(
)); |
| 149 |
127 applicationNameField.setFocus(); | 150 applicationNameField.setFocus(); |
128 setPageComplete(false); | 151 setPageComplete(false); |
| 152 setControl(container); |
129 } | 153 } |
130 | 154 |
131 @Override | 155 @Override |
132 protected String getDefaultFolder() { | 156 protected String getDefaultFolder() { |
133 String defaultLocation = System.getProperty("user.home"); //$NON-NLS-1$ | 157 String defaultLocation = System.getProperty("user.home"); //$NON-NLS-1$ |
134 return defaultLocation + File.separator + "dart" + File.separator; | 158 return defaultLocation + File.separator + "dart" + File.separator; //$NON-NL
S-1$ |
135 | 159 |
136 } | 160 } |
137 | 161 |
138 @Override | 162 @Override |
139 protected void handleBrowseButton(Text locationField) { | 163 protected void handleBrowseButton(Text locationField) { |
140 DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); | 164 DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); |
141 String location = locationField.getText().trim(); | 165 String location = locationField.getText().trim(); |
142 if (!new File(location).exists()) { | 166 if (!new File(location).exists()) { |
143 if (new File(defaultLocation).exists()) { | 167 if (new File(defaultLocation).exists()) { |
144 location = defaultLocation; | 168 location = defaultLocation; |
(...skipping 24 matching lines...) Expand all Loading... |
169 * Update the name of the file in the {@link FileGenerator}. | 193 * Update the name of the file in the {@link FileGenerator}. |
170 */ | 194 */ |
171 protected void updateName() { | 195 protected void updateName() { |
172 applicationGenerator.setApplicationName(applicationNameField.getText()); | 196 applicationGenerator.setApplicationName(applicationNameField.getText()); |
173 if (useDefaultLocation) { | 197 if (useDefaultLocation) { |
174 applicationLocationField.setText(defaultLocation + applicationNameField.ge
tText().trim()); | 198 applicationLocationField.setText(defaultLocation + applicationNameField.ge
tText().trim()); |
175 } | 199 } |
176 updateState(); | 200 updateState(); |
177 } | 201 } |
178 | 202 |
| 203 private void updateApplicationType() { |
| 204 applicationGenerator.setWebApplication(webApplicationButton.getSelection()); |
| 205 updateState(); |
| 206 } |
| 207 |
179 private void updateState() { | 208 private void updateState() { |
180 if (applicationNameField.getText().isEmpty()) { | 209 if (applicationNameField.getText().isEmpty()) { |
181 return; | 210 return; |
182 } | 211 } |
183 IStatus status = applicationGenerator.validate(); | 212 IStatus status = applicationGenerator.validate(); |
184 // Should this be a trace instead of a local DEBUG flag? | 213 // Should this be a trace instead of a local DEBUG flag? |
185 if (DEBUG) { | 214 if (DEBUG) { |
186 System.out.println("NewLibraryWizardPage.updateState()"); | 215 System.out.println("NewLibraryWizardPage.updateState()"); //$NON-NLS-1$ |
187 System.out.println("\t\"" + applicationLocationField.getText() + "\""); | 216 System.out.println("\t\"" + applicationLocationField.getText() + "\""); //
$NON-NLS-1$ //$NON-NLS-2$ |
188 System.out.println("\t\"" + applicationNameField.getText() + "\""); | 217 System.out.println("\t\"" + applicationNameField.getText() + "\""); //$NON
-NLS-1$ //$NON-NLS-2$ |
189 if (status.isOK()) { | 218 if (status.isOK()) { |
190 System.out.println("\tSTATUS IS OKAY \"" + status.getMessage() + "\""); | 219 System.out.println("\tSTATUS IS OKAY \"" + status.getMessage() + "\"");
//$NON-NLS-1$ //$NON-NLS-2$ |
191 } else { | 220 } else { |
192 System.out.println("\tSTATUS NOT OKAY \"" + status.getMessage() + "\""); | 221 System.out.println("\tSTATUS NOT OKAY \"" + status.getMessage() + "\"");
//$NON-NLS-1$ //$NON-NLS-2$ |
193 } | 222 } |
194 } | 223 } |
195 setMessage(WizardMessages.NewApplicationWizardPage_message); | 224 setMessage(WizardMessages.NewApplicationWizardPage_message); |
196 if (status.isOK()) { | 225 if (status.isOK()) { |
197 setPageComplete(true); | 226 setPageComplete(true); |
198 setMessage(WizardMessages.NewApplicationWizardPage_message); | 227 setMessage(WizardMessages.NewApplicationWizardPage_message); |
199 setErrorMessage(null); | 228 setErrorMessage(null); |
200 } else { | 229 } else { |
201 setPageComplete(false); | 230 setPageComplete(false); |
202 setErrorMessage(status.getMessage()); | 231 setErrorMessage(status.getMessage()); |
203 } | 232 } |
204 } | 233 } |
205 } | 234 } |
OLD | NEW |