Start plugins wizard #15
authorVassiliy <vassiliy.kudryashov@jetbrains.com>
Wed, 16 Apr 2014 16:59:36 +0000 (20:59 +0400)
committerVassiliy <vassiliy.kudryashov@jetbrains.com>
Wed, 16 Apr 2014 16:59:36 +0000 (20:59 +0400)
platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
platform/platform-impl/src/com/intellij/ide/startupWizard/StartupWizardAction.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java

diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java
new file mode 100644 (file)
index 0000000..e4b4a8e
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * 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.ide.customize;
+
+import com.intellij.CommonBundle;
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.plugins.IdeaPluginDescriptor;
+import com.intellij.ide.plugins.PluginNode;
+import com.intellij.openapi.updateSettings.impl.PluginDownloader;
+import com.intellij.ui.components.JBScrollPane;
+import com.intellij.util.ConcurrencyUtil;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardStep {
+  private static ScheduledExecutorService ourService = ConcurrencyUtil.newSingleScheduledThreadExecutor("FeaturedPlugins");
+
+  public CustomizeFeaturedPluginsStepPanel() {
+    setLayout(new GridLayout(0, 3, GAP, GAP));
+    JPanel gridPanel = new JPanel(new GridLayout(0, 3, GAP, GAP));
+    JBScrollPane scrollPane =
+      new JBScrollPane(gridPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
+
+    Map<String, String> config = PluginGroups.getInstance().getFeaturedPlugins();
+    for (Map.Entry<String, String> entry : config.entrySet()) {
+      JPanel groupPanel = new JPanel(new GridBagLayout());
+      GridBagConstraints gbc = new GridBagConstraints();
+      gbc.insets = new Insets(0, 0, 10, 0);
+      gbc.fill = GridBagConstraints.BOTH;
+      gbc.anchor = GridBagConstraints.WEST;
+      gbc.gridwidth = GridBagConstraints.REMAINDER;
+      gbc.weightx = 1;
+
+      String title = entry.getKey();
+      String s = entry.getValue();
+      int i = s.indexOf(":");
+      String topic = s.substring(0, i);
+      int j = s.indexOf(":", i + 1);
+      final String description = s.substring(i + 1, j);
+      final String pluginId = s.substring(j + 1);
+      IdeaPluginDescriptor foundDescriptor = null;
+      List<IdeaPluginDescriptor> pluginsFromRepository = PluginGroups.getInstance().getPluginsFromRepository();
+      for (IdeaPluginDescriptor descriptor : pluginsFromRepository) {
+        if (descriptor.getPluginId().getIdString().equals(pluginId)) {
+          foundDescriptor = descriptor;
+          break;
+        }
+      }
+      if (foundDescriptor == null) continue;
+      final IdeaPluginDescriptor descriptor = foundDescriptor;
+
+
+
+      JLabel titleLabel = new JLabel("<html><body><h2 style=\"text-align:left;\">" + title + "</h2></body></html>");
+      JLabel topicLabel = new JLabel("<html><body><h4 style=\"text-align:left;\">" + topic + "</h4></body></html>");
+      JLabel descriptionLabel = new JLabel("<html><body><i>" + description + "</i></body></html>") {
+        @Override
+        public Dimension getPreferredSize() {
+          Dimension size = super.getPreferredSize();
+          size.width = Math.min(size.width, 200);
+          return size;
+        }
+      };
+      final JButton installButton = new JButton("Install", AllIcons.General.DownloadPlugin);
+      installButton.addActionListener(new ActionListener() {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+          installButton.setEnabled(false);
+          installButton.setText("In progress...");
+          ourService.schedule(new Runnable() {
+            @Override
+            public void run() {
+              try {
+                PluginNode node = new PluginNode(descriptor.getPluginId());
+                node.setUrl(descriptor.getUrl());
+                PluginDownloader downloader = PluginDownloader.createDownloader(node);
+                if (downloader.prepareToInstall()) {
+                  downloader.install();
+                  onSuccess();
+                }
+                else {
+                  onFail();
+                }
+              }
+              catch (Exception ignored) {
+                ignored.printStackTrace();
+                onFail();
+              }
+            }
+
+            void onFail() {
+              //noinspection SSBasedInspection
+              SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                  installButton.setText("Cannot download plugin");
+                }
+              });
+            }
+
+            void onSuccess() {
+              //noinspection SSBasedInspection
+              SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                  installButton.setText("Installed");
+                }
+              });
+            }
+          }, 0, TimeUnit.SECONDS);
+          //PluginGroups.getInstance().setFeaturedPluginEnabled(pluginId, installButton.isSelected());
+        }
+      });
+      groupPanel.add(titleLabel, gbc);
+      groupPanel.add(topicLabel, gbc);
+      groupPanel.add(descriptionLabel, gbc);
+      gbc.weighty = 1;
+      groupPanel.add(Box.createVerticalGlue(), gbc);
+      gbc.weighty = 0;
+      groupPanel.add(installButton, gbc);
+      gbc.weighty = 1;
+      groupPanel.add(Box.createVerticalGlue(), gbc);
+      groupPanel.setBorder(BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP));
+      gridPanel.add(groupPanel);
+    }
+    setLayout(new GridLayout(1, 1));
+    add(scrollPane);
+  }
+
+  @Override
+  public String getTitle() {
+    return "Featured plugins";
+  }
+
+  @Override
+  public String getHTMLHeader() {
+    return "<html><body><h2>Download featured plugins</h2>" +
+           "We have a few plugins in our repository that most users like to download." +
+           "Perhaps, you need them too?</body></html>";
+  }
+
+  @Override
+  public String getHTMLFooter() {
+    return "New plugins can also be downloaded in " + CommonBundle.settingsTitle() + " | Plugins";
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java
new file mode 100644 (file)
index 0000000..8bbae3b
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * 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.ide.customize;
+
+import com.intellij.ide.plugins.PluginManager;
+import com.intellij.openapi.application.ApplicationNamesInfo;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.ui.JBCardLayout;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomizeIDEWizardDialog extends DialogWrapper implements ActionListener {
+  private final JButton mySkipButton = new JButton("Skip All and Set Defaults");
+  private final JButton myBackButton = new JButton("Back");
+  private final JButton myNextButton = new JButton("Next");
+
+  private final JBCardLayout myCardLayout = new JBCardLayout();
+  protected final List<AbstractCustomizeWizardStep> mySteps = new ArrayList<AbstractCustomizeWizardStep>();
+  private int myIndex = 0;
+  private final JLabel myNavigationLabel = new JLabel();
+  private final JLabel myHeaderLabel = new JLabel();
+  private final JLabel myFooterLabel = new JLabel();
+  private JPanel myContentPanel;
+
+  public CustomizeIDEWizardDialog() {
+    super(null, true, true);
+    setTitle("Customize " + ApplicationNamesInfo.getInstance().getProductName());
+    initSteps();
+    mySkipButton.addActionListener(this);
+    myBackButton.addActionListener(this);
+    myNextButton.addActionListener(this);
+    myNavigationLabel.setEnabled(false);
+    myFooterLabel.setEnabled(false);
+    init();
+    initCurrentStep();
+  }
+
+  protected void initSteps() {
+    mySteps.add(new CustomizeUIThemeStepPanel());
+    if (SystemInfo.isMac) {
+      mySteps.add(new CustomizeKeyboardSchemeStepPanel());
+    }
+    mySteps.add(new CustomizePluginsStepPanel());
+    mySteps.add(new CustomizeFeaturedPluginsStepPanel());
+  }
+
+  @Override
+  protected JComponent createCenterPanel() {
+    JPanel result = new JPanel(new BorderLayout(5, 5));
+    myContentPanel = new JPanel(myCardLayout);
+    for (AbstractCustomizeWizardStep step : mySteps) {
+      myContentPanel.add(step, step.getTitle());
+    }
+    JPanel topPanel = new JPanel(new BorderLayout(5, 5));
+    topPanel.add(myNavigationLabel, BorderLayout.NORTH);
+    topPanel.add(myHeaderLabel, BorderLayout.CENTER);
+    result.add(topPanel, BorderLayout.NORTH);
+    result.add(myContentPanel, BorderLayout.CENTER);
+    result.add(myFooterLabel, BorderLayout.SOUTH);
+    result.setPreferredSize(new Dimension(700, 600));
+    result.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+    return result;
+  }
+
+  @Override
+  protected JComponent createSouthPanel() {
+    final JPanel result = new JPanel(new GridBagLayout());
+    GridBagConstraints gbc = new GridBagConstraints();
+    gbc.insets.right = 5;
+    gbc.fill = GridBagConstraints.BOTH;
+    gbc.gridx = 0;
+    gbc.gridy = 0;
+    result.add(mySkipButton, gbc);
+    gbc.gridx++;
+    result.add(myBackButton, gbc);
+    gbc.gridx++;
+    gbc.weightx = 1;
+    result.add(Box.createHorizontalGlue(), gbc);
+    gbc.gridx++;
+    gbc.weightx = 0;
+    result.add(myNextButton, gbc);
+    result.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));
+    return result;
+  }
+
+  @Override
+  public void actionPerformed(ActionEvent e) {
+    if (e.getSource() == mySkipButton) {
+      doOKAction();
+      return;
+    }
+    if (e.getSource() == myBackButton) {
+      myIndex--;
+      initCurrentStep();
+      return;
+    }
+    if (e.getSource() == myNextButton) {
+      if (myIndex >= mySteps.size() - 1) {
+        doOKAction();
+        return;
+      }
+      myIndex++;
+      initCurrentStep();
+    }
+  }
+
+  @Override
+  protected void doOKAction() {
+    try {
+      PluginManager.saveDisabledPlugins(PluginGroups.getInstance().getDisabledPluginIds(), false);
+    }
+    catch (IOException ignored) {
+    }
+    super.doOKAction();
+  }
+
+  private void initCurrentStep() {
+    final AbstractCustomizeWizardStep myCurrentStep = mySteps.get(myIndex);
+    myCardLayout.swipe(myContentPanel, myCurrentStep.getTitle(), JBCardLayout.SwipeDirection.AUTO, new Runnable() {
+      @Override
+      public void run() {
+        Component component = myCurrentStep.getDefaultFocusedComponent();
+        if (component != null) {
+          component.requestFocus();
+        }
+      }
+    });
+
+    myBackButton.setVisible(myIndex > 0);
+    if (myIndex > 0) {
+      myBackButton.setText("Back to " + mySteps.get(myIndex - 1).getTitle());
+    }
+    mySkipButton.setText("Skip " + (myIndex > 0 ? "Remaining" : "All") + " and Set Defaults");
+
+    myNextButton.setText(myIndex < mySteps.size() - 1
+                         ? "Next: " + mySteps.get(myIndex + 1).getTitle()
+                         : "Start using " + ApplicationNamesInfo.getInstance().getFullProductName());
+    myHeaderLabel.setText(myCurrentStep.getHTMLHeader());
+    myFooterLabel.setText(myCurrentStep.getHTMLFooter());
+    StringBuilder navHTML = new StringBuilder("<html><body>");
+    for (int i = 0; i < mySteps.size(); i++) {
+      if (i > 0) navHTML.append("&nbsp;&#8594;&nbsp;");
+      if (i == myIndex) navHTML.append("<b>");
+      navHTML.append(mySteps.get(i).getTitle());
+      if (i == myIndex) navHTML.append("</b>");
+    }
+    myNavigationLabel.setText(navHTML.toString());
+  }
+
+
+  private static <T extends Component> void getChildren(@NotNull Component c, Class<? extends T> cls, List<T> accumulator) {
+    if (cls.isAssignableFrom(c.getClass())) accumulator.add((T)c);
+    if (c instanceof Container) {
+      Component[] components = ((Container)c).getComponents();
+      for (Component component : components) {
+        getChildren(component, cls, accumulator);
+      }
+    }
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java
new file mode 100644 (file)
index 0000000..eca49dd
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+ * 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.ide.customize;
+
+import com.intellij.openapi.application.ApplicationNamesInfo;
+import com.intellij.openapi.ui.VerticalFlowLayout;
+import com.intellij.ui.ColorUtil;
+import com.intellij.ui.JBCardLayout;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.border.CustomLineBorder;
+import com.intellij.ui.components.JBScrollPane;
+import com.intellij.ui.components.labels.LinkLabel;
+import com.intellij.ui.components.labels.LinkListener;
+
+import javax.swing.*;
+import javax.swing.border.CompoundBorder;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+import java.util.Map;
+
+public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep implements LinkListener<String> {
+  private static final String MAIN = "main";
+  private static final String CUSTOMIZE = "customize";
+  private static final int COLS = 3;
+  private final Color myDescriptionForeground = ColorUtil.withAlpha(UIManager.getColor("Label.foreground"), .75);
+  private static final TextProvider CUSTOMIZE_TEXT_PROVIDER = new TextProvider() {
+    @Override
+    public String getText() {
+      return "Customize...";
+    }
+  };
+  private static final String SWITCH_COMMAND = "Switch";
+  private static final String CUSTOMIZE_COMMAND = "Customize";
+  private final JBCardLayout myCardLayout;
+  private final IdSetPanel myCustomizePanel;
+
+
+  public CustomizePluginsStepPanel() {
+    myCardLayout = new JBCardLayout();
+    setLayout(myCardLayout);
+    JPanel gridPanel = new JPanel(new GridLayout(0, COLS));
+    myCustomizePanel = new IdSetPanel();
+    JBScrollPane scrollPane =
+      new JBScrollPane(gridPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
+    add(scrollPane, MAIN);
+    add(myCustomizePanel, CUSTOMIZE);
+
+    //PluginManager.loadDisabledPlugins(new File(PathManager.getConfigPath()).getPath(), myDisabledPluginIds);
+    //for (IdeaPluginDescriptor pluginDescriptor : myAllPlugins) {
+    //  if (pluginDescriptor.getPluginId().getIdString().equals("com.intellij")) {
+    ////    skip 'IDEA CORE' plugin
+        //continue;
+      //}
+    //  //PluginManager.initClassLoader(PluginGroups.class.getClassLoader(), (IdeaPluginDescriptorImpl)pluginDescriptor);
+    //}
+    Map<String, List<String>> groups = PluginGroups.getInstance().getTree();
+    for (Map.Entry<String, List<String>> entry : groups.entrySet()) {
+      final String group = entry.getKey();
+      if (PluginGroups.CORE.equals(group)) continue;
+
+      JPanel groupPanel = new JPanel(new GridBagLayout());
+      GridBagConstraints gbc = new GridBagConstraints();
+      gbc.insets = new Insets(0, 0, 10, 0);
+      gbc.fill = GridBagConstraints.BOTH;
+      gbc.gridwidth = GridBagConstraints.REMAINDER;
+      gbc.weightx = 1;
+      JLabel titleLabel = new JLabel("<html><body><h2 style=\"text-align:left;\">" + group + "</h2></body></html>") {
+        @Override
+        public boolean isEnabled() {
+          return isGroupEnabled(group);
+        }
+      };
+      groupPanel.add(titleLabel, gbc);
+      JLabel descriptionLabel = new JLabel(PluginGroups.getInstance().getDescription(group)) {
+        @Override
+        public Dimension getPreferredSize() {
+          Dimension size = super.getPreferredSize();
+          size.width = Math.min(size.width, 200);
+          return size;
+        }
+
+        @Override
+        public boolean isEnabled() {
+          return isGroupEnabled(group);
+        }
+
+        //@Override
+        //public Color getForeground() {
+        //  return isGroupEnabled(group)? myDescriptionForeground : myDescriptionDisabledForeground;
+        //}
+
+      };
+      descriptionLabel.setForeground(myDescriptionForeground);
+      groupPanel.add(descriptionLabel, gbc);
+      gbc.weighty = 1;
+      groupPanel.add(Box.createVerticalGlue(), gbc);
+      gbc.weighty = 0;
+      if (PluginGroups.getInstance().getSets(group).size() == 1) {
+        groupPanel.add(createLink(SWITCH_COMMAND + ":" + group, getGroupSwitchTextProvider(group)), gbc);
+      }
+      else {
+        JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 10, 5));
+        LinkLabel customizeButton = createLink(CUSTOMIZE_COMMAND + ":" + group, CUSTOMIZE_TEXT_PROVIDER);
+        buttonsPanel.add(customizeButton);
+        LinkLabel disableAllButton = createLink(SWITCH_COMMAND + ":" + group, getGroupSwitchTextProvider(group));
+        buttonsPanel.add(disableAllButton);
+        groupPanel.add(buttonsPanel, gbc);
+      }
+      gridPanel.add(groupPanel);
+    }
+
+    int cursor = 0;
+    Component[] components = gridPanel.getComponents();
+    int rowCount = components.length / COLS;
+    for (Component component : components) {
+      ((JComponent)component).setBorder(
+        new CompoundBorder(new CustomLineBorder(ColorUtil.withAlpha(JBColor.foreground(), .2), 0, 0, cursor / 3 < rowCount - 1 ? 1 : 0,
+                                                cursor % COLS != COLS - 1 ? 1 : 0), BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP))
+      );
+      cursor++;
+    }
+  }
+
+  @Override
+  public void linkSelected(LinkLabel linkLabel, String command) {
+    if (command == null || !command.contains(":")) return;
+    int semicolonPosition = command.indexOf(":");
+    String group = command.substring(semicolonPosition + 1);
+    command = command.substring(0, semicolonPosition);
+
+    if (SWITCH_COMMAND.equals(command)) {
+      boolean enabled = isGroupEnabled(group);
+      List<IdSet> sets = PluginGroups.getInstance().getSets(group);
+      for (IdSet idSet : sets) {
+        String[] ids = idSet.getIds();
+        for (String id : ids) {
+          PluginGroups.getInstance().setPluginEnabledWithDependencies(id, !enabled);
+        }
+      }
+      repaint();
+      return;
+    }
+    if (CUSTOMIZE_COMMAND.equals(command)) {
+      myCustomizePanel.update(group);
+      myCardLayout.show(this, CUSTOMIZE);
+    }
+  }
+
+  private LinkLabel createLink(String command, final TextProvider provider) {
+    return new LinkLabel<String>("", null, this, command) {
+      @Override
+      public String getText() {
+        return provider.getText();
+      }
+    };
+  }
+
+  TextProvider getGroupSwitchTextProvider(final String group) {
+    return new TextProvider() {
+      @Override
+      public String getText() {
+        return (isGroupEnabled(group) ? "Disable" : "Enable") +
+               (PluginGroups.getInstance().getSets(group).size() > 1 ? " All" : "");
+      }
+    };
+  }
+
+  private boolean isGroupEnabled(String group) {
+    List<IdSet> sets = PluginGroups.getInstance().getSets(group);
+    for (IdSet idSet : sets) {
+      String[] ids = idSet.getIds();
+      for (String id : ids) {
+        if (PluginGroups.getInstance().isPluginEnabled(id)) return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public String getTitle() {
+    return "Default plugins";
+  }
+
+  @Override
+  public String getHTMLHeader() {
+    return "<html><body><h2>Tune " +
+           ApplicationNamesInfo.getInstance().getProductName() +
+           " to your tasks</h2>" +
+           ApplicationNamesInfo.getInstance().getProductName() +
+           " has a lot of tools enabled by default. You can set only ones you need or leave them all." +
+           "</body></html>";
+  }
+
+  @Override
+  public String getHTMLFooter() {
+    return null;
+  }
+
+
+
+
+
+  private class IdSetPanel extends JPanel {
+    private JLabel myTitleLabel = new JLabel();
+    private JPanel myContentPanel = new JPanel(new GridLayout(0, 3, 5, 5));
+    private JButton mySaveButton = new JButton("Save Changes and Go Back");
+
+    private IdSetPanel() {
+      setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, GAP, true, false));
+      add(myTitleLabel);
+      add(myContentPanel);
+      JPanel buttonPanel = new JPanel(new BorderLayout());
+      buttonPanel.add(mySaveButton, BorderLayout.WEST);
+      buttonPanel.add(Box.createHorizontalGlue(), BorderLayout.CENTER);
+      add(buttonPanel);
+      mySaveButton.addActionListener(new ActionListener() {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+          myCardLayout.show(CustomizePluginsStepPanel.this, MAIN);
+        }
+      });
+    }
+
+    void update(String group) {
+      myTitleLabel.setText("<html><body><h2 style=\"text-align:left;\">" + group + "</h2></body></html>");
+      myContentPanel.removeAll();
+      List<IdSet> idSets = PluginGroups.getInstance().getSets(group);
+      for (final IdSet set : idSets) {
+        final JCheckBox checkBox = new JCheckBox(set.getTitle(), PluginGroups.getInstance().isIdSetAllEnabled(set));
+        checkBox.setModel(new JToggleButton.ToggleButtonModel() {
+          @Override
+          public boolean isSelected() {
+            return PluginGroups.getInstance().isIdSetAllEnabled(set);
+          }
+        });
+        checkBox.addActionListener(new ActionListener() {
+          @Override
+          public void actionPerformed(ActionEvent e) {
+            PluginGroups.getInstance().setIdSetEnabled(set, !checkBox.isSelected());
+            CustomizePluginsStepPanel.this.repaint();
+          }
+        });
+        myContentPanel.add(checkBox);
+      }
+    }
+  }
+
+  private interface TextProvider {
+    String getText();
+  }
+}
index 9959cef30030b42a13bf2151cd90097ebd226c9e..be7aa3c8f600c9abd5e8a3934ff9164f750bdccc 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.ide.plugins;
 import com.google.common.hash.Hashing;
 import com.google.common.io.Files;
 import com.intellij.ide.IdeBundle;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.PathManager;
 import com.intellij.openapi.application.ex.ApplicationInfoEx;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
