From 9f5f7f1bba88a85f9fbb827e36cbc93d4a8bb499 Mon Sep 17 00:00:00 2001 From: Raphael Moll Date: Fri, 27 May 2011 18:03:33 -0700 Subject: SdkManager: Refactor name of UpdaterWindow. Since the sdkmanager now contains separate windows for the "SDK Updater" versus the "AVD Manager", the various UpdaterWindow classes are renamed to SdkUpdateWindow. We already have now a standalone AvdManagerWindow that matches this pattern. This is a pure refactoring/renaming CL with no workflow change whatsoever. Change-Id: I18ecb6aa33b7e9bd2294a959b371b424d03b2060 --- .../plugins/com.android.ide.eclipse.adt/plugin.xml | 4 +- .../adt/internal/actions/SdkAvdManagerAction.java | 132 +++++++++++++++++++++ .../internal/launch/AndroidLaunchController.java | 4 +- .../internal/wizards/actions/AvdManagerAction.java | 132 --------------------- 4 files changed, 136 insertions(+), 136 deletions(-) create mode 100755 eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkAvdManagerAction.java delete mode 100755 eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/AvdManagerAction.java (limited to 'eclipse') diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml index 9e1a770..a1cafc7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml @@ -742,9 +742,9 @@ label="Android SDK and AVD Manager" visible="true"> + * {@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) { + DexWrapper dx = sdk.getDexWrapper(); + dx.unload(); + } + } + + /** + * Nothing to do. We'll reparse the SDK later in onSdkReload. + *

+ * {@inheritDoc} + */ + public void postInstallHook() { + } + + /** + * Reparse the SDK in case anything was add/removed. + *

+ * {@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."); + } + } + + public void selectionChanged(IAction action, ISelection selection) { + // nothing related to the current selection. + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // nothing to do. + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java index 4db603e..1b17e09 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java @@ -30,6 +30,7 @@ import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener; import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener; import com.android.ddmlib.ClientData.DebuggerStatus; import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.actions.SdkAvdManagerAction; import com.android.ide.eclipse.adt.internal.launch.AndroidLaunchConfiguration.TargetMode; import com.android.ide.eclipse.adt.internal.launch.DelayedLaunchInfo.InstallRetryMode; import com.android.ide.eclipse.adt.internal.launch.DeviceChooserDialog.DeviceChooserResponse; @@ -39,7 +40,6 @@ import com.android.ide.eclipse.adt.internal.project.ApkInstallManager; import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; import com.android.ide.eclipse.adt.internal.project.ProjectHelper; import com.android.ide.eclipse.adt.internal.sdk.Sdk; -import com.android.ide.eclipse.adt.internal.wizards.actions.AvdManagerAction; import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; @@ -497,7 +497,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener Shell shell = display.getActiveShell(); if (MessageDialog.openQuestion(shell, "Android AVD Error", "No compatible targets were found. Do you wish to a add new Android Virtual Device?")) { - AvdManagerAction action = new AvdManagerAction(); + SdkAvdManagerAction action = new SdkAvdManagerAction(); action.run(null /*action*/); searchAgain[0] = true; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/AvdManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/AvdManagerAction.java deleted file mode 100755 index ded5919..0000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/AvdManagerAction.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.internal.build.DexWrapper; -import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog; -import com.android.ide.eclipse.adt.internal.sdk.Sdk; -import com.android.sdkuilib.repository.ISdkChangeListener; -import com.android.sdkuilib.repository.UpdaterWindow; -import com.android.sdkuilib.repository.UpdaterWindow.InvocationContext; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -/** - * Delegate for the toolbar/menu action "Android AVD Manager". - * It displays the Android AVD Manager. - */ -public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate { - - public void dispose() { - // nothing to dispose. - } - - public void init(IWorkbenchWindow window) { - // no init - } - - public void run(IAction action) { - final Sdk sdk = Sdk.getCurrent(); - if (sdk != null) { - - // Runs the updater window, directing all logs to the ADT console. - - UpdaterWindow window = new UpdaterWindow( - AdtPlugin.getDisplay().getActiveShell(), - new AdtConsoleSdkLog(), - sdk.getSdkLocation(), - InvocationContext.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. - *

- * {@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) { - DexWrapper dx = sdk.getDexWrapper(); - dx.unload(); - } - } - - /** - * Nothing to do. We'll reparse the SDK later in onSdkReload. - *

- * {@inheritDoc} - */ - public void postInstallHook() { - } - - /** - * Reparse the SDK in case anything was add/removed. - *

- * {@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."); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - // nothing related to the current selection. - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // nothing to do. - } -} -- cgit v1.1