IDEA-57233 Editor font antialising/appearance problems on Linux

Made storing bundled jdks paths in config as relative to idea home
Updated JDK switcher, MacLauncher, idea.sh to use relative paths for jdk bundles
This commit is contained in:
Alexey Ushakov
2015-12-15 16:54:19 +03:00
parent f8a90871b4
commit d464b40846
6 changed files with 40 additions and 23 deletions
+3
View File
@@ -61,6 +61,9 @@ if [ -n "$@@product_uc@@_JDK" -a -x "$@@product_uc@@_JDK/bin/java" ]; then
JDK="$@@product_uc@@_JDK"
elif [ -s "$HOME/.@@system_selector@@/config/@@vm_options@@.jdk" ]; then
JDK=`$CAT $HOME/.@@system_selector@@/config/@@vm_options@@.jdk`
if [ ! -d $JDK ]; then
JDK=$IDE_HOME/$JDK
fi
elif [ -x "$IDE_HOME/jre/jre/bin/java" ] && "$IDE_HOME/jre/jre/bin/java" -version > /dev/null 2>&1 ; then
JDK="$IDE_HOME/jre"
elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
+5
View File
@@ -236,6 +236,11 @@ NSBundle *findMatchingVm() {
NSString *pathForFile = [NSString stringWithFormat:@"%@/%@.jdk", getPreferencesFolderPath(), getExecutable()];
if (!pathForFile.isAbsolutePath) {
// Handle relative paths
pathForFile = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:pathForFile];
}
if ([fileManager fileExistsAtPath:pathForFile]){
NSString* fileContents = [NSString stringWithContentsOfFile:pathForFile encoding:NSUTF8StringEncoding error:nil];
NSArray* allLinedStrings = [fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
@@ -58,7 +58,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
@NotNull
private static File getBundledJDKFile() {
StringBuilder bundledJDKPath = new StringBuilder(PathManager.getHomePath() + File.separator + "jre");
StringBuilder bundledJDKPath = new StringBuilder("jre");
if (SystemInfo.isMac) {
bundledJDKPath.append(File.separator).append("jdk");
}
@@ -75,16 +75,17 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
e.getPresentation().setText("Switch Boot JDK");
}
public static List<JdkBundle> getBundlesFromFile(@NotNull File fileWithBundles) {
private static List<JdkBundle> getBundlesFromFile(@NotNull File fileWithBundles) {
List<JdkBundle> list = new ArrayList<JdkBundle>();
try {
for (String line : FileUtil.loadLines(fileWithBundles, "UTF-8")) {
File file = new File(line);
if (file.exists()) {
list.add(JdkBundle.createBundle(file, false, false));
File storedFile = new File(line);
final boolean isBundled = !storedFile.isAbsolute();
File actualFile = isBundled ? new File(PathManager.getHomePath(), storedFile.getPath()) : storedFile;
if (actualFile.exists()) {
list.add(JdkBundle.createBundle(storedFile, false, isBundled));
}
}
} catch (IllegalStateException e) {
// The device builders can throw IllegalStateExceptions if
// build gets called before everything is properly setup
@@ -118,7 +119,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
try {
//noinspection IOResourceOpenedButNotSafelyClosed
fooWriter = new FileWriter(productJdkConfigFile, false);
fooWriter.write(selectedJdkBundleFile.getAbsolutePath());
fooWriter.write(selectedJdkBundleFile.getPath());
}
catch (IOException e) {
LOG.error(e);
@@ -141,7 +142,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
@NotNull private final ComboBox myComboBox;
protected SwitchBootJdkDialog(@Nullable Project project, final List<JdkBundle> jdkBundlesList) {
private SwitchBootJdkDialog(@Nullable Project project, final List<JdkBundle> jdkBundlesList) {
super(project, false);
final JdkBundleList pathsList = findJdkPaths();
@@ -223,7 +224,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
}
public File getSelectedFile() {
return ((JdkBundle)myComboBox.getSelectedItem()).getBundleAsFile();
return ((JdkBundle)myComboBox.getSelectedItem()).getLocation();
}
}
@@ -247,7 +248,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
jdkBundleList.addBundle(bootJdk, true);
}
if (bundledJdkFile.exists()) {
if (new File(PathManager.getHomePath() + File.separator + bundledJdkFile).exists()) {
JdkBundle bundledJdk = JdkBundle.createBundle(bundledJdkFile, false, true);
if (bundledJdk != null) {
jdkBundleList.addBundle(bundledJdk, true);
@@ -18,6 +18,7 @@ package com.intellij.util;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.util.ExecUtil;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
@@ -63,10 +64,12 @@ public class JdkBundle {
@Nullable
static JdkBundle createBundle(@NotNull File jvm, @NotNull String homeSubPath, boolean boot, boolean bundled) {
File javaHome = SystemInfo.isMac ? new File(jvm, homeSubPath) : jvm;
if (bundled) javaHome = new File(PathManager.getHomePath(), javaHome.getPath());
boolean hasToolsJar = new File(javaHome, "lib" + File.separator + "tools.jar").exists();
if (!SystemInfo.isMac && !hasToolsJar) return null; // Skip jre
Pair<String, Pair<Version, Integer>> nameVersionAndUpdate = getJDKNameVersionAndUpdate(jvm, homeSubPath);
File absJvmLocation = bundled ? new File(PathManager.getHomePath(), jvm.getPath()) : jvm;
Pair<String, Pair<Version, Integer>> nameVersionAndUpdate = getJDKNameVersionAndUpdate(absJvmLocation, homeSubPath);
if (SystemInfo.isMac && nameVersionAndUpdate.second != null && nameVersionAndUpdate.second.first.isOrGreaterThan(1, 7) && !hasToolsJar)
return null; // Skip jre
@@ -90,7 +93,12 @@ public class JdkBundle {
}
@NotNull
public File getBundleAsFile() {
File getAbsoluteLocation() {
return myBundled ? new File(PathManager.getHomePath(), myBundleAsFile.getPath()) : myBundleAsFile;
}
@NotNull
public File getLocation() {
return myBundleAsFile;
}
@@ -33,7 +33,7 @@ public class JdkBundleList {
private HashMap<String, JdkBundle> nameVersionMap = new HashMap<String, JdkBundle>();
public void addBundle(@NotNull JdkBundle bundle, boolean forceOldVersion) {
JdkBundle bundleDescr = bundleMap.get(bundle.getBundleAsFile().getAbsolutePath());
JdkBundle bundleDescr = bundleMap.get(bundle.getAbsoluteLocation().getAbsolutePath());
if (bundleDescr == null) {
addMostRecent(bundle, forceOldVersion);
}
@@ -59,14 +59,14 @@ public class JdkBundleList {
else if (!latestJdk.isBoot() && !latestJdk.isBundled()) { // preserve boot and bundled versions
bundleList.remove(latestJdk);
nameVersionMap.remove(latestJdk.getNameVersion());
bundleMap.remove(latestJdk.getBundleAsFile().getAbsolutePath());
bundleMap.remove(latestJdk.getAbsoluteLocation().getAbsolutePath());
}
}
}
}
bundleList.add(bundleDescriptor);
bundleMap.put(bundleDescriptor.getBundleAsFile().getAbsolutePath(), bundleDescriptor);
bundleMap.put(bundleDescriptor.getAbsoluteLocation().getAbsolutePath(), bundleDescriptor);
if (updateVersionMap) {
nameVersionMap.put(bundleDescriptor.getNameVersion(), bundleDescriptor);
@@ -76,7 +76,7 @@ public class JdkBundleTest {
for (File file : jdk6Files) {
testPassed = false;
for (JdkBundle bundle : bundles) {
if (FileUtil.filesEqual(bundle.getBundleAsFile(), file)) {
if (FileUtil.filesEqual(bundle.getAbsoluteLocation(), file)) {
testPassed = true;
break;
}
@@ -110,8 +110,8 @@ public class JdkBundleTest {
ArrayList<JdkBundle> bundles = jdkBundleList.toArrayList();
for (JdkBundle bundle : bundles) {
assertTrue("jre \"" + bundle.getBundleAsFile().getAbsolutePath() + "\" found among jdk bundles",
new File(bundle.getBundleAsFile(), "Contents/Home/lib/tools.jar").exists());
assertTrue("jre \"" + bundle.getAbsoluteLocation().getAbsolutePath() + "\" found among jdk bundles",
new File(bundle.getAbsoluteLocation(), "Contents/Home/lib/tools.jar").exists());
}
}
@@ -127,15 +127,15 @@ public class JdkBundleTest {
boolean macNonStandardJDK = SystemInfo.isMac && !new File(bootJDK, "Contents/Home").exists();
JdkBundle bundle = macNonStandardJDK
? JdkBundle.createBundle(homeJDK, "", true, true) : // the test is run under jdk with non-standard layout
JdkBundle.createBundle(bootJDK, true, true);
? JdkBundle.createBundle(homeJDK, "", true, false) : // the test is run under jdk with non-standard layout
JdkBundle.createBundle(bootJDK, true, false);
assertNotNull(bundle);
assertTrue(bundle.isBoot());
assertTrue(bundle.isBundled());
assertFalse(bundle.isBundled());
assertTrue(FileUtil.filesEqual(bundle.getBundleAsFile(), macNonStandardJDK ? homeJDK : bootJDK));
assertTrue(FileUtil.filesEqual(bundle.getAbsoluteLocation(), macNonStandardJDK ? homeJDK : bootJDK));
Pair<Version, Integer> verUpdate = bundle.getVersionUpdate();
assertNotNull(verUpdate);
@@ -161,7 +161,7 @@ public class JdkBundleTest {
assertTrue(bundle.isBoot());
assertFalse(bundle.isBundled());
assertTrue(FileUtil.filesEqual(bundle.getBundleAsFile(), macNonStandardJDK ? homeJDK : bootJDK));
assertTrue(FileUtil.filesEqual(bundle.getAbsoluteLocation(), macNonStandardJDK ? homeJDK : bootJDK));
Pair<Version, Integer> verUpdate = bundle.getVersionUpdate();
assertNotNull(verUpdate);