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 u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.ui.wizard; | 14 package com.google.dart.tools.ui.wizard; |
15 | 15 |
16 import com.google.dart.tools.core.generator.ApplicationGenerator; | 16 import com.google.dart.tools.core.generator.ApplicationGenerator; |
17 import com.google.dart.tools.ui.DartToolsPlugin; | 17 import com.google.dart.tools.ui.DartToolsPlugin; |
18 import com.google.dart.tools.ui.internal.handlers.NewFileCommandState; | 18 import com.google.dart.tools.ui.internal.handlers.NewFileCommandState; |
19 | 19 |
20 import org.eclipse.core.resources.IFile; | 20 import org.eclipse.core.resources.IFile; |
21 import org.eclipse.core.runtime.CoreException; | 21 import org.eclipse.core.runtime.CoreException; |
22 import org.eclipse.core.runtime.IProgressMonitor; | 22 import org.eclipse.core.runtime.IProgressMonitor; |
| 23 import org.eclipse.jface.dialogs.IDialogSettings; |
23 import org.eclipse.jface.viewers.IStructuredSelection; | 24 import org.eclipse.jface.viewers.IStructuredSelection; |
24 import org.eclipse.ui.INewWizard; | 25 import org.eclipse.ui.INewWizard; |
25 import org.eclipse.ui.IWorkbench; | 26 import org.eclipse.ui.IWorkbench; |
26 import org.eclipse.ui.actions.WorkspaceModifyOperation; | 27 import org.eclipse.ui.actions.WorkspaceModifyOperation; |
27 import org.eclipse.ui.services.ISourceProviderService; | 28 import org.eclipse.ui.services.ISourceProviderService; |
28 | 29 |
29 import java.lang.reflect.InvocationTargetException; | 30 import java.lang.reflect.InvocationTargetException; |
30 | 31 |
31 /** | 32 /** |
32 * This wizard is used to create a new library file. | 33 * This wizard is used to create a new library file. |
33 * | 34 * |
34 * @see NewApplicationWizardPage | 35 * @see NewApplicationWizardPage |
35 * @see ApplicationGenerator | 36 * @see ApplicationGenerator |
36 */ | 37 */ |
37 public class NewApplicationWizard extends AbstractDartWizard implements INewWiza
rd { | 38 public class NewApplicationWizard extends AbstractDartWizard implements INewWiza
rd { |
38 | 39 |
| 40 private static final String WEB_APPLICATION = "webApplication"; |
| 41 |
39 private final ApplicationGenerator appGenerator = new ApplicationGenerator(); | 42 private final ApplicationGenerator appGenerator = new ApplicationGenerator(); |
40 | 43 |
41 private IWorkbench workbench; | 44 private IWorkbench workbench; |
42 | 45 |
43 public NewApplicationWizard() { | 46 public NewApplicationWizard() { |
44 | |
45 setWindowTitle(WizardMessages.NewApplicationWizard_title); | 47 setWindowTitle(WizardMessages.NewApplicationWizard_title); |
46 } | 48 } |
47 | 49 |
48 /** | 50 /** |
49 * Add pages to gather information about the library to be created | 51 * Add pages to gather information about the library to be created |
50 */ | 52 */ |
51 @Override | 53 @Override |
52 public void addPages() { | 54 public void addPages() { |
53 addPage(new NewApplicationWizardPage(appGenerator)); | 55 addPage(new NewApplicationWizardPage(appGenerator)); |
54 } | 56 } |
55 | 57 |
56 @Override | 58 @Override |
57 public void init(IWorkbench workbench, IStructuredSelection selection) { | 59 public void init(IWorkbench workbench, IStructuredSelection selection) { |
58 super.init(workbench, selection); | 60 super.init(workbench, selection); |
59 this.workbench = workbench; | 61 this.workbench = workbench; |
| 62 IDialogSettings settings = DartToolsPlugin.getDefault().getDialogSettingsSec
tion( |
| 63 getClass().getName()); |
| 64 if (settings.get(WEB_APPLICATION) != null) { |
| 65 appGenerator.setWebApplication(settings.getBoolean(WEB_APPLICATION)); |
| 66 } else { |
| 67 settings.put(WEB_APPLICATION, true); |
| 68 appGenerator.setWebApplication(true); |
| 69 } |
60 } | 70 } |
61 | 71 |
62 @Override | 72 @Override |
63 public boolean performFinish() { | 73 public boolean performFinish() { |
| 74 saveSettings(); |
64 try { | 75 try { |
65 getContainer().run(true, true, new WorkspaceModifyOperation() { | 76 getContainer().run(true, true, new WorkspaceModifyOperation() { |
66 @Override | 77 @Override |
67 protected void execute(IProgressMonitor monitor) throws CoreException, | 78 protected void execute(IProgressMonitor monitor) throws CoreException, |
68 InvocationTargetException, InterruptedException { | 79 InvocationTargetException, InterruptedException { |
69 performOperation(monitor); | 80 performOperation(monitor); |
70 } | 81 } |
71 }); | 82 }); |
72 } catch (InvocationTargetException e) { | 83 } catch (InvocationTargetException e) { |
73 DartToolsPlugin.log(e); | 84 DartToolsPlugin.log(e); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 120 } |
110 | 121 |
111 ISourceProviderService service = (ISourceProviderService) workbench.getAct
iveWorkbenchWindow().getService( | 122 ISourceProviderService service = (ISourceProviderService) workbench.getAct
iveWorkbenchWindow().getService( |
112 ISourceProviderService.class); | 123 ISourceProviderService.class); |
113 | 124 |
114 NewFileCommandState newFileCommandStateProvider = (NewFileCommandState) se
rvice.getSourceProvider(NewFileCommandState.NEW_FILE_STATE); | 125 NewFileCommandState newFileCommandStateProvider = (NewFileCommandState) se
rvice.getSourceProvider(NewFileCommandState.NEW_FILE_STATE); |
115 | 126 |
116 newFileCommandStateProvider.checkState(); | 127 newFileCommandStateProvider.checkState(); |
117 } | 128 } |
118 } | 129 } |
| 130 |
| 131 private void saveSettings() { |
| 132 IDialogSettings settings = DartToolsPlugin.getDefault().getDialogSettingsSec
tion( |
| 133 getClass().getName()); |
| 134 settings.put(WEB_APPLICATION, appGenerator.isWebApplication()); |
| 135 } |
119 } | 136 } |
OLD | NEW |