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
;
23 import com
.intellij
.ide
.util
.projectWizard
.ModuleWizardStep
;
24 import com
.intellij
.openapi
.module
.ModuleType
;
25 import org
.jetbrains
.annotations
.NonNls
;
26 import org
.jetbrains
.annotations
.Nullable
;
30 public class StepSequence
{
31 private final List
<ModuleWizardStep
> myCommonSteps
= new ArrayList
<ModuleWizardStep
>();
32 private final Map
<String
, StepSequence
> mySpecificSteps
= new HashMap
<String
, StepSequence
>();
33 @NonNls private String myType
;
34 private StepSequence myParentSequence
;
36 public StepSequence() {
40 public StepSequence(final StepSequence stepSequence
) {
41 myParentSequence
= stepSequence
;
44 public void addCommonStep(ModuleWizardStep step
){
45 myCommonSteps
.add(step
);
48 public void addSpecificSteps(String type
, StepSequence sequence
){
49 mySpecificSteps
.put(type
, sequence
);
52 public List
<ModuleWizardStep
> getCommonSteps() {
56 public StepSequence
getSpecificSteps(String type
) {
57 return mySpecificSteps
.get(type
);
60 public Set
<String
> getTypes() {
61 return mySpecificSteps
.keySet();
65 public ModuleWizardStep
getNextStep(ModuleWizardStep step
) {
66 final StepSequence stepSequence
= mySpecificSteps
.get(myType
);
67 if (myCommonSteps
.contains(step
)) {
68 final int idx
= myCommonSteps
.indexOf(step
);
69 if (idx
< myCommonSteps
.size() - 1) {
70 return myCommonSteps
.get(idx
+ 1);
72 if (stepSequence
!= null && stepSequence
.getCommonSteps().size() > 0) {
73 return stepSequence
.getCommonSteps().get(0);
76 if (stepSequence
!= null) {
77 return stepSequence
.getNextStep(step
);
83 public ModuleWizardStep
getPreviousStep(ModuleWizardStep step
) {
84 if (myCommonSteps
.contains(step
)) {
85 final int idx
= myCommonSteps
.indexOf(step
);
87 return myCommonSteps
.get(idx
- 1);
89 if (myParentSequence
!= null) {
90 final List
<ModuleWizardStep
> commonSteps
= myParentSequence
.getCommonSteps();
91 if (!commonSteps
.isEmpty()) {
92 return commonSteps
.get(commonSteps
.size() - 1);
96 final StepSequence stepSequence
= mySpecificSteps
.get(myType
);
97 return stepSequence
!= null ? stepSequence
.getPreviousStep(step
) : null;
100 public void setType(@NonNls final String type
) {
102 myType
= ModuleType
.EMPTY
.getId();
108 public String
getSelectedType() {