@Override public void run(IAction action) { final Sdk sdk = Sdk.getCurrent(); if (sdk != null) { // Although orthogonal to the avd manager action, this is a good time // to check whether the SDK has changed on disk. AdtPlugin.getDefault().refreshSdk(); // Runs the updater window, directing all logs to the ADT console. AvdManagerWindow window = new AvdManagerWindow( AdtPlugin.getDisplay().getActiveShell(), new AdtConsoleSdkLog(), sdk.getSdkLocation(), AvdInvocationContext.IDE); window.open(); } else { AdtPlugin.displayError( "Android SDK", "Location of the Android SDK has not been setup in the preferences."); } }
public void run(IAction action) { final Sdk sdk = Sdk.getCurrent(); if (sdk != null) { // Runs the updater window, directing all logs to the ADT console. SdkUpdaterWindow window = new SdkUpdaterWindow( AdtPlugin.getDisplay().getActiveShell(), new AdtConsoleSdkLog(), sdk.getSdkLocation(), SdkInvocationContext.IDE); ISdkChangeListener listener = new ISdkChangeListener() { public void onSdkLoaded() { // Ignore initial load of the SDK. } /** * Unload all we can from the SDK before new packages are installed. Typically we need * to get rid of references to dx from platform-tools and to any platform resource data. * * <p>{@inheritDoc} */ public void preInstallHook() { // TODO we need to unload as much of as SDK as possible. Otherwise // on Windows we end up with Eclipse locking some files and we can't // replace them. // // At this point, we know what the user wants to install so it would be // possible to pass in flags to know what needs to be unloaded. Typically // we need to: // - unload dex if platform-tools is going to be updated. There's a vague // attempt below at removing any references to dex and GCing. Seems // to do the trick. // - unload any target that is going to be updated since it may have // resource data used by a current layout editor (e.g. data/*.ttf // and various data/res/*.xml). // // Most important we need to make sure there isn't a build going on // and if there is one, either abort it or wait for it to complete and // then we want to make sure we don't get any attempt to use the SDK // before the postInstallHook is called. if (sdk != null) { sdk.unloadTargetData(true /*preventReload*/); DexWrapper dx = sdk.getDexWrapper(); dx.unload(); } } /** * Nothing to do. We'll reparse the SDK later in onSdkReload. * * <p>{@inheritDoc} */ public void postInstallHook() {} /** * Reparse the SDK in case anything was add/removed. * * <p>{@inheritDoc} */ public void onSdkReload() { AdtPlugin.getDefault().reparseSdk(); } }; window.addListener(listener); window.open(); } else { AdtPlugin.displayError( "Android SDK", "Location of the Android SDK has not been setup in the preferences."); } }