Use constant

This commit is contained in:
Roman Shevchenko
2012-05-22 19:02:50 +04:00
parent 37598c0a01
commit c3b3603256
18 changed files with 79 additions and 46 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,12 +79,12 @@ public class NewProjectUtil {
try {
if (StorageScheme.DIRECTORY_BASED == dialog.getStorageScheme()) {
final File ideaDir = new File(projectFilePath + File.separator + ".idea");
final File ideaDir = new File(projectFilePath, Project.DIRECTORY_STORE_FOLDER);
if (!ideaDir.exists() && !ideaDir.mkdirs()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project initialization failed");
Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project Initialization Failed");
}
});
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSources
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.projectImport.ProjectFormatPanel;
@@ -111,7 +112,7 @@ public class ProjectNameStep extends ModuleWizardStep {
return getProjectFileDirectory() + "/" + myNamePathComponent.getNameValue() + ProjectFileType.DOT_DEFAULT_EXTENSION;
}
else {
return getProjectFileDirectory() + "/" + ".idea";
return getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER;
}
}
else {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.ide.highlighter.ProjectFileType;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -118,18 +118,17 @@ public class ProjectNameStep extends ModuleWizardStep {
boolean shouldContinue = true;
final String path = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED
? getProjectFileDirectory() + "/" + ProjectUtil.DIRECTORY_BASED_PROJECT_DIR
: getProjectFilePath();
? getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER : getProjectFilePath();
final File projectFile = new File(path);
if (projectFile.exists()) {
final String title = myWizardContext.isCreatingNewProject()
? IdeBundle.message("title.new.project")
: IdeBundle.message("title.add.module");
final String message = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED
? IdeBundle.message("prompt.overwrite.project.folder", ProjectUtil.DIRECTORY_BASED_PROJECT_DIR,
projectFile.getParentFile().getAbsolutePath())
: IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(),
myWizardContext.getPresentationName());
? IdeBundle.message("prompt.overwrite.project.folder",
Project.DIRECTORY_STORE_FOLDER, projectFile.getParentFile().getAbsolutePath())
: IdeBundle.message("prompt.overwrite.project.file",
projectFile.getAbsolutePath(), myWizardContext.getPresentationName());
int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
shouldContinue = answer == 0;
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.vcs.checkout;
import com.intellij.ide.impl.ProjectUtil;
@@ -9,16 +24,15 @@ import java.io.File;
/**
* @author irengrig
* Date: 5/27/11
* Time: 12:57 PM
* @since 5/27/11
*/
public class ProjectDirCheckoutListener implements CheckoutListener {
@Override
public boolean processCheckedOutDirectory(Project project, File directory) {
if (new File(directory, ".idea").exists()) {
int rc = Messages
.showYesNoDialog(project, VcsBundle.message("checkout.open.project.dir.prompt", ProjectCheckoutListener.getProductNameWithArticle(),
directory.getPath()), VcsBundle.message("checkout.title"), Messages.getQuestionIcon());
if (new File(directory, Project.DIRECTORY_STORE_FOLDER).exists()) {
String message = VcsBundle.message("checkout.open.project.dir.prompt",
ProjectCheckoutListener.getProductNameWithArticle(), directory.getPath());
int rc = Messages.showYesNoDialog(project, message, VcsBundle.message("checkout.title"), Messages.getQuestionIcon());
if (rc == 0) {
ProjectUtil.openProject(directory.getPath(), project, false);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -151,7 +151,7 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
}
wizardContext.setProjectJdk(jdk);
final String dotIdeaFilePath = wizardContext.getProjectFileDirectory() + File.separator + ".idea";
final String dotIdeaFilePath = wizardContext.getProjectFileDirectory() + File.separator + Project.DIRECTORY_STORE_FOLDER;
final String projectFilePath = wizardContext.getProjectFileDirectory() + File.separator + wizardContext.getProjectName() +
ProjectFileType.DOT_DEFAULT_EXTENSION;