gradle: Add support choosing Gradle JVM
authorVladislav.Soroka <Vladislav.Soroka@jetbrains.com>
Mon, 15 Dec 2014 12:44:11 +0000 (15:44 +0300)
committerVladislav.Soroka <Vladislav.Soroka@jetbrains.com>
Mon, 15 Dec 2014 12:44:11 +0000 (15:44 +0300)
24 files changed:
platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java
platform/external-system-impl/external-system-impl.iml
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemJdkException.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemJdkUtil.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/InvalidJavaHomeException.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtensionImpl.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/callback/OpenExternalSystemSettingsCallback.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/callback/OpenProjectJdkSettingsCallback.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalSystemJdkComboBox.java
platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml
plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleModuleBuilder.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleConfigurable.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectSettingsControl.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/ImportFromGradleControl.java
plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleProjectSettings.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerPanel.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerSettings.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingConfigurable.java

index e89aa54a1238cb0afa39235511dc80aab73ec77f..3a93a5bdf9fc8ec26f0f30bc963836251f6d4dff 100644 (file)
@@ -85,6 +85,13 @@ run.text.ended.multiple.task={0}: External tasks execution finished ''{1}''.\n
 run.text.ended.single.task={0}: External task execution finished ''{1}''.\n
 run.error.undefined.task=No task to execute is specified
 
+external.system.java.internal.jre=Use Internal JRE
+external.system.java.home.env=Use JAVA_HOME
+external.system.project_jdk.not_specified=Project JDK is not specified. <a href=''{0}''>Open Project SDK Configuration</a>
+external.system.java.home.undefined=JAVA_HOME environment variable not defined
+external.system.java.home.invalid=JAVA_HOME environment variable does not point to valid JDK or JRE ({0})
+external.system.platform.sdk.invalid=Platform SDK does not point to valid JDK ({0})
+
 tasks.select.task.title=Select {0} task
 tasks.edit.task.title=Edit {0} Task
 tasks.before.run.empty=Run {0} task
index 6c7eae51ab9ec22aa9b0fb9db079700dd5dddb38..9af4560ee284b1318379727affe922ab0082092b 100644 (file)
@@ -28,20 +28,26 @@ public class ExternalSystemException extends RuntimeException {
   private final String[] myQuickFixes;
 
   public ExternalSystemException() {
-    this(null, null);
+    this(null, (Throwable)null);
   }
 
   public ExternalSystemException(@Nullable String message) {
-    this(message, null);
+    this(message, (Throwable)null);
   }
 
   public ExternalSystemException(@Nullable Throwable cause) {
     this("", cause);
   }
 
+  public ExternalSystemException(@Nullable String message, @NotNull String... quickFixes) {
+    this(message, null, quickFixes);
+  }
+
   public ExternalSystemException(@Nullable String message, @Nullable Throwable cause, @NotNull String... quickFixes) {
     super(extractMessage(message, cause));
-    myQuickFixes = quickFixes;
+    myQuickFixes = mergeArrays(cause instanceof ExternalSystemException
+                               ? ((ExternalSystemException)cause).getQuickFixes()
+                               : new String[0], quickFixes);
     if (cause == null) {
       myOriginalReason = "";
       return;
@@ -57,7 +63,7 @@ public class ExternalSystemException extends RuntimeException {
     }
     myOriginalReason = stringWriter.toString();
   }
-  
+
   /**
    * @return    textual description of the wrapped exception (if any); empty string otherwise
    */
@@ -104,7 +110,16 @@ public class ExternalSystemException extends RuntimeException {
       }
       buffer.append(m);
     }
-    
-    return buffer.toString(); 
+
+    return buffer.toString();
+  }
+
+  private static String[] mergeArrays(@NotNull String[] a1, @NotNull String[] a2) {
+    if (a1.length == 0) return a2;
+    if (a2.length == 0) return a1;
+    String[] result = new String[a1.length + a2.length];
+    System.arraycopy(a1, 0, result, 0, a1.length);
+    System.arraycopy(a2, 0, result, a1.length, a2.length);
+    return result;
   }
 }
index 1cbf68f907f9e43dd8875b948b1dcc15dce8de14..843b483bd11ce01bc09df61c27d32e5a1fd3510f 100644 (file)
@@ -25,6 +25,7 @@
     <orderEntry type="module" module-name="testFramework" scope="TEST" />
     <orderEntry type="module" module-name="testFramework-java" scope="TEST" />
     <orderEntry type="module" module-name="compiler-impl" scope="TEST" />
+    <orderEntry type="module" module-name="java-impl" />
+    <orderEntry type="module" module-name="openapi" />
   </component>
