ui: startup wizard in CE
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Fri, 31 Oct 2014 12:32:13 +0000 (13:32 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Fri, 31 Oct 2014 12:32:13 +0000 (13:32 +0100)
platform/platform-impl/src/com/intellij/idea/StartupUtil.java
platform/platform-main/src/com/intellij/idea/MainImpl.java

index fdf11dc54e4d0e29d5d06ef07d21e0905cd59deb..155389da46bf73942eb7a57a7f9c783e5b75fd97 100644 (file)
  */
 package com.intellij.idea;
 
+import com.intellij.ide.customize.CustomizeIDEWizardDialog;
+import com.intellij.ide.plugins.PluginManagerCore;
+import com.intellij.ide.startupWizard.StartupWizard;
 import com.intellij.openapi.application.ApplicationInfo;
 import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.application.ConfigImportHelper;
 import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.ex.ApplicationInfoEx;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.SystemInfo;
@@ -30,6 +34,7 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.ui.AppUIUtil;
 import com.intellij.util.Consumer;
 import com.intellij.util.EnvironmentUtil;
+import com.intellij.util.PlatformUtils;
 import com.intellij.util.lang.UrlClassLoader;
 import com.sun.jna.Native;
 import org.jetbrains.annotations.NonNls;
@@ -66,14 +71,14 @@ public class StartupUtil {
     ourLock.setActivateListener(consumer);
   }
 
-  interface AppStarter {
-    void start(boolean newConfigFolder);
-  }
-
   public synchronized static int getAcquiredPort() {
     return ourLock.getAcquiredPort();
   }
 
+  interface AppStarter {
+    void start(boolean newConfigFolder);
+  }
+
   static void prepareAndStart(String[] args, AppStarter appStarter) {
     boolean newConfigFolder = false;
 
@@ -294,4 +299,29 @@ public class StartupUtil {
       log.info("JVM Args: " + StringUtil.join(arguments, " "));
     }
   }
+
+  static void runStartupWizard() {
+    ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
+
+    String stepsProvider = appInfo.getCustomizeIDEWizardStepsProvider();
+    if (stepsProvider != null) {
+      CustomizeIDEWizardDialog.showCustomSteps(stepsProvider);
+      PluginManagerCore.invalidatePlugins();
+      return;
+    }
+
+    if (PlatformUtils.isIntelliJ()) {
+      new CustomizeIDEWizardDialog().show();
+      PluginManagerCore.invalidatePlugins();
+      return;
+    }
+
+    List<ApplicationInfoEx.PluginChooserPage> pages = appInfo.getPluginChooserPages();
+    if (!pages.isEmpty()) {
+      StartupWizard startupWizard = new StartupWizard(pages);
+      startupWizard.setCancelText("Skip");
+      startupWizard.show();
+      PluginManagerCore.invalidatePlugins();
+    }
+  }
 }
index 32a41d49d02feee87d09d53f9e32d579223f15d2..88ce048d3b0d10ecbd932b6c6a9657b6f0c9f271 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.idea;
 
 import com.intellij.ide.plugins.PluginManager;
+import com.intellij.openapi.application.ConfigImportHelper;
 import com.intellij.util.PlatformUtils;
 
 import javax.swing.*;
@@ -32,12 +33,17 @@ public class MainImpl {
 
     StartupUtil.prepareAndStart(args, new StartupUtil.AppStarter() {
       @Override
-      public void start(boolean newConfigFolder) {
+      public void start(final boolean newConfigFolder) {
         //noinspection SSBasedInspection
         SwingUtilities.invokeLater(new Runnable() {
           @Override
           public void run() {
             PluginManager.installExceptionHandler();
+
+            if (newConfigFolder && !Boolean.getBoolean(ConfigImportHelper.CONFIG_IMPORTED_IN_CURRENT_SESSION_KEY)) {
+              StartupUtil.runStartupWizard();
+            }
+
             final IdeaApplication app = new IdeaApplication(args);
             //noinspection SSBasedInspection
             SwingUtilities.invokeLater(new Runnable() {