From 763fc2bb309878d51486ba12225ff005d5be659a Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Tue, 2 Oct 2012 18:19:56 +0400 Subject: [PATCH] RUBY-10872: some stubs for remote interpreters --- .../impl/SdkConfigurationUtil.java | 68 +------------------ .../src/com/intellij/util/Consumer.java | 4 +- 2 files changed, 4 insertions(+), 68 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java index 506d9de50c47..0ce108c3906b 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java @@ -17,7 +17,6 @@ package com.intellij.openapi.projectRoots.impl; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.PathChooserDialog; @@ -33,11 +32,6 @@ import com.intellij.openapi.projectRoots.SdkType; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.ui.popup.ListPopup; -import com.intellij.openapi.ui.popup.ListPopupStep; -import com.intellij.openapi.ui.popup.PopupStep; -import com.intellij.openapi.ui.popup.util.BaseListPopupStep; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -48,7 +42,6 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.util.*; /** @@ -166,7 +159,7 @@ public class SdkConfigurationUtil { e.getMessage() + ".\nPlease make sure that " + FileUtil.toSystemDependentName(homeDir.getPath()) + - " is a valid home path for this SDK type.", "Error configuring SDK"); + " is a valid home path for this SDK type.", "Error Configuring SDK"); } return null; } @@ -298,65 +291,6 @@ public class SdkConfigurationUtil { return LocalFileSystem.getInstance().findFileByPath(homepath); } - public static void suggestAndAddSdk(@Nullable final Project project, - final Sdk[] existingSdks, - JComponent popupOwner, - final Consumer callback, - final SdkType... sdkTypes) { - assert sdkTypes.length > 0; - final Map suggestedSdkHomes = new LinkedHashMap(); - for (SdkType sdkType : sdkTypes) { - final Collection sdkHomes = sdkType.suggestHomePaths(); - for (String sdkHome : filterExistingPaths(sdkType, sdkHomes, existingSdks)) { - suggestedSdkHomes.put(sdkHome, sdkType); - } - } - if (suggestedSdkHomes.size() > 0) { - suggestedSdkHomes.put(null, sdkTypes[0]); - showSuggestedHomesPopup(project, existingSdks, suggestedSdkHomes, sdkTypes, popupOwner, callback); - } - else { - createSdk(project, existingSdks, callback, sdkTypes); - } - } - - private static void showSuggestedHomesPopup(@Nullable final Project project, - final Sdk[] existingSdks, - final Map suggestedSdkHomes, - final SdkType[] sdkTypes, - final JComponent popupOwner, - final Consumer callback) { - final List list = new ArrayList(suggestedSdkHomes.keySet()); - ListPopupStep sdkHomesStep = new BaseListPopupStep("Select Interpreter Path", list) { - @NotNull - @Override - public String getTextFor(String value) { - return value == null ? "Specify Other..." : FileUtil.toSystemDependentName(value); - } - - @Override - public PopupStep onChosen(final String selectedValue, boolean finalChoice) { - final SdkType sdkType = suggestedSdkHomes.get(selectedValue); - if (selectedValue == null) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - @Override - public void run() { - createSdk(project, existingSdks, callback, sdkTypes); - } - }, ModalityState.current()); - } - else { - Sdk sdk = setupSdk(existingSdks, LocalFileSystem.getInstance().findFileByPath(selectedValue), - sdkType, false, null, null); - callback.consume(sdk); - } - return FINAL_CHOICE; - } - }; - final ListPopup popup = JBPopupFactory.getInstance().createListPopup(sdkHomesStep); - popup.showUnderneathOf(popupOwner); - } - public static List filterExistingPaths(SdkType sdkType, Collection sdkHomes, final Sdk[] sdks) { List result = new ArrayList(); for (String sdkHome : sdkHomes) { diff --git a/platform/util-rt/src/com/intellij/util/Consumer.java b/platform/util-rt/src/com/intellij/util/Consumer.java index 2886971cec98..d00f829b117e 100644 --- a/platform/util-rt/src/com/intellij/util/Consumer.java +++ b/platform/util-rt/src/com/intellij/util/Consumer.java @@ -15,6 +15,8 @@ */ package com.intellij.util; +import org.jetbrains.annotations.Nullable; + public interface Consumer { Consumer EMPTY_CONSUMER = new Consumer() { public void consume(final Object t) { @@ -24,7 +26,7 @@ public interface Consumer { /** * @param t consequently takes value of each element of the set this processor is passed to for processing. */ - void consume(T t); + void consume(@Nullable T t); }