allow to double-click on project type step (IDEADEV-40685)
[fedora-idea.git] / platform / lang-api / src / com / intellij / ide / util / projectWizard / WizardContext.java
blob7a92d4007167c6d01e9224471518bc64867e9e68
1 /*
2 * Copyright 2000-2007 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.
16 package com.intellij.ide.util.projectWizard;
18 import com.intellij.ide.GeneralSettings;
19 import com.intellij.ide.IdeBundle;
20 import com.intellij.openapi.application.ApplicationNamesInfo;
21 import com.intellij.openapi.components.StorageScheme;
22 import com.intellij.openapi.project.Project;
23 import com.intellij.openapi.projectRoots.Sdk;
24 import com.intellij.openapi.roots.ProjectRootManager;
25 import com.intellij.util.SystemProperties;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
29 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.List;
33 public class WizardContext {
34 /**
35 * a project where the module should be added, can be null => the wizard creates a new project
37 @Nullable
38 private final Project myProject;
39 private String myProjectFileDirectory;
40 private String myProjectName;
41 private String myCompilerOutputDirectory;
42 private Sdk myProjectJdk;
43 private ProjectBuilder myProjectBuilder;
44 private final List<Listener> myListeners = new ArrayList<Listener>();
45 private StorageScheme myProjectStorageFormat = StorageScheme.DEFAULT;
47 public void setProjectStorageFormat(StorageScheme format) {
48 myProjectStorageFormat = format;
51 public interface Listener {
52 void buttonsUpdateRequested();
53 void nextStepRequested();
56 public WizardContext(Project project) {
57 myProject = project;
58 if (myProject != null){
59 myProjectJdk = ProjectRootManager.getInstance(myProject).getProjectJdk();
63 @Nullable
64 public Project getProject() {
65 return myProject;
68 @NotNull
69 public String getProjectFileDirectory() {
70 if (myProjectFileDirectory != null) {
71 return myProjectFileDirectory;
73 final String lastProjectLocation = GeneralSettings.getInstance().getLastProjectLocation();
74 if (lastProjectLocation != null) {
75 return lastProjectLocation.replace('/', File.separatorChar);
77 final String userHome = SystemProperties.getUserHome();
78 //noinspection HardCodedStringLiteral
79 return userHome.replace('/', File.separatorChar) + File.separator + ApplicationNamesInfo.getInstance().getLowercaseProductName() +
80 "Projects";
83 public void setProjectFileDirectory(String projectFileDirectory) {
84 myProjectFileDirectory = projectFileDirectory;
87 public String getCompilerOutputDirectory() {
88 return myCompilerOutputDirectory;
91 public void setCompilerOutputDirectory(final String compilerOutputDirectory) {
92 myCompilerOutputDirectory = compilerOutputDirectory;
95 public String getProjectName() {
96 return myProjectName;
99 public void setProjectName(String projectName) {
100 myProjectName = projectName;
103 public boolean isCreatingNewProject() {
104 return myProject == null;
107 public void requestWizardButtonsUpdate() {
108 final Listener[] listeners = myListeners.toArray(new Listener[myListeners.size()]);
109 for (Listener listener : listeners) {
110 listener.buttonsUpdateRequested();
114 public void requestNextStep() {
115 final Listener[] listeners = myListeners.toArray(new Listener[myListeners.size()]);
116 for (Listener listener : listeners) {
117 listener.nextStepRequested();
121 public void addContextListener(Listener listener) {
122 myListeners.add(listener);
125 public void removeContextListener(Listener listener) {
126 myListeners.remove(listener);
129 public void setProjectJdk(Sdk jdk) {
130 myProjectJdk = jdk;
133 public Sdk getProjectJdk() {
134 return myProjectJdk;
137 public ProjectBuilder getProjectBuilder() {
138 return myProjectBuilder;
141 public void setProjectBuilder(final ProjectBuilder projectBuilder) {
142 myProjectBuilder = projectBuilder;
145 public String getPresentationName() {
146 return myProject == null ? IdeBundle.message("project.new.wizard.project.identification") : IdeBundle.message("project.new.wizard.module.identification");
149 public StorageScheme getProjectStorageFormat() {
150 return myProjectStorageFormat;