1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.wizards.actions; 18 19 import com.android.ide.eclipse.adt.AdtPlugin; 20 import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog; 21 import com.android.ide.eclipse.adt.internal.sdk.Sdk; 22 import com.android.sdkuilib.repository.UpdaterWindow; 23 24 import org.eclipse.jface.action.IAction; 25 import org.eclipse.jface.viewers.ISelection; 26 import org.eclipse.ui.IObjectActionDelegate; 27 import org.eclipse.ui.IWorkbenchPart; 28 import org.eclipse.ui.IWorkbenchWindow; 29 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 30 31 /** 32 * Delegate for the toolbar/menu action "Android AVD Manager". 33 * It displays the Android AVD Manager. 34 */ 35 public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate { 36 dispose()37 public void dispose() { 38 // nothing to dispose. 39 } 40 init(IWorkbenchWindow window)41 public void init(IWorkbenchWindow window) { 42 // no init 43 } 44 run(IAction action)45 public void run(IAction action) { 46 Sdk sdk = Sdk.getCurrent(); 47 if (sdk != null) { 48 49 // Runs the updater window, directing all logs to the ADT console. 50 51 UpdaterWindow window = new UpdaterWindow( 52 AdtPlugin.getDisplay().getActiveShell(), 53 new AdtConsoleSdkLog(), 54 sdk.getSdkLocation(), 55 false /*userCanChangeSdkRoot*/); 56 window.addListeners(new UpdaterWindow.ISdkListener() { 57 public void onSdkChange(boolean init) { 58 if (init == false) { // ignore initial load of the SDK. 59 AdtPlugin.getDefault().reparseSdk(); 60 } 61 } 62 }); 63 window.open(); 64 } else { 65 AdtPlugin.displayError("Android SDK", 66 "Location of the Android SDK has not been setup in the preferences."); 67 } 68 } 69 selectionChanged(IAction action, ISelection selection)70 public void selectionChanged(IAction action, ISelection selection) { 71 // nothing related to the current selection. 72 } 73 setActivePart(IAction action, IWorkbenchPart targetPart)74 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 75 // nothing to do. 76 } 77 } 78