Plug the Android SDK window as the AVD manager.

- the "manager" button on the AVD selector (when not in manager
  will open the Android SDK window

- the AVD manager in the eclipse toolsbar open the Android SDK
  window as well.

Still left to do:
- remove the now obsolete AVD wizard
- figure out what to do with the other pages.
This commit is contained in:
Xavier Ducrohet
2009-06-30 06:38:30 -07:00
parent a944e34f1c
commit e78015c12d
5 changed files with 65 additions and 13 deletions

View File

@@ -4,7 +4,7 @@
* 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
@@ -16,19 +16,48 @@
package com.android.ide.eclipse.adt.internal.wizards.actions;
import com.android.ide.eclipse.adt.internal.wizards.avdmanager.AvdManagerWizard;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdkuilib.repository.UpdaterWindow;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IWorkbenchWizard;
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 extends OpenWizardAction {
public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
@Override
protected IWorkbenchWizard instanciateWizard(IAction action) {
return new AvdManagerWizard();
public void dispose() {
// nothing to dispose.
}
public void init(IWorkbenchWindow window) {
// no init
}
public void run(IAction action) {
Sdk sdk = Sdk.getCurrent();
if (sdk != null) {
UpdaterWindow window = new UpdaterWindow(
AdtPlugin.getDisplay().getActiveShell(),
null /*sdk log*/,
sdk.getSdkLocation(),
false /*userCanChangeSdkRoot*/);
window.open();
}
}
public void selectionChanged(IAction action, ISelection selection) {
// nothing related to the current selection.
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// nothing to do.
}
}

View File

@@ -243,6 +243,7 @@ class Main {
System.out.printf("No command line parameters provided, launching UI.\n" +
"See 'android --help' for operations from the command line.\n");
UpdaterWindow window = new UpdaterWindow(
null /* parentShell */,
mSdkLog,
mOsSdkFolder,
false /*userCanChangeSdkRoot*/);

View File

@@ -46,6 +46,7 @@ import java.util.ArrayList;
*/
public class UpdaterWindowImpl {
private final Shell mParentShell;
/** Internal data shared between the window and its pages. */
private final UpdaterData mUpdaterData;
/** The array of pages instances. Only one is visible at a time. */
@@ -70,7 +71,9 @@ public class UpdaterWindowImpl {
private AvdManagerPage mAvdManagerPage;
private StackLayout mStackLayout;
public UpdaterWindowImpl(ISdkLog sdkLog, String osSdkRoot, boolean userCanChangeSdkRoot) {
public UpdaterWindowImpl(Shell parentShell, ISdkLog sdkLog, String osSdkRoot,
boolean userCanChangeSdkRoot) {
mParentShell = parentShell;
mUpdaterData = new UpdaterData(osSdkRoot, sdkLog);
mUpdaterData.setUserCanChangeSdkRoot(userCanChangeSdkRoot);
}
@@ -80,7 +83,9 @@ public class UpdaterWindowImpl {
* @wbp.parser.entryPoint
*/
public void open() {
Display.setAppName("Android"); //$hide$ (hide from SWT designer)
if (mParentShell == null) {
Display.setAppName("Android"); //$hide$ (hide from SWT designer)
}
createContents();
mAndroidSdkUpdater.open();
@@ -102,7 +107,7 @@ public class UpdaterWindowImpl {
* Create contents of the window.
*/
protected void createContents() {
mAndroidSdkUpdater = new Shell();
mAndroidSdkUpdater = new Shell(mParentShell);
mAndroidSdkUpdater.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
onAndroidSdkUpdaterDispose(); //$hide$ (hide from SWT designer)
@@ -251,6 +256,10 @@ public class UpdaterWindowImpl {
*/
@SuppressWarnings("unchecked")
private void addExtraPages() {
if (mExtraPages == null) {
return;
}
for (Object[] extraPage : mExtraPages) {
String title = (String) extraPage[0];
Class<? extends Composite> clazz = (Class<? extends Composite>) extraPage[1];

View File

@@ -23,6 +23,7 @@ import com.android.sdklib.internal.avd.AvdManager;
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
import com.android.sdklib.internal.avd.AvdManager.AvdInfo.AvdStatus;
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
import com.android.sdkuilib.repository.UpdaterWindow;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
@@ -252,7 +253,7 @@ public final class AvdSelector {
mManagerButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
onManager();
}
});
}
@@ -707,6 +708,16 @@ public final class AvdSelector {
}
}
private void onManager() {
UpdaterWindow window = new UpdaterWindow(
mTable.getShell(),
null /*sdk log*/,
mAvdManager.getSdkManager().getLocation(),
false /*userCanChangeSdkRoot*/);
window.open();
refresh(true /*reload*/); // UpdaterWindow uses its own AVD manager so this one must reload.
}
/**
* Collects all log from the AVD action and displays it in a dialog.
*/

View File

@@ -20,6 +20,7 @@ import com.android.sdklib.ISdkLog;
import com.android.sdkuilib.internal.repository.UpdaterWindowImpl;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
/**
* Opens an SDK Updater Window.
@@ -37,8 +38,9 @@ public class UpdaterWindow {
* @param userCanChangeSdkRoot If true, the window lets the user change the SDK path
* being browsed.
*/
public UpdaterWindow(ISdkLog sdkLog, String osSdkRoot, boolean userCanChangeSdkRoot) {
mWindow = new UpdaterWindowImpl(sdkLog, osSdkRoot, userCanChangeSdkRoot);
public UpdaterWindow(Shell parentShell, ISdkLog sdkLog, String osSdkRoot,
boolean userCanChangeSdkRoot) {
mWindow = new UpdaterWindowImpl(parentShell, sdkLog, osSdkRoot, userCanChangeSdkRoot);
}
/**