aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2010-03-25 13:31:37 -0700
committerRaphael <raphael@google.com>2010-03-25 13:31:37 -0700
commit1a6379e626588d1b3306ee89e4dc05f7b79ec103 (patch)
treea61c1c960cffd36100b6b7e3ad8b3c5370a9b5c0 /eclipse/plugins/com.android.ide.eclipse.adt
parent532bfee321d688084e0f25e5274429f73e397a66 (diff)
downloadsdk-1a6379e626588d1b3306ee89e4dc05f7b79ec103.zip
sdk-1a6379e626588d1b3306ee89e4dc05f7b79ec103.tar.gz
sdk-1a6379e626588d1b3306ee89e4dc05f7b79ec103.tar.bz2
SDK Manager: fix crash when creating new AVD with no home.
This also fixes the logging: - properly propagate the ISdkLog to the AvdCreateDialog. - properly use the ADT console for logging when invoked from Eclipse. SDK Bug 2535112 Change-Id: I9e059fe30fe02c4f5d3e70054b4454f5703df515
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java4
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AdtConsoleSdkLog.java49
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/AvdManagerAction.java29
4 files changed, 60 insertions, 26 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
index bb4d580..d6c9cd8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
@@ -25,6 +25,7 @@ import com.android.ddmuilib.IImageLoader;
import com.android.ddmuilib.ImageHelper;
import com.android.ddmuilib.TableHelper;
import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.ddms.DdmsPlugin;
import com.android.sdklib.AndroidVersion;
@@ -400,7 +401,8 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
mSdk.getSdkLocation(),
mSdk.getAvdManager(),
new NonRunningAvdFilter(),
- DisplayMode.SIMPLE_SELECTION);
+ DisplayMode.SIMPLE_SELECTION,
+ new AdtConsoleSdkLog());
mPreferredAvdSelector.setTableHeightHint(100);
mPreferredAvdSelector.setEnabled(false);
mPreferredAvdSelector.setSelectionListener(new SelectionAdapter() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
index 36bd2fc..a4c7c1f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
@@ -20,6 +20,7 @@ import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.launch.AndroidLaunchConfiguration.TargetMode;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
+import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.ddms.DdmsPlugin;
import com.android.prefs.AndroidLocation.AndroidLocationException;
@@ -199,7 +200,8 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
mPreferredAvdSelector = new AvdSelector(offsetComp,
Sdk.getCurrent().getSdkLocation(),
null /* avd manager */,
- DisplayMode.SIMPLE_CHECK);
+ DisplayMode.SIMPLE_CHECK,
+ new AdtConsoleSdkLog());
mPreferredAvdSelector.setTableHeightHint(100);
mPreferredAvdSelector.setSelectionListener(new SelectionAdapter() {
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AdtConsoleSdkLog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AdtConsoleSdkLog.java
new file mode 100755
index 0000000..062c2d4
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AdtConsoleSdkLog.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 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.sdk;
+
+import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.sdklib.ISdkLog;
+
+/**
+ * An {@link ISdkLog} logger that outputs to the ADT console.
+ */
+public class AdtConsoleSdkLog implements ISdkLog {
+
+ private static final String TAG = "SDK Manager"; //$NON-NLS-1$
+
+ public void error(Throwable t, String errorFormat, Object... args) {
+ if (t != null) {
+ AdtPlugin.logAndPrintError(t, TAG, "Error: " + errorFormat, args);
+ } else {
+ AdtPlugin.printErrorToConsole(TAG, String.format(errorFormat, args));
+ }
+ }
+
+ public void printf(String msgFormat, Object... args) {
+ String msg = String.format(msgFormat, args);
+ for (String s : msg.split("\n")) {
+ if (s.trim().length() > 0) {
+ AdtPlugin.printToConsole(TAG, s);
+ }
+ }
+ }
+
+ public void warning(String warningFormat, Object... args) {
+ AdtPlugin.printToConsole(TAG, String.format("Warning: " + warningFormat, args));
+ }
+}
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
index 1254c31..15c31f9 100755
--- 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
@@ -17,8 +17,8 @@
package com.android.ide.eclipse.adt.internal.wizards.actions;
import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
-import com.android.sdklib.ISdkLog;
import com.android.sdkuilib.repository.UpdaterWindow;
import org.eclipse.jface.action.IAction;
@@ -45,9 +45,12 @@ public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObject
public void run(IAction action) {
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 AdtSdkLogger(),
+ new AdtConsoleSdkLog(),
sdk.getSdkLocation(),
false /*userCanChangeSdkRoot*/);
window.addListeners(new UpdaterWindow.ISdkListener() {
@@ -68,26 +71,4 @@ public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObject
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// nothing to do.
}
-
- private static class AdtSdkLogger implements ISdkLog {
-
- private static final String TAG = "SDK Manager"; //$NON-NLS-1$
-
- public void error(Throwable t, String errorFormat, Object... args) {
- if (t != null) {
- AdtPlugin.logAndPrintError(t, TAG, "Error: " + errorFormat, args);
- } else {
- AdtPlugin.printErrorToConsole(TAG, String.format(errorFormat, args));
- }
- }
-
- public void printf(String msgFormat, Object... args) {
- AdtPlugin.printToConsole(TAG, String.format(msgFormat, args));
- }
-
- public void warning(String warningFormat, Object... args) {
- AdtPlugin.printToConsole(TAG, String.format("Warning: " + warningFormat, args));
- }
-
- }
}