mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-156888 Simplify JDK setup for new projects
This commit is contained in:
@@ -44,6 +44,7 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -321,9 +322,9 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
SdkType[] types = SdkType.getAllTypes();
|
||||
for (SdkType type : types) {
|
||||
if (sdkTypeFilter == null || sdkTypeFilter.value(type) && ContainerUtil.find(jdks, sdk -> sdk.getSdkType() == type) == null) {
|
||||
String homePath = type.suggestHomePath();
|
||||
if (homePath != null && type.isValidSdkHome(homePath)) {
|
||||
addElement(new SuggestedJdkItem(type, homePath));
|
||||
Collection<String> paths = type.suggestHomePaths();
|
||||
for (String path : paths) {
|
||||
addElement(new SuggestedJdkItem(type, path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.roots.AnnotationOrderRootType;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.RootProvider;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -263,6 +264,7 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
scanFolder(new File(anotherJavasFolder, javasFolder.getName()), result);
|
||||
}
|
||||
}
|
||||
result.sort((o1, o2) -> Comparing.compare(JdkVersionUtil.getVersion(o2), JdkVersionUtil.getVersion(o1)));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.roots;
|
||||
|
||||
import com.intellij.openapi.roots.ui.configuration.JdkComboBox;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class JdkComboBoxTest extends LightPlatformTestCase {
|
||||
|
||||
public void testSuggestedSdks() throws Exception {
|
||||
JdkComboBox comboBox = new JdkComboBox(new ProjectSdksModel(), null, null, null, true);
|
||||
Object itemAt = comboBox.getItemAt(0);
|
||||
System.out.println(itemAt);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class JavaModuleBuilder extends ModuleBuilder implements SourcePathsBuild
|
||||
|
||||
@Override
|
||||
public boolean isSuitableSdkType(SdkTypeId sdkType) {
|
||||
return sdkType instanceof JavaSdkType;
|
||||
return sdkType instanceof JavaSdk;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user