@@ -32,6 +33,7 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import java.io.*;
 import java.net.HttpURLConnection;
+import java.net.URL;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
 
@@ -62,7 +64,9 @@ public class RepositoryHelper {
       }
     }
 
-    HttpURLConnection connection = HttpConfigurable.getInstance().openHttpConnection(url);
+    HttpURLConnection connection = ApplicationManager.getApplication() != null ?
+                                   HttpConfigurable.getInstance().openHttpConnection(url) :
+                                   (HttpURLConnection)new URL(url).openConnection();
     connection.setRequestProperty("Accept-Encoding", "gzip");
 
     if (indicator != null) {
index b032ae4aedaacfb32d227ef7e1c5325deea28ac3..4179543a9b90659b962d35da8e06580036c29953 100644 (file)
  */
 package com.intellij.ide.startupWizard;
 
+import com.intellij.ide.customize.CustomizeIDEWizardDialog;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.application.ApplicationNamesInfo;
-import com.intellij.openapi.project.Project;
+import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 
@@ -31,6 +31,10 @@ import com.intellij.openapi.ui.Messages;
  */
 public class StartupWizardAction extends AnAction implements DumbAware {
   public void actionPerformed(final AnActionEvent e) {
+    if (Boolean.getBoolean("idea.is.internal")) {
+      new CustomizeIDEWizardDialog().show();
+      return;
+    }
     Project project = e.getData(CommonDataKeys.PROJECT);
     final StartupWizard startupWizard = new StartupWizard(project, ApplicationInfoImpl.getShadowInstance().getPluginChooserPages());
     final String title = ApplicationNamesInfo.getInstance().getFullProductName() + " Plugin Configuration Wizard";
index bdc23622a66baffff4f8f59632c0dc4947c8c5a5..e8d8ba4335243d7d72504ea14a0fed16e887e56a 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.application.ApplicationInfo;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.extensions.PluginId;
 import com.intellij.openapi.progress.ProgressIndicator;
@@ -43,9 +44,11 @@ import org.jetbrains.annotations.Nullable;
 
 import java.io.*;
 import java.net.HttpURLConnection;
+import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * @author anna
@@ -226,12 +229,16 @@ public class PluginDownloader {
     try {
       connection = openConnection(myPluginUrl);
 
-      final InputStream is = UrlConnectionUtil.getConnectionInputStream(connection, pi);
+      final InputStream is = (ApplicationManager.getApplication() != null)
+                              ? UrlConnectionUtil.getConnectionInputStream(connection, pi)
+                              : connection.getInputStream();
       if (is == null) {
         throw new IOException("Failed to open connection");
       }
 
-      pi.setText(IdeBundle.message("progress.downloading.plugin", getPluginName()));
+      if (ApplicationManager.getApplication() != null) {
+        pi.setText(IdeBundle.message("progress.downloading.plugin", getPluginName()));
+      }
       final int contentLength = connection.getContentLength();
       pi.setIndeterminate(contentLength == -1);
 
@@ -264,7 +271,9 @@ public class PluginDownloader {
   }
 
   private URLConnection openConnection(final String url) throws IOException {
-    final URLConnection connection = HttpConfigurable.getInstance().openConnection(url);
+    final URLConnection connection = ApplicationManager.getApplication() != null
+                                     ? HttpConfigurable.getInstance().openConnection(url)
+                                     : new URL(url).openConnection();
     if (connection instanceof HttpURLConnection) {
       final int responseCode = ((HttpURLConnection)connection).getResponseCode();
       if (responseCode != HttpURLConnection.HTTP_OK) {
@@ -363,8 +372,12 @@ public class PluginDownloader {
       url = ((PluginNode)descriptor).getDownloadUrl();
     }
     if (url == null) {
-      String uuid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
-      String buildNumber = ApplicationInfo.getInstance().getApiVersion();
+      String uuid = ApplicationManager.getApplication() == null ?
+                    UUID.randomUUID().toString() :
+                    UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
+      String buildNumber = ApplicationManager.getApplication() != null
+                           ? ApplicationInfo.getInstance().getApiVersion()
+                           :  ApplicationInfoImpl.getShadowInstance().getBuild().asString();
       url = RepositoryHelper.getDownloadUrl() + URLEncoder.encode(descriptor.getPluginId().getIdString(), "UTF8") +
             "&build=" + buildNumber + "&uuid=" + URLEncoder.encode(uuid, "UTF8");
     }