• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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.AvdManagerWindow;
23 import com.android.sdkuilib.repository.AvdManagerWindow.AvdInvocationContext;
24 
25 import org.eclipse.jface.action.IAction;
26 import org.eclipse.jface.viewers.ISelection;
27 import org.eclipse.ui.IObjectActionDelegate;
28 import org.eclipse.ui.IWorkbenchPart;
29 import org.eclipse.ui.IWorkbenchWindow;
30 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
31 
32 /**
33  * Delegate for the toolbar/menu action "AVD Manager".
34  * It displays the AVD Manager window.
35  */
36 public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
37 
38     @Override
dispose()39     public void dispose() {
40         // nothing to dispose.
41     }
42 
43     @Override
init(IWorkbenchWindow window)44     public void init(IWorkbenchWindow window) {
45         // no init
46     }
47 
48     @Override
run(IAction action)49     public void run(IAction action) {
50         final Sdk sdk = Sdk.getCurrent();
51         if (sdk != null) {
52 
53             // Runs the updater window, directing all logs to the ADT console.
54 
55             AvdManagerWindow window = new AvdManagerWindow(
56                     AdtPlugin.getDisplay().getActiveShell(),
57                     new AdtConsoleSdkLog(),
58                     sdk.getSdkLocation(),
59                     AvdInvocationContext.IDE);
60             window.open();
61         } else {
62             AdtPlugin.displayError("Android SDK",
63                     "Location of the Android SDK has not been setup in the preferences.");
64         }
65     }
66 
67     @Override
selectionChanged(IAction action, ISelection selection)68     public void selectionChanged(IAction action, ISelection selection) {
69         // nothing related to the current selection.
70     }
71 
72     @Override
setActivePart(IAction action, IWorkbenchPart targetPart)73     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
74         // nothing to do.
75     }
76 }
77