mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DBE-3157 2016.3 EAP uses .DataGrip2016.2 folder as default place for Project Folder
This commit is contained in:
@@ -16,9 +16,11 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -99,35 +101,54 @@ public abstract class RecentProjectsManagerBase extends RecentProjectsManager im
|
||||
|
||||
// TODO Should be removed later (required to convert the already saved system-dependent paths).
|
||||
private void makePathsSystemIndependent() {
|
||||
makeSystemIndependent(recentPaths);
|
||||
ApplicationInfo appInfo = ApplicationInfo.getInstance();
|
||||
String version = appInfo.getMajorVersion() + "." + appInfo.getMinorVersion();
|
||||
PathMacroManager pathMacroManager = PathMacroManager.getInstance(ApplicationManager.getApplication());
|
||||
Function<String, String> convert = depPath -> {
|
||||
String result = PathUtil.toSystemIndependentName(depPath);
|
||||
if (!result.startsWith("$APP") && result.contains("2017.1")) {
|
||||
String migrated = result.replace("2017.1", version);
|
||||
// check for possible PathMacroUtil.APPLICATION_*
|
||||
if (pathMacroManager.collapsePath(migrated).startsWith("$APP")) {
|
||||
return migrated;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
Consumer<List<String>> convertList = o -> {
|
||||
for (ListIterator<String> it = o.listIterator(); it.hasNext(); ) {
|
||||
it.set(convert.fun(it.next()));
|
||||
}
|
||||
};
|
||||
|
||||
makeSystemIndependent(openPaths);
|
||||
convertList.consume(recentPaths);
|
||||
convertList.consume(openPaths);
|
||||
|
||||
Map<String, String> namesCopy = new HashMap<>(names);
|
||||
names.clear();
|
||||
for (Map.Entry<String, String> entry : namesCopy.entrySet()) {
|
||||
names.put(PathUtil.toSystemIndependentName(entry.getKey()), entry.getValue());
|
||||
names.put(convert.fun(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
for (ProjectGroup group : groups) {
|
||||
List<String> paths = new ArrayList<>(group.getProjects());
|
||||
makeSystemIndependent(paths);
|
||||
convertList.consume(paths);
|
||||
group.save(paths);
|
||||
}
|
||||
|
||||
if (lastPath != null) {
|
||||
lastPath = PathUtil.toSystemIndependentName(lastPath);
|
||||
lastPath = convert.fun(lastPath);
|
||||
}
|
||||
|
||||
Map<String, RecentProjectMetaInfo> additionalInfoCopy = new HashMap<>(additionalInfo);
|
||||
additionalInfo.clear();
|
||||
for (Map.Entry<String, RecentProjectMetaInfo> entry : additionalInfoCopy.entrySet()) {
|
||||
entry.getValue().binFolder = PathUtil.toSystemIndependentName(entry.getValue().binFolder);
|
||||
additionalInfo.put(PathUtil.toSystemIndependentName(entry.getKey()), entry.getValue());
|
||||
entry.getValue().binFolder = convert.fun(entry.getValue().binFolder);
|
||||
additionalInfo.put(convert.fun(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
if (lastProjectLocation != null) {
|
||||
lastProjectLocation = PathUtil.toSystemIndependentName(lastProjectLocation);
|
||||
lastProjectLocation = convert.fun(lastProjectLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,14 +161,6 @@ public abstract class RecentProjectsManagerBase extends RecentProjectsManager im
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void makeSystemIndependent(List<String> paths) {
|
||||
List<String> copy = new ArrayList<>(paths);
|
||||
paths.clear();
|
||||
for (String path : copy) {
|
||||
paths.add(PathUtil.toSystemIndependentName(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Object myStateLock = new Object();
|
||||
|
||||
Reference in New Issue
Block a user