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;
@@ -41,7 +41,8 @@ import javax.swing.*;
* @author max
*/
public class ProjectUtil {
@NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = ".idea";
/** @deprecated use {@linkplain Project#DIRECTORY_STORE_FOLDER} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration") @NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = Project.DIRECTORY_STORE_FOLDER;
private ProjectUtil() { }
@@ -129,7 +130,7 @@ public class ProjectUtil {
public static boolean isProjectOrWorkspaceFile(final VirtualFile file,
final FileType fileType) {
if (fileType instanceof InternalFileType) return true;
return file.getPath().contains("/"+ DIRECTORY_BASED_PROJECT_DIR +"/");
return file.getPath().contains("/"+ Project.DIRECTORY_STORE_FOLDER +"/");
}
@NotNull
@@ -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.
@@ -28,7 +28,6 @@ import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.progress.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -168,7 +167,7 @@ class PrintManager {
if(isRecursive) {
PsiDirectory[] directories = psiDirectory.getSubdirectories();
for (PsiDirectory directory : directories) {
if (!ProjectUtil.DIRECTORY_BASED_PROJECT_DIR.equals(directory.getName())) {
if (!Project.DIRECTORY_STORE_FOLDER.equals(directory.getName())) {
addToPsiFileList(directory, filesList, isRecursive);
}
}
@@ -199,7 +198,7 @@ class PrintManager {
pageFormat.setOrientation(PageFormat.LANDSCAPE);
paperWidth -= topMargin + bottomMargin;
paperHeight -= leftMargin + rightMargin;
paper.setImageableArea(topMargin, rightMargin, paperWidth, paperHeight);
paper.setImageableArea(rightMargin, topMargin, paperWidth, paperHeight);
}
pageFormat.setPaper(paper);
return pageFormat;
@@ -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.
@@ -29,6 +29,7 @@ import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.impl.ModuleManagerImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.util.Condition;
@@ -82,7 +83,7 @@ public class ConversionContextImpl implements ConversionContext {
if (myProjectFile.isDirectory()) {
myStorageScheme = StorageScheme.DIRECTORY_BASED;
myProjectBaseDir = myProjectFile;
mySettingsBaseDir = new File(myProjectBaseDir.getAbsolutePath(), ".idea");
mySettingsBaseDir = new File(myProjectBaseDir.getAbsolutePath(), Project.DIRECTORY_STORE_FOLDER);
modulesFile = new File(mySettingsBaseDir, "modules.xml");
myWorkspaceFile = new File(mySettingsBaseDir, "workspace.xml");
}
@@ -61,7 +61,8 @@ public class ModuleDeleteProvider implements DeleteProvider, TitledHandler {
for (Module module : modules) {
final File moduleFile = new File(module.getModuleFilePath());
final File projectFile = new File(module.getProject().getProjectFilePath());
if (moduleFile.getParent().equals(projectFile.getParent()) && moduleFile.getParentFile().getName().equals(".idea")) {
if (moduleFile.getParent().equals(projectFile.getParent()) &&
moduleFile.getParentFile().getName().equals(Project.DIRECTORY_STORE_FOLDER)) {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 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.
@@ -49,7 +49,7 @@ public class PlatformProjectViewStructureProvider implements TreeStructureProvid
for (AbstractTreeNode moduleChild : moduleChildren) {
if (moduleChild instanceof PsiDirectoryNode) {
final PsiDirectory value = ((PsiDirectoryNode)moduleChild).getValue();
if (value.getName().equals(".idea") && Registry.is("projectView.hide.dot.idea")) {
if (value.getName().equals(Project.DIRECTORY_STORE_FOLDER) && Registry.is("projectView.hide.dot.idea")) {
continue;
}
}
@@ -24,7 +24,6 @@ import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerAdapter;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
@@ -77,7 +76,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
}
if (myState.lastPath != null) {
File lastFile = new File(myState.lastPath);
if (lastFile.isDirectory() && !new File(lastFile, ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) {
if (lastFile.isDirectory() && !new File(lastFile, Project.DIRECTORY_STORE_FOLDER).exists()) {
myState.lastPath = null;
}
}
@@ -246,7 +245,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
public static boolean isValidProjectPath(String projectPath) {
final File file = new File(projectPath);
return file.exists() && (!file.isDirectory() || new File(file, ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists());
return file.exists() && (!file.isDirectory() || new File(file, Project.DIRECTORY_STORE_FOLDER).exists());
}
private class MyProjectManagerListener extends ProjectManagerAdapter {
@@ -102,7 +102,7 @@ public class ProjectUtil {
}
if (path.endsWith(ProjectFileType.DOT_DEFAULT_EXTENSION) ||
virtualFile.isDirectory() && virtualFile.findChild(com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR) != null) {
virtualFile.isDirectory() && virtualFile.findChild(Project.DIRECTORY_STORE_FOLDER) != null) {
return openProject(path, projectToClose, forceOpenInNewFrame);
}
@@ -145,8 +145,9 @@ public class ProjectUtil {
return null;
}
if (file.isDirectory() && !new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) {
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle());
if (file.isDirectory() && !new File(file, Project.DIRECTORY_STORE_FOLDER).exists()) {
String message = IdeBundle.message("error.project.file.does.not.exist", new File(file, Project.DIRECTORY_STORE_FOLDER).getPath());
Messages.showErrorDialog(message, CommonBundle.getErrorTitle());
return null;
}
@@ -285,7 +285,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
final VirtualFile baseDir = getProjectBaseDir();
assert baseDir != null : "project file: " + getProjectFile();
final VirtualFile ideaDir = baseDir.findChild(".idea");
final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
if (ideaDir != null && ideaDir.isValid()) {
final VirtualFile nameFile = ideaDir.findChild(".name");
if (nameFile != null && nameFile.isValid()) {
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.projectImport.ProjectAttachProcessor;
@@ -93,7 +94,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
if (!baseDir.isDirectory()) {
baseDir = virtualFile.getParent();
while (baseDir != null) {
if (new File(baseDir.getPath(), ".idea").exists()) {
if (new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER).exists()) {
break;
}
baseDir = baseDir.getParent();
@@ -103,7 +104,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
}
}
final File projectDir = new File(baseDir.getPath(), ".idea");
final File projectDir = new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER);
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (!forceOpenInNewFrame && openProjects.length > 0) {
@@ -405,7 +405,7 @@ show.diff.progress.title=Loading content...
show.diff.progress.title.detailed=Loading content for {0}
checkout.open.project.prompt=You have checked out {0} project file:\n{1}\nWould you like to open it?
checkout.open.project.dir.prompt=You have checked out {0} project:\n{1}\nWould you like to open it?
checkout.title=Checkout from Version Control
checkout.title=Checkout From Version Control
checkout.create.project.prompt=Would you like to create {0} project for the sources you have checked out to {1}?
checkout.open.directory.prompt=Would you like to open the directory {0}?
new.changelist.duplicate.name.error=A changelist with that name already exists
@@ -40,7 +40,7 @@ import java.io.IOException;
*/
public class CoreProjectLoader {
public static void loadProject(MockProject project, @NotNull VirtualFile virtualFile) throws IOException, JDOMException {
if (virtualFile.isDirectory() && virtualFile.findChild(".idea") != null) {
if (virtualFile.isDirectory() && virtualFile.findChild(Project.DIRECTORY_STORE_FOLDER) != null) {
project.setBaseDir(virtualFile);
loadDirectoryProject(project, virtualFile);
}
@@ -51,7 +51,7 @@ public class CoreProjectLoader {
}
private static void loadDirectoryProject(Project project, VirtualFile projectDir) throws IOException, JDOMException {
VirtualFile dotIdea = projectDir.findChild(".idea");
VirtualFile dotIdea = projectDir.findChild(Project.DIRECTORY_STORE_FOLDER);
VirtualFile modulesXml = dotIdea.findChild("modules.xml");
StorageData storageData = loadStorageFile(project, modulesXml);
final Element moduleManagerState = storageData.getState("ProjectModuleManager");
@@ -21,6 +21,7 @@ import com.intellij.application.options.ReplacePathToMacroMap;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -67,7 +68,7 @@ public class ModulePathMacroManager extends BasePathMacroManager {
// rather than the .idea directory itself is considered the module root
// (so that a Ruby IDE project doesn't break if its directory is moved together with the .idea directory)
File moduleDirParent = moduleDirFile.getParentFile();
if (moduleDirParent != null && moduleDirFile.getName().equals(".idea")) {
if (moduleDirParent != null && moduleDirFile.getName().equals(Project.DIRECTORY_STORE_FOLDER)) {
moduleDirFile = moduleDirParent;
}
String moduleDir = moduleDirFile.getPath();
@@ -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 org.jetbrains.plugins.github;
import com.intellij.notification.Notification;
@@ -285,7 +300,7 @@ public class GithubShareAction extends DumbAwareAction {
}
for (VirtualFile file : changeListManager.getUnversionedFiles()) {
if (file.getPath().contains(".idea")) {
if (file.getPath().contains(Project.DIRECTORY_STORE_FOLDER)) {
continue;
}
if (readmeFile != null && readmeFile.equals(file)) {