summaryrefslogtreecommitdiff
path: root/sdk-updates
diff options
context:
space:
mode:
authorJoe Baker-Malone <jbakermalone@google.com>2015-04-30 14:52:10 -0700
committerJoe Baker-Malone <jbakermalone@google.com>2015-04-30 17:05:20 -0700
commit19f53264a99f41418895bac68551436e6c1e9ccd (patch)
treea24bc276f921547db790736cf591509de285e521 /sdk-updates
parentdc8a62a7dc8c1553c0caca3b8593149a85972d66 (diff)
downloadidea-19f53264a99f41418895bac68551436e6c1e9ccd.tar.gz
Fixing excessive refreshing of remote sites in sdk config
When config panels are initialized reset() is called to allow them to fetch their content. Removing unnecessary fetch that was done before that. Fixed loadSynchronously to actually wait until an existing fetch is complete before returning in the case we're not on the dispatch thread. Fixed assignment to myPackages in SdkState such that we'll always get at least empty packages, and during refresh (when run for the first time) we'll get the local packages right away. Changed the updater checker to not force a refresh of sources. Added updating message to sites page. Change-Id: Iec6d21aef56f8e0055edbf805db576a1e0cb187d
Diffstat (limited to 'sdk-updates')
-rw-r--r--sdk-updates/src/com/android/tools/idea/updater/SdkComponentSource.java2
-rw-r--r--sdk-updates/src/com/android/tools/idea/updater/configure/SdkUpdaterConfigPanel.java12
-rw-r--r--sdk-updates/src/com/android/tools/idea/updater/configure/SourcesTableModel.java19
-rw-r--r--sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.form26
-rw-r--r--sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.java21
5 files changed, 46 insertions, 34 deletions
diff --git a/sdk-updates/src/com/android/tools/idea/updater/SdkComponentSource.java b/sdk-updates/src/com/android/tools/idea/updater/SdkComponentSource.java
index 78afb695e38..2c992701223 100644
--- a/sdk-updates/src/com/android/tools/idea/updater/SdkComponentSource.java
+++ b/sdk-updates/src/com/android/tools/idea/updater/SdkComponentSource.java
@@ -100,7 +100,7 @@ public class SdkComponentSource implements ExternalComponentSource {
private Collection<UpdatableExternalComponent> getComponents(ProgressIndicator indicator, boolean remote) {
initIfNecessary();
List<UpdatableExternalComponent> result = Lists.newArrayList();
- mySdkState.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, true, null, null, null, true);
+ mySdkState.loadSynchronously(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, true, null, null, null, false);
for (UpdatablePkgInfo info : mySdkState.getPackages().getConsolidatedPkgs()) {
if (remote) {
if (info.hasRemote()) {
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 2dfb34302ff..c617e413a1b 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
@@ -71,17 +71,11 @@ public class SdkUpdaterConfigPanel {
public SdkUpdaterConfigPanel(SdkState sdkState) {
mySdkState = sdkState;
- mySdkState.loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, myUpdater, myUpdater, null,
- true); // TODO(jbakermalone): show something on error
ILogger logger = new LogWrapper(Logger.getInstance(getClass()));
mySdkSources = mySdkState.getRemoteSdk().fetchSources(RemoteSdk.DEFAULT_EXPIRATION_PERIOD_MS, logger);
- mySdkState.getRemoteSdk().fetch(mySdkSources, logger); // fetch to find any problems with the urls
mySdkSources.addChangeListener(mySourcesChangeListener);
myUpdateSitesPanel.setSdkState(sdkState);
-
mySdkLocation.setText(IdeSdks.getAndroidSdkPath().getPath());
-
- refresh();
}
public String getSdkPath() {
@@ -128,6 +122,7 @@ public class SdkUpdaterConfigPanel {
public void refresh() {
myPlatformComponentsPanel.startLoading();
myToolComponentsPanel.startLoading();
+ myUpdateSitesPanel.startLoading();
Runnable remoteComplete = new DispatchRunnable() {
@Override
@@ -135,6 +130,7 @@ public class SdkUpdaterConfigPanel {
updateItems();
myPlatformComponentsPanel.finishLoading();
myToolComponentsPanel.finishLoading();
+ myUpdateSitesPanel.finishLoading();
}
};
mySdkState.loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, myUpdater, remoteComplete, null, true);
@@ -178,15 +174,13 @@ public class SdkUpdaterConfigPanel {
}
public void reset() {
+ refresh();
myPlatformComponentsPanel.reset();
myToolComponentsPanel.reset();
myUpdateSitesPanel.reset();
-
- myRootPane.repaint();
}
public void disposeUIResources() {
- myUpdateSitesPanel.disposeUIResources();
mySdkSources.removeChangeListener(mySourcesChangeListener);
}
diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/SourcesTableModel.java b/sdk-updates/src/com/android/tools/idea/updater/configure/SourcesTableModel.java
index 41ede0072b4..162db14cc53 100644
--- a/sdk-updates/src/com/android/tools/idea/updater/configure/SourcesTableModel.java
+++ b/sdk-updates/src/com/android/tools/idea/updater/configure/SourcesTableModel.java
@@ -46,14 +46,6 @@ class SourcesTableModel extends ListTableModel<SourcesTableModel.Row> implements
private Map<String, SdkSource> myInitialItems = Maps.newHashMap();
private SdkState mySdkState;
- private Runnable mySourcesChangeListener = new Runnable() {
- @Override
- public void run() {
- mySdkState.getRemoteSdk().fetch(mySources, new LogWrapper(Logger.getInstance(SourcesTableModel.class)));
- sourcesUpdated();
- }
- };
-
SourcesTableModel() {
super();
setColumnInfos(new ColumnInfo[]{new ColumnInfo<Row, Boolean>("Enabled") {
@@ -142,16 +134,15 @@ class SourcesTableModel extends ListTableModel<SourcesTableModel.Row> implements
public void setSdkState(SdkState state) {
mySdkState = state;
mySources = state.getRemoteSdk().fetchSources(RemoteSdk.DEFAULT_EXPIRATION_PERIOD_MS, new LogWrapper(Logger.getInstance(getClass())));
- mySources.addChangeListener(mySourcesChangeListener);
for (SdkSource s : mySources.getAllSources()) {
myInitialItems.put(s.getUrl(), s);
}
- sourcesUpdated();
+ refreshSources();
}
private Map<String, Boolean> myUrlEnabledMap = Maps.newHashMap();
- private void sourcesUpdated() {
+ public void refreshSources() {
ArrayList<Row> items = Lists.newArrayList();
for (SdkSource source : mySources.getAllSources()) {
Boolean enabled = myUrlEnabledMap.get(source.getUrl());
@@ -226,7 +217,7 @@ class SourcesTableModel extends ListTableModel<SourcesTableModel.Row> implements
for (Row row : getItems()) {
row.myEnabled = row.mySource.isEnabled();
}
- sourcesUpdated();
+ refreshSources();
}
public boolean isSourcesModified() {
@@ -242,10 +233,6 @@ class SourcesTableModel extends ListTableModel<SourcesTableModel.Row> implements
return false;
}
- public void dispose() {
- mySources.removeChangeListener(mySourcesChangeListener);
- }
-
public void save() {
if (isSourcesModified()) {
mySources.saveUserAddons(new StdLogger(StdLogger.Level.WARNING));
diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.form b/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.form
index b48146bbc09..8d287cf94ea 100644
--- a/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.form
+++ b/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.android.tools.idea.updater.configure.UpdateSitesPanel">
- <grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="604" height="400"/>
@@ -28,6 +28,30 @@
<border type="none"/>
<children/>
</grid>
+ <grid id="27578" binding="mySourcesLoadingPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="none"/>
+ <children>
+ <component id="e1740" class="com.intellij.ui.components.JBLabel">
+ <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>
+ <text value="Loading sources..."/>
+ </properties>
+ </component>
+ <component id="35d4e" class="com.intellij.util.ui.AsyncProcessIcon" binding="mySourcesLoadingIcon" custom-create="true">
+ <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"/>
+ </constraints>
+ <properties/>
+ </component>
+ </children>
+ </grid>
</children>
</grid>
</form>
diff --git a/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.java b/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.java
index 40af14a398a..627cb6d5ee9 100644
--- a/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.java
+++ b/sdk-updates/src/com/android/tools/idea/updater/configure/UpdateSitesPanel.java
@@ -19,13 +19,13 @@ import com.android.tools.idea.sdk.SdkState;
import com.android.tools.idea.sdk.remote.internal.sources.SdkSources;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.AnActionButtonUpdater;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.table.JBTable;
import com.intellij.ui.table.TableView;
+import com.intellij.util.ui.AsyncProcessIcon;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -37,10 +37,12 @@ public class UpdateSitesPanel {
private JPanel myRootPanel;
private JBTable myUpdateSitesTable;
private JPanel mySourcesPanel;
+ private JPanel mySourcesLoadingPanel;
+ private AsyncProcessIcon mySourcesLoadingIcon;
private SourcesTableModel mySourcesTableModel;
- private SdkState mySdkState;
private void createUIComponents() {
+ mySourcesLoadingIcon = new AsyncProcessIcon("Loading...");
mySourcesTableModel = new SourcesTableModel();
myUpdateSitesTable = new TableView<SourcesTableModel.Row>(mySourcesTableModel);
ToolbarDecorator userDefinedDecorator = ToolbarDecorator.createDecorator(myUpdateSitesTable);
@@ -107,15 +109,20 @@ public class UpdateSitesPanel {
}
public void setSdkState(SdkState state) {
- mySdkState = state;
mySourcesTableModel.setSdkState(state);
}
- public void disposeUIResources() {
- mySourcesTableModel.dispose();
- }
-
public void save() {
mySourcesTableModel.save();
}
+
+ public void startLoading() {
+ mySourcesLoadingPanel.setVisible(true);
+ }
+
+ public void finishLoading() {
+ mySourcesTableModel.refreshSources();
+ mySourcesLoadingPanel.setVisible(false);
+ }
+
}