-</module>
-
+</module>
\ No newline at end of file
index 83968495a8c21431d010749bd45bb26a87ec691e..8e19c16a7a605fe5d23123859fcbea2c76416351 100644 (file)
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public class ExternalSystemJdkException extends ExternalSystemException {
 
-  public ExternalSystemJdkException(@Nullable String message, @Nullable Throwable cause) {
-    super(message, cause);
+  public ExternalSystemJdkException(@Nullable String message, @Nullable Throwable cause, @NotNull String... quickFixes) {
+    super(message, cause, quickFixes);
   }
 }
index 09dd7dfd1fcfc32ddbb1fd7cc8367a213a0be20b..a94f8c0a473b7641c19a3b7da6bb37559405326c 100644 (file)
  */
 package com.intellij.openapi.externalSystem.service.execution;
 
-import com.intellij.openapi.externalSystem.model.ExternalSystemException;
-import com.intellij.openapi.externalSystem.service.notification.callback.OpenExternalSystemSettingsCallback;
-import com.intellij.openapi.externalSystem.service.notification.callback.OpenProjectJdkSettingsCallback;
-import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.projectRoots.JavaSdk;
-import com.intellij.openapi.projectRoots.JavaSdkType;
-import com.intellij.openapi.projectRoots.ProjectJdkTable;
-import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.projectRoots.*;
 import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
 
-import javax.swing.*;
-import java.util.Collection;
+import java.io.File;
 
 public class ExternalSystemJdkUtil {
 
@@ -44,9 +34,8 @@ public class ExternalSystemJdkUtil {
   @NonNls public static final String USE_PROJECT_JDK = "#USE_PROJECT_JDK";
   @NonNls public static final String USE_JAVA_HOME = "#JAVA_HOME";
 
-
   @Nullable
-  public static Sdk getJdk(@Nullable Project project, @Nullable String jdkName) {
+  public static Sdk getJdk(@Nullable Project project, @Nullable String jdkName) throws ExternalSystemJdkException {
     if (jdkName == null) return null;
 
     if (USE_INTERNAL_JAVA.equals(jdkName)) {
@@ -56,103 +45,55 @@ public class ExternalSystemJdkUtil {
     if (USE_PROJECT_JDK.equals(jdkName)) {
       if (project != null) {
         Sdk res = ProjectRootManager.getInstance(project).getProjectSdk();
-        if (res != null) {
-          return res;
-        }
+        if (res != null) return res;
+
         Module[] modules = ModuleManager.getInstance(project).getModules();
         for (Module module : modules) {
           Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
-          if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
-            return sdk;
-          }
+          if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) return sdk;
         }
       }
 
       if (project == null) {
         Sdk recent = ProjectJdkTable.getInstance().findMostRecentSdkOfType(JavaSdk.getInstance());
         if (recent != null) return recent;
+
         return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
       }
 
-      throw new ExternalSystemException(
-        String.format("Project JDK is not specified. <a href='%s'>Configure</a>", OpenProjectJdkSettingsCallback.ID),
-        OpenProjectJdkSettingsCallback.ID);
+      throw new ProjectJdkNotFoundException();
     }
 
     if (USE_JAVA_HOME.equals(jdkName)) {
       final String javaHome = System.getenv("JAVA_HOME");
       if (StringUtil.isEmptyOrSpaces(javaHome)) {
-        throw new ExternalSystemException(ExternalSystemBundle.message("external.system.java.home.undefined"));
+        throw new UndefinedJavaHomeException();
       }
-      final Sdk jdk = JavaSdk.getInstance().createJdk("", javaHome);
-      if (jdk == null) {
-        throw new ExternalSystemException(ExternalSystemBundle.message("external.system.java.home.invalid", javaHome));
+
+      if (JdkUtil.checkForJdk(new File(javaHome)) || JdkUtil.checkForJre(javaHome)) {
+        final Sdk jdk = JavaSdk.getInstance().createJdk("", javaHome);
+        if (jdk == null) {
+          throw new InvalidJavaHomeException(javaHome);
+        }
+        return jdk;
+      }
+      else {
+        throw new InvalidJavaHomeException(javaHome);
       }
-      return jdk;
     }
 
     for (Sdk projectJdk : ProjectJdkTable.getInstance().getAllJdks()) {
       if (projectJdk.getName().equals(jdkName)) {
-        return projectJdk;
-      }
-    }
-
-    throw new ExternalSystemException(ExternalSystemBundle.message("external.system.java.home.invalid", jdkName));
-  }
-
-
-  private static class Item {
-    private final Object value;
-    private final String label;
-
-    private Item(Object value, String label) {
-      this.value = value;
-      this.label = label;
-    }
-
-    public Object getValue() {
-      return value;
-    }
-
-    public String toString() {
-      return label;
-    }
-  }
-
-  public static void addToModel(DefaultComboBoxModel model, Object value, String label) {
-    model.addElement(new Item(value, label));
-  }
-
-  public static <T> void setModel(JComboBox comboBox, DefaultComboBoxModel model, Collection<T> values, Function<T, Pair<String, ?>> func) {
-    model.removeAllElements();
-    for (T each : values) {
-      Pair<String, ?> pair = func.fun(each);
-      addToModel(model, pair.second, pair.first);
-    }
-    comboBox.setModel(model);
-  }
-
-  public static void select(DefaultComboBoxModel model, Object value) {
-    for (int i = 0; i < model.getSize(); i++) {
-      Item comboBoxUtil = (Item)model.getElementAt(i);
-      if (comboBoxUtil.getValue().equals(value)) {
-        model.setSelectedItem(comboBoxUtil);
-        return;
+        if (projectJdk.getHomePath() != null &&
+            (JdkUtil.checkForJdk(new File(projectJdk.getHomePath())) || JdkUtil.checkForJre(projectJdk.getHomePath()))) {
+          return projectJdk;
+        }
+        else {
+          throw new InvalidSdkException(projectJdk.getHomePath());
+        }
       }
     }
-    if (model.getSize() != 0) {
-      model.setSelectedItem(model.getElementAt(0));
-    }
-  }
 
-  @Nullable
-  public static String getSelectedString(DefaultComboBoxModel model) {
-    return String.valueOf(getSelectedValue(model));
-  }
-
-  @Nullable
-  public static Object getSelectedValue(DefaultComboBoxModel model) {
-    final Object item = model.getSelectedItem();
-    return item != null ? ((Item)item).getValue() : null;
+    return null;
   }
 }
index b8379c6787a8c62293f92d0f0fc1bc964460925f..1ae20de303e47eee2ba6a790fa73c76bddd7be75 100644 (file)
@@ -15,7 +15,7 @@
  */
 package com.intellij.openapi.externalSystem.service.execution;
 
-import org.jetbrains.annotations.Nullable;
+import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
 
 /**
  * @author Vladislav.Soroka
@@ -23,11 +23,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public class InvalidJavaHomeException extends ExternalSystemJdkException {
 
-  public InvalidJavaHomeException(@Nullable String message) {
-    super(message);
-  }
-
-  public InvalidJavaHomeException(@Nullable Throwable cause) {
-    super(cause);
+  public InvalidJavaHomeException(String invalidPath) {
+    super(ExternalSystemBundle.message("external.system.java.home.invalid", invalidPath), null);
   }
 }
index 4af9e2b5e4f9807029ca5de9ccca41b18e09dc4a..ac4d4eb7c2c43fc14bbad45fb58dff80bf474dc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
  */
 package com.intellij.openapi.externalSystem.service.notification;
 
+import com.intellij.execution.rmi.RemoteUtil;
+import com.intellij.openapi.externalSystem.model.ExternalSystemException;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.service.notification.callback.OpenProjectJdkSettingsCallback;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * @author Vladislav.Soroka
  * @since 12/11/2014
  */
 public class ExternalSystemNotificationExtensionImpl implements ExternalSystemNotificationExtension {
+  @NotNull
+  @Override
+  public ProjectSystemId getTargetExternalSystemId() {
+    return ProjectSystemId.IDE;
+  }
+
+  @Override
+  public void customize(@NotNull NotificationData notification,
+                        @NotNull Project project,
+                        @Nullable Throwable error) {
+    if (error == null) return;
+    //noinspection ThrowableResultOfMethodCallIgnored
+    Throwable unwrapped = RemoteUtil.unwrap(error);
+    if (unwrapped instanceof ExternalSystemException) {
+      updateNotification(notification, project, (ExternalSystemException)unwrapped);
+    }
+  }
+
+  private static void updateNotification(@NotNull final NotificationData notificationData,
+                                         @NotNull final Project project,
+                                         @NotNull ExternalSystemException e) {
+
+    for (String fix : e.getQuickFixes()) {
+      if (OpenProjectJdkSettingsCallback.ID.equals(fix)) {
+        notificationData.setListener(OpenProjectJdkSettingsCallback.ID, new OpenProjectJdkSettingsCallback(project));
+      }
+    }
+  }
 }
index aa37b6b1b600aa991ecc8ebded5ba60577d4502e..23da78d91752d81bb2ab7cc691147d3a3a1af566 100644 (file)
@@ -10,7 +10,6 @@ import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware;
 import com.intellij.openapi.externalSystem.ExternalSystemManager;
-import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
 import com.intellij.openapi.externalSystem.model.LocationAwareExternalSystemException;
 import com.intellij.openapi.externalSystem.model.ProjectSystemId;
 import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager;
@@ -112,7 +111,8 @@ public class ExternalSystemNotificationManager {
         filePath, ObjectUtils.notNull(line, -1), ObjectUtils.notNull(column, -1), false);
 
     for (ExternalSystemNotificationExtension extension : ExternalSystemNotificationExtension.EP_NAME.getExtensions()) {
-      if (!externalSystemId.equals(extension.getTargetExternalSystemId())) {
+      final ProjectSystemId targetExternalSystemId = extension.getTargetExternalSystemId();
+      if (!externalSystemId.equals(targetExternalSystemId) && !targetExternalSystemId.equals(ProjectSystemId.IDE)) {
         continue;
       }
       extension.customize(notificationData, myProject, error);
index 1fbc93378bf4e78712df825de689e9d738fb87b5..e1122d2caf59cb4008fc6454f7688d773cb6bbd7 100644 (file)
@@ -17,8 +17,9 @@ package com.intellij.openapi.externalSystem.service.notification.callback;
 
 import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationListener;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.options.ShowSettingsUtil;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.event.HyperlinkEvent;
@@ -29,15 +30,17 @@ import javax.swing.event.HyperlinkEvent;
  */
 public class OpenExternalSystemSettingsCallback extends NotificationListener.Adapter {
 
-  public final static String ID = "open_project_jdk_settings";
+  public final static String ID = "#open_external_system_settings";
   private final Project myProject;
+  @NotNull private final ProjectSystemId mySystemId;
 
-  public OpenExternalSystemSettingsCallback(Project project) {
+  public OpenExternalSystemSettingsCallback(Project project, @NotNull ProjectSystemId systemId) {
     myProject = project;
+    mySystemId = systemId;
   }
 
   @Override
   protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
-    ProjectSettingsService.getInstance(myProject).openProjectSettings();
+    ShowSettingsUtil.getInstance().showSettingsDialog(myProject, mySystemId.getReadableName());
   }
 }
index aac3b85125d1837db7636f16201562ebfd8deb19..8b5bb4008a39254d82b563b5928e6fb835fd19e7 100644 (file)
@@ -29,7 +29,7 @@ import javax.swing.event.HyperlinkEvent;
  */
 public class OpenProjectJdkSettingsCallback extends NotificationListener.Adapter {
 
-  public final static String ID = "open_project_jdk_settings";
+  public final static String ID = "#open_project_jdk_settings";
   private final Project myProject;
 
   public OpenProjectJdkSettingsCallback(Project project) {
index 5a933ab18e42ebd2424452c08568ee936a177070..9cd7fc657c3701e8e431ed2c6872a93a7a548c89 100644 (file)
@@ -83,6 +83,11 @@ public abstract class AbstractExternalSystemConfigurable<
     myExternalSystemId = externalSystemId;
   }
 
+  @NotNull
+  public Project getProject() {
+    return myProject;
+  }
+
   @Nullable
   @Override
   public Runnable enableSearch(String option) {
index 13cd37893b70fa830d8c75d8e2a174bf6ccbd508..b1c7cafaff4aa2f1cff8639f37a43b86f90d72b0 100644 (file)
@@ -1,12 +1,35 @@
+/*
+ * 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.
+ * 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.openapi.externalSystem.service.ui;
 
+import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil;
 import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.JavaSdk;
 import com.intellij.openapi.projectRoots.ProjectJdkTable;
 import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.projectRoots.SdkType;
 import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.ui.util.CompositeAppearance;
+import com.intellij.openapi.ui.ComboBoxWithWidePopup;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.ui.ColoredListCellRendererWrapper;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.SimpleTextAttributes;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -14,12 +37,10 @@ import javax.swing.*;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-import static com.intellij.openapi.externalSystem.service.ui.ComboBoxUtil.*;
-
 /**
  * @author Sergey Evdokimov
  */
-public class ExternalSystemJdkComboBox extends JComboBox {
+public class ExternalSystemJdkComboBox extends ComboBoxWithWidePopup {
 
   private static final int MAX_PATH_LENGTH = 50;
 
@@ -28,6 +49,31 @@ public class ExternalSystemJdkComboBox extends JComboBox {
 
   public ExternalSystemJdkComboBox(@Nullable Project project) {
     myProject = project;
+    setRenderer(new ColoredListCellRendererWrapper() {
+
+      @Override
+      protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
+        JdkComboBoxItem item = (JdkComboBoxItem)value;
+        CompositeAppearance appearance = new CompositeAppearance();
+        SdkType sdkType = JavaSdk.getInstance();
+        appearance.setIcon(sdkType.getIcon());
+        SimpleTextAttributes attributes = getTextAttributes(item.valid, selected);
+        CompositeAppearance.DequeEnd ending = appearance.getEnding();
+
+        ending.addText(item.label, attributes);
+        if (item.comment != null) {
+          if (!item.comment.equals(item.jdkName)) {
+            SimpleTextAttributes textAttributes =
+              SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN,
+                                                                      JBColor.WHITE) : SimpleTextAttributes.GRAY_ATTRIBUTES;
+            ending.addComment(item.comment, textAttributes);
+          }
+        }
+
+        final CompositeAppearance compositeAppearance = ending.getAppearance();
+        compositeAppearance.customize(this);
+      }
+    });
   }
 
   @Nullable
@@ -36,58 +82,81 @@ public class ExternalSystemJdkComboBox extends JComboBox {
   }
 
   public void refreshData(@Nullable String selectedValue) {
-    Map<String, String> jdkMap = collectJdkNamesAndDescriptions();
+    Map<String, JdkComboBoxItem> jdkMap = collectComboBoxItem();
     if (selectedValue != null && !jdkMap.containsKey(selectedValue)) {
       assert selectedValue.length() > 0;
-      jdkMap.put(selectedValue, selectedValue);
+      jdkMap.put(selectedValue, new JdkComboBoxItem(selectedValue, selectedValue, selectedValue, true));
     }
 
     removeAllItems();
 
-    for (Map.Entry<String, String> entry : jdkMap.entrySet()) {
-      addToModel((DefaultComboBoxModel)getModel(), entry.getKey(), entry.getValue());
+    for (Map.Entry<String, JdkComboBoxItem> entry : jdkMap.entrySet()) {
+      //noinspection unchecked
+      ((DefaultComboBoxModel)getModel()).addElement(entry.getValue());
     }
 
     select((DefaultComboBoxModel)getModel(), selectedValue);
   }
 
+  private static void select(DefaultComboBoxModel model, Object value) {
+    for (int i = 0; i < model.getSize(); i++) {
+      JdkComboBoxItem comboBoxUtil = (JdkComboBoxItem)model.getElementAt(i);
+      if (comboBoxUtil.jdkName.equals(value)) {
+        model.setSelectedItem(comboBoxUtil);
+        return;
+      }
+    }
+    if (model.getSize() != 0) {
+      model.setSelectedItem(model.getElementAt(0));
+    }
+  }
+
+  @Nullable
   public String getSelectedValue() {
-    return getSelectedString((DefaultComboBoxModel)getModel());
+    final DefaultComboBoxModel model = (DefaultComboBoxModel)getModel();
+    final Object item = model.getSelectedItem();
+    return item != null ? ((JdkComboBoxItem)item).jdkName : null;
   }
 
-  private Map<String, String> collectJdkNamesAndDescriptions() {
-    Map<String, String> result = new LinkedHashMap<String, String>();
+  private Map<String, JdkComboBoxItem> collectComboBoxItem() {
+    Map<String, JdkComboBoxItem> result = new LinkedHashMap<String, JdkComboBoxItem>();
 
     for (Sdk projectJdk : ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) {
       String name = projectJdk.getName();
 
-      String label;
-
       String path = projectJdk.getHomePath();
-      if (path == null) {
-        label = name;
+      String comment;
+      String versionString = projectJdk.getVersionString();
+      if (versionString != null && !versionString.equals(name)) {
+        comment = versionString;
       }
       else {
-        label = String.format("<html>%s <font color=gray>(%s)</font></html>", name, truncateLongPath(path));
+        comment = path == null ? name : truncateLongPath(path);
       }
 
-      result.put(name, label);
+      result.put(name, new JdkComboBoxItem(name, name, comment, ((SdkType)projectJdk.getSdkType()).sdkHasValidPath(projectJdk)));
     }
 
     String internalJdkPath = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().getHomePath();
     assert internalJdkPath != null;
-    result.put(USE_INTERNAL_JAVA, ExternalSystemBundle.message("maven.java.internal", truncateLongPath(internalJdkPath)));
+    result.put(ExternalSystemJdkUtil.USE_INTERNAL_JAVA,
+               new JdkComboBoxItem(ExternalSystemJdkUtil.USE_INTERNAL_JAVA,
+                                   ExternalSystemBundle.message("external.system.java.internal.jre"), truncateLongPath(internalJdkPath),
+                                   true));
 
     if (myProject != null) {
       String projectJdk = ProjectRootManager.getInstance(myProject).getProjectSdkName();
-      String projectJdkTitle = String.format("<html>Use Project JDK <font color=gray>(%s)</font></html>", projectJdk == null ? "not defined yet" : projectJdk);
-      result.put(USE_PROJECT_JDK, projectJdkTitle);
+      result.put(ExternalSystemJdkUtil.USE_PROJECT_JDK,
+                 new JdkComboBoxItem(ExternalSystemJdkUtil.USE_PROJECT_JDK, "Use Project JDK",
+                                     projectJdk == null ? "not defined yet" : projectJdk, projectJdk != null));
     }
 
     String javaHomePath = System.getenv("JAVA_HOME");
-    String javaHomeLabel = ExternalSystemBundle.message("maven.java.home.env", javaHomePath == null ? "not defined yet" : truncateLongPath(javaHomePath));
+    String javaHomeLabel = ExternalSystemBundle.message("external.system.java.home.env");
 
-    result.put(USE_JAVA_HOME, javaHomeLabel);
+    result.put(ExternalSystemJdkUtil.USE_JAVA_HOME,
+               new JdkComboBoxItem(ExternalSystemJdkUtil.USE_JAVA_HOME, javaHomeLabel,
+                                   javaHomePath == null ? "not defined yet" : truncateLongPath(javaHomePath), javaHomePath != null));
 
     return result;
   }
@@ -101,4 +170,29 @@ public class ExternalSystemJdkComboBox extends JComboBox {
     return path;
   }
 
+  private static SimpleTextAttributes getTextAttributes(final boolean valid, final boolean selected) {
+    if (!valid) {
+      return SimpleTextAttributes.ERROR_ATTRIBUTES;
+    }
+    else if (selected && !(SystemInfo.isWinVistaOrNewer && UIManager.getLookAndFeel().getName().contains("Windows"))) {
+      return SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES;
+    }
+    else {
+      return SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES;
+    }
+  }
+
+  private static class JdkComboBoxItem {
+    private String jdkName;
+    private String label;
+    private String comment;
+    private boolean valid;
+
+    public JdkComboBoxItem(String jdkName, String label, String comment, boolean valid) {
+      this.jdkName = jdkName;
+      this.label = label;
+      this.comment = comment;
+      this.valid = valid;
+    }
+  }
 }
index 98d7413c2dcee24c9ec58945fa56c72a21c60857..d1f2ba06610efac98bced9d0e0544bf569e7f1fe 100644 (file)
@@ -19,6 +19,7 @@
     <applicationService serviceImplementation="com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper"/>
     <applicationService serviceImplementation="com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager"/>
     <projectService serviceImplementation="com.intellij.openapi.externalSystem.service.notification.ExternalSystemNotificationManager"/>
+    <externalSystemNotificationExtension implementation="com.intellij.openapi.externalSystem.service.notification.ExternalSystemNotificationExtensionImpl" />
 
     <!--Project structure management services-->
     <applicationService serviceImplementation="com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager"/>
index 33ab74a762a8c714d00fd31eb9c6dc8085bca202..30c8e07ca4b28bd5ecc7d3932f6cd54d7770eef4 100644 (file)
@@ -61,7 +61,6 @@ import icons.GradleIcons;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.gradle.config.GradleSettingsListenerAdapter;
-import org.jetbrains.plugins.gradle.remote.GradleJavaHelper;
 import org.jetbrains.plugins.gradle.service.GradleInstallationManager;
 import org.jetbrains.plugins.gradle.service.project.GradleAutoImportAware;
 import org.jetbrains.plugins.gradle.service.project.GradleProjectResolver;
@@ -147,14 +146,10 @@ public class GradleManager
   public Function<Pair<Project, String>, GradleExecutionSettings> getExecutionSettingsProvider() {
     return new Function<Pair<Project, String>, GradleExecutionSettings>() {
 
-      private final GradleJavaHelper myJavaHelper = new GradleJavaHelper();
-
       @Override
       public GradleExecutionSettings fun(Pair<Project, String> pair) {
         GradleSettings settings = GradleSettings.getInstance(pair.first);
         File gradleHome = myInstallationManager.getGradleHome(pair.first, pair.second);
-        Sdk gradleJdk = myInstallationManager.getGradleJdk(pair.first, pair.second);
-
         String localGradlePath = null;
         if (gradleHome != null) {
           try {
@@ -187,16 +182,12 @@ public class GradleManager
           result.addResolverExtensionClass(ClassHolder.from(extension.getClass()));
         }
 
-        if (gradleJdk != null) {
-          result.setJavaHome(gradleJdk.getHomePath());
-        } else {
-          String javaHome = myJavaHelper.getJdkHome(pair.first);
-          if (!StringUtil.isEmpty(javaHome)) {
-            LOG.info("Instructing gradle to use java from " + javaHome);
-          }
-          result.setJavaHome(javaHome);
+        final Sdk gradleJdk = myInstallationManager.getGradleJdk(pair.first, pair.second);
+        final String javaHome = gradleJdk != null ? gradleJdk.getHomePath() : null;
+        if (!StringUtil.isEmpty(javaHome)) {
+          LOG.info("Instructing gradle to use java from " + javaHome);
         }
-
+        result.setJavaHome(javaHome);
         return result;
       }
     };
index 941e551211f7e7620fe7273272a7d80847062926..6a157e3a7ec334d15b0efa1047bcceab4600a37b 100644 (file)
@@ -1,5 +1,8 @@
 package org.jetbrains.plugins.gradle.service;
 
+import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkException;
+import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil;
+import com.intellij.openapi.externalSystem.service.notification.callback.OpenExternalSystemSettingsCallback;
 import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
 import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
 import com.intellij.openapi.module.Module;
@@ -129,7 +132,16 @@ public class GradleInstallationManager {
       return null;
     }
 
-    return settings.getGradleJvm();
+    final String gradleJvm = settings.getGradleJvm();
+    try {
+      return ExternalSystemJdkUtil.getJdk(project, gradleJvm);
+    }
+    catch (ExternalSystemJdkException e) {
+      throw new ExternalSystemJdkException(
+        String.format("Invalid Gradle JDK configuration found: <a href='%s'>Open Gradle Settings</a> \n",
+                      OpenExternalSystemSettingsCallback.ID),
+        e, OpenExternalSystemSettingsCallback.ID);
+    }
   }
 
   /**
index 19dfa5d6927b57a6754f5b71addba3d3860c62cc..9069dc104aba29f487c776c6f8100f896839fc2b 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.externalSystem.model.ExternalSystemException;
 import com.intellij.openapi.externalSystem.model.ProjectSystemId;
 import com.intellij.openapi.externalSystem.service.notification.ExternalSystemNotificationExtension;
 import com.intellij.openapi.externalSystem.service.notification.NotificationData;
+import com.intellij.openapi.externalSystem.service.notification.callback.OpenExternalSystemSettingsCallback;
 import com.intellij.openapi.project.Project;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -62,6 +63,10 @@ public class GradleNotificationExtension implements ExternalSystemNotificationEx
       else if (GotoSourceNotificationCallback.ID.equals(fix)) {
         notificationData.setListener(GotoSourceNotificationCallback.ID, new GotoSourceNotificationCallback(notificationData, project));
       }
+      else if (OpenExternalSystemSettingsCallback.ID.equals(fix)) {
+        notificationData.setListener(
+          OpenExternalSystemSettingsCallback.ID, new OpenExternalSystemSettingsCallback(project, GradleConstants.SYSTEM_ID));
+      }
     }
   }
 }
index e5951134e52333bfdf0850a05f92d4d24989a21b..c03281223c8a0f93cc947072799228033c15e278 100644 (file)
@@ -142,7 +142,7 @@ public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradlePro
 
       }
     };
-    final GradleProjectSettingsControl settingsControl = new GradleProjectSettingsControl(getExternalProjectSettings());
+    final GradleProjectSettingsControl settingsControl = new GradleProjectSettingsControl(getExternalProjectSettings(), myWizardContext.getProject());
     return new ExternalModuleSettingsStep<GradleProjectSettings>(this, settingsControl);
   }
 
index 5bd644d24e8d52284fb3b54cc0217d1156436d81..cdda8bc9e29060f0cc464ddaf58f17b5c2e90bbe 100644 (file)
@@ -41,7 +41,7 @@ public class GradleConfigurable extends AbstractExternalSystemConfigurable<Gradl
   @NotNull
   @Override
   protected ExternalSystemSettingsControl<GradleProjectSettings> createProjectSettingsControl(@NotNull GradleProjectSettings settings) {
-    return new GradleProjectSettingsControl(settings);
+    return new GradleProjectSettingsControl(settings, getProject());
   }
 
   @Nullable
index 936424b0729e24de0bb71be0ad0b15d8bd511315..132ea731fe094bdfd3fac576fb50b9bd113e2ecc 100644 (file)
@@ -18,14 +18,12 @@ package org.jetbrains.plugins.gradle.service.settings;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.externalSystem.model.settings.LocationSettingType;
 import com.intellij.openapi.externalSystem.service.settings.AbstractExternalProjectSettingsControl;
+import com.intellij.openapi.externalSystem.service.ui.ExternalSystemJdkComboBox;
 import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
 import com.intellij.openapi.externalSystem.util.PaintAwarePanel;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.projectRoots.ProjectJdkTable;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.ui.configuration.JdkComboBox;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.ui.TextComponentAccessor;
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
@@ -70,25 +68,30 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
   @NotNull private LocationSettingType myGradleHomeSettingType = LocationSettingType.UNKNOWN;
 
   @NotNull private final GradleInstallationManager myInstallationManager;
+  @Nullable private final Project myProject;
 
-  // @formatter:off
   @SuppressWarnings("FieldCanBeLocal") // Used implicitly by reflection at disposeUIResources() and showUi()
   private JLabel                    myGradleHomeLabel;
-  private JLabel                    myGradleJdkLabel;
-  private JdkComboBox               myGradleJdkComboBox;
+  @SuppressWarnings("FieldCanBeLocal") // Used implicitly by reflection at disposeUIResources() and showUi()
+  private JLabel myGradleJdkLabel;
+  private ExternalSystemJdkComboBox myGradleJdkComboBox;
   private TextFieldWithBrowseButton myGradleHomePathField;
   private JBRadioButton             myUseWrapperButton;
   private JBRadioButton             myUseWrapperWithVerificationButton;
   private JBLabel                   myUseWrapperVerificationLabel;
   private JBRadioButton             myUseLocalDistributionButton;
   private JBRadioButton             myUseBundledDistributionButton;
-  // @formatter:on
 
   private boolean myShowBalloonIfNecessary;
 
   public GradleProjectSettingsControl(@NotNull GradleProjectSettings initialSettings) {
+    this(initialSettings, null);
+  }
+
+  public GradleProjectSettingsControl(@NotNull GradleProjectSettings initialSettings, @Nullable Project project) {
     super(initialSettings);
     myInstallationManager = ServiceManager.getService(GradleInstallationManager.class);
+    myProject = project;
   }
 
   @Override
@@ -118,10 +121,10 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
     });
 
     myGradleHomeLabel = new JBLabel(GradleBundle.message("gradle.settings.text.home.path"));
+    initGradleHome();
     myGradleJdkLabel = new JBLabel(GradleBundle.message("gradle.settings.text.jvm.path"));
+    myGradleJdkComboBox = new ExternalSystemJdkComboBox(myProject);
 
-    initGradleHome();
-    initGradleJdk();
     initControls();
     content.add(myUseWrapperButton, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
     content.add(myUseWrapperWithVerificationButton, ExternalSystemUiUtil.getLabelConstraints(indentLevel));
@@ -186,16 +189,6 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
     buttonGroup.add(myUseLocalDistributionButton);
   }
 
-  private void initGradleJdk() {
-    final ProjectSdksModel jdkModel = new ProjectSdksModel();
-
-    for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
-      jdkModel.addSdk(sdk);
-    }
-
-    myGradleJdkComboBox = new JdkComboBox(jdkModel);
-  }
-
   private void initGradleHome() {
     myGradleHomePathField = new TextFieldWithBrowseButton();
 
@@ -254,7 +247,8 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
       GradleUtil.storeLastUsedGradleHome(gradleHomePath);
     }
 
-    settings.setGradleJvm(myGradleJdkComboBox.getSelectedJdk());
+    final String gradleJvm = FileUtil.toCanonicalPath(myGradleJdkComboBox.getSelectedValue());
+    settings.setGradleJvm(StringUtil.isEmpty(gradleJvm) ? null : gradleJvm);
 
     if (myUseLocalDistributionButton.isSelected()) {
       settings.setDistributionType(DistributionType.LOCAL);
@@ -269,7 +263,8 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
   protected void updateInitialExtraSettings() {
     String gradleHomePath = FileUtil.toCanonicalPath(myGradleHomePathField.getText());
     getInitialSettings().setGradleHome(StringUtil.isEmpty(gradleHomePath) ? null : gradleHomePath);
-    getInitialSettings().setGradleJvm(myGradleJdkComboBox.getSelectedJdk());
+    final String gradleJvm = FileUtil.toCanonicalPath(myGradleJdkComboBox.getSelectedValue());
+    getInitialSettings().setGradleJvm(StringUtil.isEmpty(gradleJvm) ? null : gradleJvm);
     if (myUseLocalDistributionButton.isSelected()) {
       getInitialSettings().setDistributionType(DistributionType.LOCAL);
     } else if(myUseWrapperButton.isSelected()) {
@@ -298,7 +293,7 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
       return true;
     }
 
-    if (myGradleJdkComboBox.getSelectedJdk() != getInitialSettings()) {
+    if (!StringUtil.equals(myGradleJdkComboBox.getSelectedValue(), getInitialSettings().getGradleJvm())) {
       return true;
     }
 
@@ -317,12 +312,8 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
     myGradleHomePathField.setText(gradleHome == null ? "" : gradleHome);
     myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
 
-    final Sdk gradleJvm = getInitialSettings().getGradleJvm();
-    if (gradleJvm != null) {
-      myGradleJdkComboBox.setSelectedJdk(gradleJvm);
-    } else {
-      myGradleJdkComboBox.setInvalidJdk("Not set");
-    }
+    final String gradleJvm = getInitialSettings().getGradleJvm();
+    myGradleJdkComboBox.refreshData(StringUtil.isEmpty(gradleJvm) ? null : gradleJvm);
 
     updateWrapperControls(getInitialSettings().getExternalProjectPath(), isDefaultModuleCreation);
     if (!myUseLocalDistributionButton.isSelected()) {
index e309bd892aaa93ad27b4b71da8e9e41c3fafd3d6..8d45b75b1c7ca853773df36b9f7e573ac577f938 100644 (file)
@@ -51,7 +51,7 @@ public class ImportFromGradleControl
   @NotNull
   @Override
   protected ExternalSystemSettingsControl<GradleProjectSettings> createProjectSettingsControl(@NotNull GradleProjectSettings settings) {
-    GradleProjectSettingsControl settingsControl = new GradleProjectSettingsControl(settings);
+    GradleProjectSettingsControl settingsControl = new GradleProjectSettingsControl(settings, getSystemSettings().getProject());
     settingsControl.hideUseAutoImportBox();
     return settingsControl;
   }
index 658c8fc1ab926666f70de939cea945c65aa6fc91..7b25028b4b7d54fae60e5af0607a85927cbda2bc 100644 (file)
@@ -15,8 +15,8 @@
  */
 package org.jetbrains.plugins.gradle.settings;
 
+import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil;
 import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
-import com.intellij.openapi.projectRoots.Sdk;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
 public class GradleProjectSettings extends ExternalProjectSettings {
 
   @Nullable private String myGradleHome;
-  @Nullable private Sdk myGradleJvm;
+  @Nullable private String myGradleJvm = ExternalSystemJdkUtil.USE_PROJECT_JDK;
   @Nullable private DistributionType distributionType;
   private boolean disableWrapperSourceDistributionNotification;
 
@@ -41,11 +41,11 @@ public class GradleProjectSettings extends ExternalProjectSettings {
   }
 
   @Nullable
-  public Sdk getGradleJvm() {
+  public String getGradleJvm() {
     return myGradleJvm;
   }
 
-  public void setGradleJvm(@Nullable Sdk gradleJvm) {
+  public void setGradleJvm(@Nullable String gradleJvm) {
     myGradleJvm = gradleJvm;
   }
 
@@ -72,6 +72,7 @@ public class GradleProjectSettings extends ExternalProjectSettings {
     GradleProjectSettings result = new GradleProjectSettings();
     copyTo(result);
     result.myGradleHome = myGradleHome;
+    result.myGradleJvm = myGradleJvm;
     result.distributionType = distributionType;
     result.disableWrapperSourceDistributionNotification = disableWrapperSourceDistributionNotification;
     return result;
index 14a01976698cfedd35a53377fa36f3e221eb68e0..140edf69ad9e312a4f03b35d39bbbf4456c10de7 100644 (file)
@@ -18,6 +18,7 @@
 package org.jetbrains.idea.maven.execution;
 
 import com.intellij.execution.configuration.EnvironmentVariablesComponent;
+import com.intellij.openapi.externalSystem.service.ui.ExternalSystemJdkComboBox;
 import com.intellij.openapi.project.Project;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.ui.RawCommandLineEditor;
@@ -38,7 +39,7 @@ public class MavenRunnerPanel {
   private JCheckBox myRunInBackgroundCheckbox;
   private RawCommandLineEditor myVMParametersEditor;
   private EnvironmentVariablesComponent myEnvVariablesComponent;
-  private MavenJdkComboBox myJdkCombo;
+  private ExternalSystemJdkComboBox myJdkCombo;
 
   private JCheckBox mySkipTestsCheckBox;
   private MavenPropertiesPanel myPropertiesPanel;
@@ -88,7 +89,7 @@ public class MavenRunnerPanel {
 
     JLabel jdkLabel = new JLabel("JRE:");
     jdkLabel.setDisplayedMnemonic('j');
-    jdkLabel.setLabelFor(myJdkCombo = new MavenJdkComboBox(myProject));
+    jdkLabel.setLabelFor(myJdkCombo = new ExternalSystemJdkComboBox(myProject));
     c.gridx = 0;
     c.gridy++;
     c.weightx = 0;
index e8a7a923c47e7a3634f654189769362c5fd60252..7cea28cae52851a030a3968608874b82a722c57e 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.jetbrains.idea.maven.execution;
 
+import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
 import org.jetbrains.annotations.NonNls;
@@ -30,9 +31,9 @@ import java.util.Map;
 
 public class MavenRunnerSettings implements Cloneable {
 
-  @NonNls public static final String USE_INTERNAL_JAVA = "#JAVA_INTERNAL";
-  @NonNls public static final String USE_PROJECT_JDK = "#USE_PROJECT_JDK";
-  @NonNls public static final String USE_JAVA_HOME = "#JAVA_HOME";
+  @NonNls public static final String USE_INTERNAL_JAVA = ExternalSystemJdkUtil.USE_INTERNAL_JAVA;
+  @NonNls public static final String USE_PROJECT_JDK = ExternalSystemJdkUtil.USE_PROJECT_JDK;
+  @NonNls public static final String USE_JAVA_HOME = ExternalSystemJdkUtil.USE_JAVA_HOME;
 
   private boolean runMavenInBackground = true;
   @NotNull private String jreName = USE_PROJECT_JDK;
index dd757ac9e3468d421861f64e84045abdc8a99ddf..7b99e4d2a248343884bcb92ad5aecb6816c7fe6d 100644 (file)
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.execution.MavenJdkComboBox;
+import com.intellij.openapi.externalSystem.service.ui.ExternalSystemJdkComboBox;
 import org.jetbrains.idea.maven.server.MavenServerManager;
 
 import javax.swing.*;
@@ -38,7 +38,7 @@ public class MavenImportingConfigurable implements SearchableConfigurable {
 
   private final JCheckBox myUseMaven3CheckBox;
   private final JTextField myEmbedderVMOptions;
-  private final MavenJdkComboBox myEmbedderJdk;
+  private final ExternalSystemJdkComboBox myEmbedderJdk;
 
   public MavenImportingConfigurable(Project project) {
     myImportingSettings = MavenProjectsManager.getInstance(project).getImportingSettings();
@@ -52,7 +52,7 @@ public class MavenImportingConfigurable implements SearchableConfigurable {
     myUseMaven3CheckBox.setToolTipText("If this option is disabled maven 2 will be used");
 
     myEmbedderVMOptions = new JTextField(30);
-    myEmbedderJdk = new MavenJdkComboBox(null); // Embedder JDK is an application setting, not a project setting, so don't pass project
+    myEmbedderJdk = new ExternalSystemJdkComboBox(null); // Embedder JDK is an application setting, not a project setting, so don't pass project
     assert myEmbedderJdk.getProject() == null;
   }