mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-32093 more clean and correct way to set/get working dir
This commit is contained in:
+18
-13
@@ -22,8 +22,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
@@ -184,24 +186,18 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
|
||||
@Override
|
||||
public void setWorkingDirectory(@Nullable String value) {
|
||||
String normalizedValue = StringUtil.isEmptyOrSpaces(value) ? null : FileUtilRt.toSystemIndependentName(value.trim());
|
||||
if (normalizedValue != null && normalizedValue.equals(getProject().getBasePath())) {
|
||||
normalizedValue = null;
|
||||
}
|
||||
|
||||
String normalizedValue = StringUtil.isEmptyOrSpaces(value) ? null : value.trim();
|
||||
//noinspection deprecation
|
||||
WORKING_DIRECTORY = normalizedValue;
|
||||
getOptions().setWorkingDirectory(normalizedValue);
|
||||
WORKING_DIRECTORY = PathUtil.toSystemDependentName(normalizedValue);
|
||||
|
||||
String independentValue = PathUtil.toSystemIndependentName(normalizedValue);
|
||||
getOptions().setWorkingDirectory(Comparing.equal(independentValue, getProject().getBasePath()) ? null : independentValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorkingDirectory() {
|
||||
//noinspection deprecation
|
||||
String workingDirectory = WORKING_DIRECTORY;
|
||||
if (workingDirectory == null) {
|
||||
return PathUtil.toSystemDependentName(getProject().getBasePath());
|
||||
}
|
||||
return ExternalizablePath.localPathValue(workingDirectory);
|
||||
return WORKING_DIRECTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,9 +289,18 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
super.readExternal(element);
|
||||
|
||||
ApplicationConfigurationOptions options = getOptions();
|
||||
|
||||
String workingDirectory = options.getWorkingDirectory();
|
||||
if (workingDirectory == null) {
|
||||
workingDirectory = PathUtil.toSystemDependentName(getProject().getBasePath());
|
||||
}
|
||||
else {
|
||||
workingDirectory = FileUtilRt.toSystemDependentName(VirtualFileManager.extractPath(workingDirectory));
|
||||
}
|
||||
|
||||
MAIN_CLASS_NAME = options.getMainClassName();
|
||||
PROGRAM_PARAMETERS = options.getProgramParameters();
|
||||
WORKING_DIRECTORY = options.getWorkingDirectory();
|
||||
WORKING_DIRECTORY = workingDirectory;
|
||||
ALTERNATIVE_JRE_PATH = options.getAlternativeJrePath();
|
||||
ALTERNATIVE_JRE_PATH_ENABLED = options.isAlternativeJrePathEnabled();
|
||||
ENABLE_SWING_INSPECTOR = options.isSwingInspectorEnabled();
|
||||
|
||||
Reference in New Issue
Block a user