Adds call back to the SDK updater for SDK content notifications.
Make ADT reload the SDK when a new package is installed/removed through the SDK Updater.
This commit is contained in:
@@ -313,16 +313,7 @@ public class AdtPlugin extends AbstractUIPlugin {
|
||||
if (checkSdkLocationAndId()) {
|
||||
// if sdk if valid, reparse it
|
||||
|
||||
// add all the opened Android projects to the list of projects to be updated
|
||||
// after the SDK is reloaded
|
||||
synchronized (getSdkLockObject()) {
|
||||
// get the project to refresh.
|
||||
IJavaProject[] androidProjects = BaseProjectHelper.getAndroidProjects();
|
||||
mPostLoadProjectsToResolve.addAll(Arrays.asList(androidProjects));
|
||||
}
|
||||
|
||||
// parse the SDK resources at the new location
|
||||
parseSdkContent();
|
||||
reparseSdk();
|
||||
}
|
||||
} else if (PREFS_BUILD_VERBOSITY.equals(property)) {
|
||||
mBuildVerbosity = BuildPreferencePage.getBuildLevel(
|
||||
@@ -1388,6 +1379,22 @@ public class AdtPlugin extends AbstractUIPlugin {
|
||||
SdkStatsService.ping("adt", versionString, getDisplay()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Reparses the content of the SDK and updates opened projects.
|
||||
*/
|
||||
public void reparseSdk() {
|
||||
// add all the opened Android projects to the list of projects to be updated
|
||||
// after the SDK is reloaded
|
||||
synchronized (getSdkLockObject()) {
|
||||
// get the project to refresh.
|
||||
IJavaProject[] androidProjects = BaseProjectHelper.getAndroidProjects();
|
||||
mPostLoadProjectsToResolve.addAll(Arrays.asList(androidProjects));
|
||||
}
|
||||
|
||||
// parse the SDK resources at the new location
|
||||
parseSdkContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints messages, associated with a project to the specified stream
|
||||
* @param stream The stream to write to
|
||||
|
||||
@@ -49,6 +49,11 @@ public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObject
|
||||
null /*sdk log*/,
|
||||
sdk.getSdkLocation(),
|
||||
false /*userCanChangeSdkRoot*/);
|
||||
window.addListeners(new UpdaterWindow.ISdkListener() {
|
||||
public void onSdkChange() {
|
||||
AdtPlugin.getDefault().reparseSdk();
|
||||
}
|
||||
});
|
||||
window.open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.sdkuilib.internal.repository;
|
||||
|
||||
import com.android.sdkuilib.internal.repository.UpdaterData.ISdkListener;
|
||||
import com.android.sdkuilib.internal.widgets.AvdSelector;
|
||||
import com.android.sdkuilib.internal.widgets.AvdSelector.DisplayMode;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.android.sdkuilib.internal.repository;
|
||||
import com.android.sdklib.internal.repository.Archive;
|
||||
import com.android.sdklib.internal.repository.IDescription;
|
||||
import com.android.sdklib.internal.repository.Package;
|
||||
import com.android.sdkuilib.internal.repository.UpdaterData.ISdkListener;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.android.sdklib.internal.repository.Archive;
|
||||
import com.android.sdklib.internal.repository.IDescription;
|
||||
import com.android.sdklib.internal.repository.Package;
|
||||
import com.android.sdklib.internal.repository.RepoSource;
|
||||
import com.android.sdkuilib.internal.repository.UpdaterData.ISdkListener;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
|
||||
|
||||
import org.eclipse.jface.dialogs.IInputValidator;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.android.sdklib.internal.repository.RepoSources;
|
||||
import com.android.sdklib.internal.repository.ToolPackage;
|
||||
import com.android.sdklib.internal.repository.Package.UpdateInfo;
|
||||
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
@@ -67,10 +68,6 @@ class UpdaterData {
|
||||
|
||||
private Shell mWindowShell;
|
||||
|
||||
public interface ISdkListener {
|
||||
void onSdkChange();
|
||||
}
|
||||
|
||||
public UpdaterData(String osSdkRoot, ISdkLog sdkLog) {
|
||||
mOsSdkRoot = osSdkRoot;
|
||||
mSdkLog = sdkLog;
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.android.sdklib.internal.repository.RepoSources;
|
||||
import com.android.sdklib.repository.SdkRepository;
|
||||
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
|
||||
import com.android.sdkuilib.internal.tasks.ProgressTaskFactory;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow.ISdkListener;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
@@ -168,6 +169,14 @@ public class UpdaterWindowImpl {
|
||||
mExtraPages.add(new Object[]{ title, pageClass });
|
||||
}
|
||||
|
||||
public void addListeners(ISdkListener listener) {
|
||||
mUpdaterData.addListeners(listener);
|
||||
}
|
||||
|
||||
public void removeListener(ISdkListener listener) {
|
||||
mUpdaterData.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to return the SWT shell.
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,17 @@ public class UpdaterWindow {
|
||||
|
||||
private UpdaterWindowImpl mWindow;
|
||||
|
||||
/**
|
||||
* Interface for listeners on SDK modifications (ie new installed compoments, or deleted
|
||||
* components)
|
||||
*/
|
||||
public interface ISdkListener {
|
||||
/**
|
||||
* Sent when the content of the SDK changed
|
||||
*/
|
||||
void onSdkChange();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new window. Caller must call open(), which will block.
|
||||
* @param sdkLog
|
||||
@@ -58,6 +69,21 @@ public class UpdaterWindow {
|
||||
mWindow.registerExtraPage(title, pageClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new listener to be notified when a change is made to the content of the SDK.
|
||||
*/
|
||||
public void addListeners(ISdkListener listener) {
|
||||
mWindow.addListeners(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a new listener to be notified anymore when a change is made to the content of
|
||||
* the SDK.
|
||||
*/
|
||||
public void removeListener(ISdkListener listener) {
|
||||
mWindow.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the window.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user