2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 package com
.intellij
.ide
.util
.newProjectWizard
.modes
;
23 import com
.intellij
.ide
.util
.newProjectWizard
.ProjectNameWithTypeStep
;
24 import com
.intellij
.ide
.util
.newProjectWizard
.StepSequence
;
25 import com
.intellij
.ide
.util
.projectWizard
.EmptyModuleBuilder
;
26 import com
.intellij
.ide
.util
.projectWizard
.ModuleBuilder
;
27 import com
.intellij
.ide
.util
.projectWizard
.ModuleWizardStep
;
28 import com
.intellij
.ide
.util
.projectWizard
.WizardContext
;
29 import com
.intellij
.openapi
.application
.ApplicationNamesInfo
;
30 import com
.intellij
.openapi
.project
.ProjectBundle
;
31 import com
.intellij
.openapi
.roots
.ui
.configuration
.ModulesProvider
;
32 import com
.intellij
.openapi
.module
.ModuleType
;
33 import org
.jetbrains
.annotations
.NonNls
;
34 import org
.jetbrains
.annotations
.NotNull
;
35 import org
.jetbrains
.annotations
.Nullable
;
38 import java
.util
.HashMap
;
41 public class CreateFromScratchMode
extends WizardMode
{
43 @NonNls private final Map
<String
, ModuleBuilder
> myBuildersMap
= new HashMap
<String
, ModuleBuilder
>();
46 public String
getDisplayName(final WizardContext context
) {
47 return ProjectBundle
.message("project.new.wizard.from.scratch.title", context
.getPresentationName());
51 public String
getDescription(final WizardContext context
) {
52 return ProjectBundle
.message("project.new.wizard.from.scratch.description", ApplicationNamesInfo
.getInstance().getProductName(), context
.getPresentationName());
56 protected StepSequence
createSteps(final WizardContext context
, final ModulesProvider modulesProvider
) {
57 final StepSequence sequence
= new StepSequence(null);
58 sequence
.addCommonStep(new ProjectNameWithTypeStep(context
, sequence
, this));
59 for (ModuleBuilder builder
: ModuleBuilder
.getAllBuilders()) {
60 addModuleBuilder(builder
, context
, modulesProvider
, sequence
);
62 myBuildersMap
.put(ModuleType
.EMPTY
.getId(), new EmptyModuleBuilder());
66 private void addModuleBuilder(ModuleBuilder builder
, WizardContext context
, ModulesProvider modulesProvider
, StepSequence myStepSequence
) {
67 final String id
= builder
.getBuilderId();
68 final StepSequence sequence
= new StepSequence(myStepSequence
);
69 myBuildersMap
.put(id
, builder
);
70 for (ModuleWizardStep step
: builder
.createWizardSteps(context
, modulesProvider
)) {
71 sequence
.addCommonStep(step
);
73 if (!sequence
.getCommonSteps().isEmpty()) {
74 myStepSequence
.addSpecificSteps(id
, sequence
);
78 public boolean isAvailable(WizardContext context
) {
82 public ModuleBuilder
getModuleBuilder() {
83 return myBuildersMap
.get(getSelectedType());
87 public JComponent
getAdditionalSettings() {
91 public void onChosen(final boolean enabled
) {
95 public void dispose() {
97 myBuildersMap
.clear();