replace some hardcoded .idea literals with references

This commit is contained in:
peter
2013-06-18 10:55:15 +02:00
parent 0da29e248e
commit d6ffb1205c
8 changed files with 12 additions and 9 deletions
@@ -19,6 +19,7 @@ import com.intellij.ide.util.projectWizard.WizardInputField;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.JDOMUtil;
@@ -43,8 +44,8 @@ import java.util.zip.ZipInputStream;
*/
public class LocalArchivedTemplate extends ArchivedProjectTemplate {
public static final String DESCRIPTION_PATH = ".idea/description.html";
static final String IDEA_INPUT_FIELDS_XML = ".idea/project-template.xml";
public static final String DESCRIPTION_PATH = Project.DIRECTORY_STORE_FOLDER + "/description.html";
static final String IDEA_INPUT_FIELDS_XML = Project.DIRECTORY_STORE_FOLDER + "/project-template.xml";
private final URL myArchivePath;
private final ModuleType myModuleType;
@@ -162,7 +162,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
if (relativePath == null) {
throw new RuntimeException("Can't find relative path for " + virtualFile);
}
final boolean system = ".idea".equals(virtualFile.getParent().getName());
final boolean system = Project.DIRECTORY_STORE_FOLDER.equals(virtualFile.getParent().getName());
if (system) {
if (!fileName.equals("description.html") &&
!fileName.equals(PROJECT_TEMPLATE_XML) &&
@@ -53,7 +53,7 @@ public class SystemFileProcessor extends ProjectTemplateFileProcessor {
@Override
protected String encodeFileText(String content, VirtualFile file, Project project) throws IOException {
final String fileName = file.getName();
if (file.getParent().getName().equals(".idea") && fileName.equals("workspace.xml")) {
if (file.getParent().getName().equals(Project.DIRECTORY_STORE_FOLDER) && fileName.equals("workspace.xml")) {
List<Object> componentList = new ArrayList<Object>();
for (String componentName : COMPONENT_NAMES) {
@@ -205,7 +205,7 @@ public class TemplateModuleBuilder extends ModuleBuilder {
@Nullable
@Override
public String fun(String path) {
if (moduleMode && path.contains(".idea")) return null;
if (moduleMode && path.contains(Project.DIRECTORY_STORE_FOLDER)) return null;
if (basePackage != null) {
return path.replace(getPathFragment(basePackage.getDefaultValue()), getPathFragment(basePackage.getValue()));
}
@@ -23,13 +23,14 @@ package com.intellij.projectImport;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.project.Project;
import javax.swing.*;
public class ProjectFormatPanel {
private static final String STORAGE_FORMAT_PROPERTY = "default.storage.format";
public static final String DIR_BASED = ".idea (directory based)";
public static final String DIR_BASED = Project.DIRECTORY_STORE_FOLDER + " (directory based)";
private static final String FILE_BASED = ".ipr (file based)";
private JComboBox myStorageFormatCombo;
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
* Project interface class.
*/
public interface Project extends ComponentManager, AreaInstance {
@NonNls String DIRECTORY_STORE_FOLDER = ".idea";
@NonNls String DIRECTORY_STORE_FOLDER = ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR;
/**
* Returns a name ot the project. For a directory-based project it's an arbitrary string specified by user at project creation
@@ -26,6 +26,7 @@ package com.intellij.openapi.application.ex;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.module.impl.ModuleManagerImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -387,7 +388,7 @@ public class PathManagerEx {
}
ourCommunityModules = new THashSet<String>();
File modulesXml = findFileUnderCommunityHome(".idea/modules.xml");
File modulesXml = findFileUnderCommunityHome(Project.DIRECTORY_STORE_FOLDER + "/modules.xml");
if (!modulesXml.exists()) {
throw new IllegalStateException("Cannot obtain test data path: " + modulesXml.getAbsolutePath() + " not found");
}
@@ -52,7 +52,7 @@ public abstract class DefaultVcsRootPolicy {
final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
boolean isDirectoryBased = StorageScheme.DIRECTORY_BASED.equals(storageScheme);
final String[] parts = new String[] {"Content roots of all modules", "all immediate descendants of project base directory",
".idea directory contents"};
Project.DIRECTORY_STORE_FOLDER + " directory contents"};
final StringBuilder sb = new StringBuilder(parts[0]);
if (isDirectoryBased) {
sb.append(", ");