/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.vfs.CharsetToolkit;
VirtualFile homeDirectory = jdk.getHomeDirectory();
if (homeDirectory == null) return null;
- VirtualFile rtJar = homeDirectory.findFileByRelativePath("jre/lib/rt.jar");
- if (rtJar == null) {
- rtJar = homeDirectory.findFileByRelativePath("lib/rt.jar");
- }
- if (rtJar == null) {
- rtJar = homeDirectory.findFileByRelativePath("jre/lib/vm.jar"); // for IBM jdk
- }
- if (rtJar == null) {
- rtJar = homeDirectory.findFileByRelativePath("../Classes/classes.jar"); // for mac
- }
+ VirtualFile rtJar = homeDirectory.findFileByRelativePath("jre/lib/rt.jar"); // JDK
+ if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("lib/rt.jar"); // JRE
+ if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("jre/lib/vm.jar"); // IBM JDK
+ if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("../Classes/classes.jar"); // Apple JDK
if (rtJar == null) {
String versionString = jdk.getVersionString();
return null;
}
- public static boolean checkForJdk(final File homePath) {
+ public static boolean checkForJdk(@NotNull File homePath) {
File binPath = new File(homePath.getAbsolutePath() + File.separator + "bin");
if (!binPath.exists()) return false;
FileFilter fileFilter = new FileFilter() {
@Override
- @SuppressWarnings({"HardCodedStringLiteral"})
- public boolean accept(File f) {
+ public boolean accept(@NotNull File f) {
if (f.isDirectory()) return false;
- return Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javac") ||
- Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javah");
+ String name = FileUtil.getNameWithoutExtension(f);
+ return "javac".equals(name) || "javah".equals(name);
}
};
File[] children = binPath.listFiles(fileFilter);
checkForRuntime(homePath.getAbsolutePath());
}
- public static boolean checkForJre(String homePath) {
+ public static boolean checkForJre(@NotNull String homePath) {
homePath = new File(FileUtil.toSystemDependentName(homePath)).getAbsolutePath();
File binPath = new File(homePath + File.separator + "bin");
if (!binPath.exists()) return false;
FileFilter fileFilter = new FileFilter() {
@Override
- @SuppressWarnings({"HardCodedStringLiteral"})
- public boolean accept(File f) {
- return !f.isDirectory() && Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "java");
+ public boolean accept(@NotNull File f) {
+ return !f.isDirectory() && "java".equals(FileUtil.getNameWithoutExtension(f));
}
};
File[] children = binPath.listFiles(fileFilter);
checkForRuntime(homePath);
}
- public static boolean checkForRuntime(final String homePath) {
- return new File(new File(new File(homePath, "jre"), "lib"), "rt.jar").exists() ||
- new File(new File(homePath, "lib"), "rt.jar").exists() ||
- new File(new File(new File(homePath, ".."), "Classes"), "classes.jar").exists() || // Apple JDK
- new File(new File(new File(homePath, "jre"), "lib"), "vm.jar").exists() || // IBM JDK
- new File(homePath, "classes").isDirectory(); // custom build
+ public static boolean checkForRuntime(@NotNull String homePath) {
+ return new File(homePath, "jre/lib/rt.jar").exists() || // JDK
+ new File(homePath, "lib/rt.jar").exists() || // JRE
+ new File(homePath, "../Classes/classes.jar").exists() || // Apple JDK
+ new File(homePath, "jre/lib/vm.jar").exists() || // IBM JDK
+ new File(homePath, "classes").isDirectory(); // custom build
}
public static GeneralCommandLine setupJVMCommandLine(final String exePath,
commandLine.addParameters(javaParameters.getProgramParametersList().getList());
- commandLine.setWorkDirectory(javaParameters.getWorkingDirectory());
+ commandLine.withWorkDirectory(javaParameters.getWorkingDirectory());
return commandLine;
}
}
private static void appendEncoding(SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList parametersList) {
- // Value of -Dfile.encoding and charset of GeneralCommandLine should be in sync in order process's input and output be correctly handled.
+ // Value of file.encoding and charset of GeneralCommandLine should be in sync in order process's input and output be correctly handled.
String encoding = parametersList.getPropertyValue("file.encoding");
if (encoding == null) {
Charset charset = javaParameters.getCharset();
if (charset == null) charset = EncodingManager.getInstance().getDefaultCharset();
if (charset == null) charset = CharsetToolkit.getDefaultSystemCharset();
- commandLine.addParameter("-Dfile.encoding=" + charset.name());
- commandLine.setCharset(charset);
+ if (charset != null) {
+ commandLine.addParameter("-Dfile.encoding=" + charset.name());
+ commandLine.withCharset(charset);
+ }
}
else {
try {
Charset charset = Charset.forName(encoding);
- commandLine.setCharset(charset);
- }
- catch (UnsupportedCharsetException ignore) {
- }
- catch (IllegalCharsetNameException ignore) {
+ commandLine.withCharset(charset);
}
+ catch (UnsupportedCharsetException ignore) { }
+ catch (IllegalCharsetNameException ignore) { }
}
}
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.openapi.roots.ui.configuration.projectRoot;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Consumer;
import com.intellij.util.EventDispatcher;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.*;
/**
- * User: anna
- * Date: 05-Jun-2006
+ * @author anna
+ * @since 05-Jun-2006
*/
public class ProjectSdksModel implements SdkModel {
private static final Logger LOG = Logger.getInstance("com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel");
return myProjectSdks;
}
- public boolean isModified(){
+ public boolean isModified() {
return myModified;
}
final SdkAdditionalData sdkAdditionalData = currItem.getSdkAdditionalData();
if (sdkAdditionalData instanceof ValidatableSdkAdditionalData) {
try {
- ((ValidatableSdkAdditionalData) sdkAdditionalData).checkValid(this);
+ ((ValidatableSdkAdditionalData)sdkAdditionalData).checkValid(this);
}
catch (ConfigurationException e) {
if (rootConfigurable != null) {
final SdkType[] types = SdkType.getAllTypes();
for (final SdkType type : types) {
if (filter != null && !filter.value(type)) continue;
- final AnAction addAction = new DumbAwareAction(type.getPresentableName(),
- null,
- type.getIconForAddAction()) {
- @Override
- public void actionPerformed(AnActionEvent e) {
- doAdd(parent, type, updateTree);
- }
- };
+ final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIconForAddAction()) {
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ doAdd(parent, type, updateTree);
+ }
+ };
group.add(addAction);
}
}
if (!sdkType.setupSdkPaths(newJdk, this)) return;
if (newJdk.getVersionString() == null) {
- Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", home),
- ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
+ String message = ProjectBundle.message("sdk.java.corrupt.error", home);
+ Messages.showMessageDialog(message, ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
}
doAdd(newJdk, callback);