1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 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.sdkuilib.repository; 18 19 import com.android.sdkuilib.internal.repository.ui.AvdManagerWindowImpl1; 20 import com.android.sdkuilib.internal.widgets.AvdSelector; 21 import com.android.utils.ILogger; 22 23 import org.eclipse.swt.widgets.Shell; 24 25 /** 26 * Opens an AVD Manager Window. 27 * 28 * This is the public entry point for using the window. 29 */ 30 public class AvdManagerWindow { 31 32 /** The actual window implementation to which this class delegates. */ 33 private AvdManagerWindowImpl1 mWindow; 34 35 /** 36 * Enum giving some indication of what is invoking this window. 37 * The behavior and UI will change slightly depending on the context. 38 * <p/> 39 * Note: if you add Android support to your specific IDE, you might want 40 * to specialize this context enum. 41 */ 42 public enum AvdInvocationContext { 43 /** 44 * The AVD Manager is invoked from the stand-alone 'android' tool. 45 * In this mode, we present an about box, a settings page. 46 * For SdkMan2, we also have a menu bar and link to the SDK Manager 2. 47 */ 48 STANDALONE, 49 50 /** 51 * The AVD Manager is embedded as a dialog in the SDK Manager 52 * or in the {@link AvdSelector}. 53 * This is similar to the {@link #STANDALONE} mode except we don't need 54 * to display a menu bar at all since we don't want a menu item linking 55 * back to the SDK Manager and we don't need to redisplay the options 56 * and about which are already on the root window. 57 */ 58 DIALOG, 59 60 /** 61 * The AVD Manager is invoked from an IDE. 62 * In this mode, we do not modify the menu bar. 63 * There is no about box and no settings. 64 */ 65 IDE, 66 } 67 68 69 /** 70 * Creates a new window. Caller must call open(), which will block. 71 * 72 * @param parentShell Parent shell. 73 * @param sdkLog Logger. Cannot be null. 74 * @param osSdkRoot The OS path to the SDK root. 75 * @param context The {@link AvdInvocationContext} to change the behavior depending on who's 76 * opening the SDK Manager. 77 */ 78 public AvdManagerWindow( 79 Shell parentShell, 80 ILogger sdkLog, 81 String osSdkRoot, 82 AvdInvocationContext context) { 83 mWindow = new AvdManagerWindowImpl1( 84 parentShell, 85 sdkLog, 86 osSdkRoot, 87 context); 88 } 89 90 /** 91 * Opens the window. 92 */ 93 public void open() { 94 mWindow.open(); 95 } 96 } 97