diff options
author | Joe Baker-Malone <jbakermalone@google.com> | 2015-07-09 22:06:51 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-07-09 22:06:52 +0000 |
commit | 851f64f398c9b250f5cdd12020a2213795c65214 (patch) | |
tree | 380b0469be29c94941126f5b795bf922c4b80ec1 /sdk-updates | |
parent | a5223030a8c0134b67b10d3461c2a19fe40e096b (diff) | |
parent | 2ba7558dbc77a7f222e2d128fe184f520f1bcc75 (diff) | |
download | idea-851f64f398c9b250f5cdd12020a2213795c65214.tar.gz |
Merge "New SDK manager during first run + better path control" into studio-1.4-dev
Diffstat (limited to 'sdk-updates')
6 files changed, 114 insertions, 50 deletions
diff --git a/sdk-updates/src/META-INF/plugin.xml b/sdk-updates/src/META-INF/plugin.xml index 19d1529080e..0270be05ff6 100644 --- a/sdk-updates/src/META-INF/plugin.xml +++ b/sdk-updates/src/META-INF/plugin.xml @@ -46,6 +46,8 @@ <actions> <action id="Android.RunAndroidSdkManager" class="com.android.tools.idea.updater.configure.RunSdkConfigAction" icon="AndroidIcons.SdkManager" overrides="true"/> + <action id="WelcomeScreen.RunAndroidSdkManager" class="com.android.tools.idea.updater.configure.RunSdkConfigAction" + icon="AndroidIcons.SdkManagerLarge" overrides="true"/> </actions> </idea-plugin> diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/CheckboxClickListener.java b/sdk-updates/src/com/android/tools/idea/updater/configure/CheckboxClickListener.java index b4a44f3484f..265e7d525c9 100644 --- a/sdk-updates/src/com/android/tools/idea/updater/configure/CheckboxClickListener.java +++ b/sdk-updates/src/com/android/tools/idea/updater/configure/CheckboxClickListener.java @@ -20,6 +20,7 @@ import com.intellij.ui.dualView.TreeTableView; import com.intellij.ui.treeStructure.treetable.TreeTableTree; import org.jetbrains.annotations.NotNull; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; @@ -38,6 +39,10 @@ class CheckboxClickListener extends ClickListener { @Override public boolean onClick(@NotNull MouseEvent e, int clickCount) { + Object source = e.getSource(); + if (source instanceof JComponent && !((JComponent)source).isEnabled()) { + return false; + } TreeTableTree tree = myTreeTable.getTree(); int row = tree.getRowForLocation(e.getX(), e.getY()); if (row < 0) { diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/PlatformComponentsPanel.java b/sdk-updates/src/com/android/tools/idea/updater/configure/PlatformComponentsPanel.java index c394ef7acc0..2b5a18666f3 100644 --- a/sdk-updates/src/com/android/tools/idea/updater/configure/PlatformComponentsPanel.java +++ b/sdk-updates/src/com/android/tools/idea/updater/configure/PlatformComponentsPanel.java @@ -186,4 +186,10 @@ public class PlatformComponentsPanel { public void setIncludePreview(boolean includePreview) { myIncludePreview = includePreview; } + + public void setEnabled(boolean enabled) { + myPlatformDetailTable.setEnabled(enabled); + myPlatformSummaryTable.setEnabled(enabled); + myPlatformDetailsCheckbox.setEnabled(enabled); + } }
\ No newline at end of file diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.form b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.form index 1677973ad77..a62867ed49d 100644 --- a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.form +++ b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.form @@ -16,26 +16,28 @@ <text value="Manager for the Android SDK and Tools used by Android Studio"/> </properties> </component> - <grid id="7bcd0" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <grid id="7bcd0" binding="mySdkLocationPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> - <grid row="1" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <grid row="1" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/> </constraints> <properties/> <border type="none"/> <children> <component id="38898" class="javax.swing.JTextField" binding="mySdkLocation"> <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"> + <minimum-size width="400" height="-1"/> + </grid> </constraints> <properties/> </component> - <component id="c575b" class="com.intellij.ui.components.JBLabel"> + <component id="c575b" class="com.intellij.ui.components.JBLabel" binding="mySdkLocationLabel"> <constraints> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> </constraints> <properties> - <enabled value="false"/> + <enabled value="true"/> <text value="Android SDK Location:"/> </properties> </component> @@ -45,14 +47,18 @@ </constraints> <properties/> </component> - <hspacer id="3b2ca"> + <component id="898d3" class="com.intellij.ui.components.JBLabel" binding="mySdkErrorLabel"> <constraints> - <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> </constraints> - </hspacer> + <properties> + <text value="SDK Location must be set"/> + <visible value="false"/> + </properties> + </component> </children> </grid> - <tabbedpane id="46ef2" class="com.intellij.ui.components.JBTabbedPane" default-binding="true"> + <tabbedpane id="46ef2" class="com.intellij.ui.components.JBTabbedPane" binding="myTabPane"> <constraints> <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"> <preferred-size width="200" height="200"/> diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.java b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.java index 703fec714d3..6dcc72bbad3 100644 --- a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.java +++ b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.java @@ -23,20 +23,30 @@ import com.android.tools.idea.sdk.remote.RemoteSdk; import com.android.tools.idea.sdk.remote.UpdatablePkgInfo; import com.android.tools.idea.sdk.remote.internal.sources.SdkSources; import com.android.tools.idea.stats.UsageTracker; +import com.android.tools.idea.welcome.config.FirstRunWizardMode; +import com.android.tools.idea.welcome.install.FirstRunWizardDefaults; +import com.android.tools.idea.welcome.wizard.InstallComponentsPath; +import com.android.tools.idea.welcome.wizard.ConsolidatedProgressStep; +import com.android.tools.idea.wizard.DialogWrapperHost; +import com.android.tools.idea.wizard.DynamicWizard; +import com.android.tools.idea.wizard.DynamicWizardHost; +import com.android.tools.idea.wizard.SingleStepPath; import com.android.utils.ILogger; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import com.google.common.collect.TreeMultimap; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ShowSettingsUtil; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.ui.InputValidator; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.updateSettings.impl.UpdateSettingsConfigurable; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.HyperlinkAdapter; import com.intellij.ui.HyperlinkLabel; +import com.intellij.ui.JBColor; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBTabbedPane; import com.intellij.ui.dualView.TreeTableView; import com.intellij.ui.table.SelectionProvider; import com.intellij.util.ui.tree.TreeUtil; @@ -71,6 +81,10 @@ public class SdkUpdaterConfigPanel { private HyperlinkLabel myLaunchStandaloneLink; private HyperlinkLabel myChannelLink; private HyperlinkLabel myEditSdkLink; + private JBTabbedPane myTabPane; + private JPanel mySdkLocationPanel; + private JBLabel mySdkLocationLabel; + private JBLabel mySdkErrorLabel; private SdkSources mySdkSources; private Runnable mySourcesChangeListener = new DispatchRunnable() { @Override @@ -123,22 +137,61 @@ public class SdkUpdaterConfigPanel { myEditSdkLink.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { - String newLocation = Messages - .showInputDialog(getComponent(), "New SDK Location:", "Set SDK Location", null, mySdkLocation.getText(), new InputValidator() { - @Override - public boolean checkInput(String inputString) { - return IdeSdks.isValidAndroidSdkPath(new File(inputString)); + final DynamicWizardHost host = new DialogWrapperHost(null); + DynamicWizard wizard = new DynamicWizard(null, null, "SDK Setup", host) { + @Override + public void init() { + ConsolidatedProgressStep progressStep = new ConsolidatedProgressStep(myHost.getDisposable(), host); + String sdkPath = mySdkLocation.getText(); + File location; + if (StringUtil.isEmpty(sdkPath)) { + location = FirstRunWizardDefaults.getInitialSdkLocation(FirstRunWizardMode.MISSING_SDK); } + else { + location = new File(sdkPath); + } + InstallComponentsPath path = + new InstallComponentsPath(progressStep, FirstRunWizardMode.MISSING_SDK, location, + mySdkState.getPackages().getRemotePkgInfos()); + progressStep.setPaths(Lists.newArrayList(path)); + addPath(path); + addPath(new SingleStepPath(progressStep)); + super.init(); + } - @Override - public boolean canClose(String inputString) { - return checkInput(inputString); + @Override + public void performFinishingActions() { + final File newPath = IdeSdks.getAndroidSdkPath(); + if (newPath != null) { + mySdkState = SdkState.getInstance(AndroidSdkData.getSdkData(newPath)); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + mySdkLocation.setText(newPath.getAbsolutePath()); + refresh(); + } + }); } - }); - setSdkPath(newLocation); + } + + @NotNull + @Override + protected String getProgressTitle() { + return "Setting up SDK..."; + } + + @Override + protected String getWizardActionDescription() { + return "Setting up SDK..."; + } + }; + wizard.init(); + wizard.show(); } }); mySdkLocation.setEditable(false); + mySdkErrorLabel.setIcon(AllIcons.General.BalloonError); + mySdkErrorLabel.setForeground(JBColor.RED); } public void setIncludePreview(boolean includePreview) { @@ -227,6 +280,8 @@ public class SdkUpdaterConfigPanel { } public void refresh() { + validate(); + myPlatformComponentsPanel.startLoading(); myToolComponentsPanel.startLoading(); myUpdateSitesPanel.startLoading(); @@ -243,6 +298,19 @@ public class SdkUpdaterConfigPanel { mySdkState.loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, myUpdater, remoteComplete, null, true); } + private void validate() { + AndroidSdkData data = mySdkState.getSdkData(); + File sdkLocation = null; + if (data != null) { + sdkLocation = data.getLocation(); + } + boolean valid = sdkLocation != null; + myTabPane.setEnabled(valid); + myPlatformComponentsPanel.setEnabled(valid); + mySdkLocationLabel.setForeground(valid ? JBColor.foreground() : JBColor.RED); + mySdkErrorLabel.setVisible(!valid); + } + private void loadPackages(SdkPackages packages) { Multimap<AndroidVersion, UpdatablePkgInfo> platformPackages = TreeMultimap.create(); Set<UpdatablePkgInfo> buildToolsPackages = Sets.newTreeSet(); @@ -291,7 +359,10 @@ public class SdkUpdaterConfigPanel { public void reset() { refresh(); - mySdkLocation.setText(IdeSdks.getAndroidSdkPath().getPath()); + File path = IdeSdks.getAndroidSdkPath(); + if (path != null) { + mySdkLocation.setText(path.getPath()); + } myPlatformComponentsPanel.reset(); myToolComponentsPanel.reset(); myUpdateSitesPanel.reset(); @@ -305,27 +376,6 @@ public class SdkUpdaterConfigPanel { myUpdateSitesPanel.save(); } - private void setSdkPath(String newLocation) { - final File currentPath = IdeSdks.getAndroidSdkPath(); - assert currentPath != null; // shouldn't be able to get to this point without sdk set. - final File newPath = new File(newLocation); - assert IdeSdks.isValidAndroidSdkPath(newPath); - - if (FileUtil.filesEqual(currentPath, newPath)) { - return; - } - - List<Sdk> sdks = IdeSdks.setAndroidSdkPath(newPath, null); - if (sdks.isEmpty()) { - Messages.showErrorDialog(getComponent(), "Failed to set SDK path"); - } - else { - mySdkState = SdkState.getInstance(AndroidSdkData.getSdkData(newPath)); - mySdkLocation.setText(newPath.getAbsolutePath()); - refresh(); - } - } - private static class CycleAction extends AbstractAction { boolean myBackward; diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigurable.java b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigurable.java index 3ab21b26e15..4ec026e8fa8 100644 --- a/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigurable.java +++ b/sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigurable.java @@ -78,11 +78,6 @@ public class SdkUpdaterConfigurable implements SearchableConfigurable { @Override public JComponent createComponent() { AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk(); - if (data == null) { - JPanel errorPanel = new JPanel(); - errorPanel.add(new JBLabel("Failed to find android sdk")); - return errorPanel; - } final Runnable channelChangedCallback = new Runnable() { @Override public void run() { |