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

@@ -16,19 +16,48 @@
package com.android.ide.eclipse.adt.internal.wizards.actions; 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.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". * Delegate for the toolbar/menu action "Android AVD Manager".
* It displays the Android AVD Manager. * It displays the Android AVD Manager.
*/ */
public class AvdManagerAction extends OpenWizardAction { public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
@Override public void dispose() {
protected IWorkbenchWizard instanciateWizard(IAction action) { // nothing to dispose.
return new AvdManagerWizard(); }
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" + System.out.printf("No command line parameters provided, launching UI.\n" +
"See 'android --help' for operations from the command line.\n"); "See 'android --help' for operations from the command line.\n");
UpdaterWindow window = new UpdaterWindow( UpdaterWindow window = new UpdaterWindow(
null /* parentShell */,
mSdkLog, mSdkLog,
mOsSdkFolder, mOsSdkFolder,
false /*userCanChangeSdkRoot*/); false /*userCanChangeSdkRoot*/);

View File

@@ -46,6 +46,7 @@ import java.util.ArrayList;
*/ */
public class UpdaterWindowImpl { public class UpdaterWindowImpl {
private final Shell mParentShell;
/** Internal data shared between the window and its pages. */ /** Internal data shared between the window and its pages. */
private final UpdaterData mUpdaterData; private final UpdaterData mUpdaterData;
/** The array of pages instances. Only one is visible at a time. */ /** The array of pages instances. Only one is visible at a time. */
@@ -70,7 +71,9 @@ public class UpdaterWindowImpl {
private AvdManagerPage mAvdManagerPage; private AvdManagerPage mAvdManagerPage;
private StackLayout mStackLayout; 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 = new UpdaterData(osSdkRoot, sdkLog);
mUpdaterData.setUserCanChangeSdkRoot(userCanChangeSdkRoot); mUpdaterData.setUserCanChangeSdkRoot(userCanChangeSdkRoot);
} }
@@ -80,7 +83,9 @@ public class UpdaterWindowImpl {
* @wbp.parser.entryPoint * @wbp.parser.entryPoint
*/ */
public void open() { public void open() {
if (mParentShell == null) {
Display.setAppName("Android"); //$hide$ (hide from SWT designer) Display.setAppName("Android"); //$hide$ (hide from SWT designer)
}
createContents(); createContents();
mAndroidSdkUpdater.open(); mAndroidSdkUpdater.open();
@@ -102,7 +107,7 @@ public class UpdaterWindowImpl {
* Create contents of the window. * Create contents of the window.
*/ */
protected void createContents() { protected void createContents() {
mAndroidSdkUpdater = new Shell(); mAndroidSdkUpdater = new Shell(mParentShell);
mAndroidSdkUpdater.addDisposeListener(new DisposeListener() { mAndroidSdkUpdater.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) { public void widgetDisposed(DisposeEvent e) {
onAndroidSdkUpdaterDispose(); //$hide$ (hide from SWT designer) onAndroidSdkUpdaterDispose(); //$hide$ (hide from SWT designer)
@@ -251,6 +256,10 @@ public class UpdaterWindowImpl {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void addExtraPages() { private void addExtraPages() {
if (mExtraPages == null) {
return;
}
for (Object[] extraPage : mExtraPages) { for (Object[] extraPage : mExtraPages) {
String title = (String) extraPage[0]; String title = (String) extraPage[0];
Class<? extends Composite> clazz = (Class<? extends Composite>) extraPage[1]; 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;
import com.android.sdklib.internal.avd.AvdManager.AvdInfo.AvdStatus; import com.android.sdklib.internal.avd.AvdManager.AvdInfo.AvdStatus;
import com.android.sdkuilib.internal.repository.icons.ImageFactory; import com.android.sdkuilib.internal.repository.icons.ImageFactory;
import com.android.sdkuilib.repository.UpdaterWindow;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
@@ -252,7 +253,7 @@ public final class AvdSelector {
mManagerButton.addSelectionListener(new SelectionAdapter() { mManagerButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { 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. * 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 com.android.sdkuilib.internal.repository.UpdaterWindowImpl;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
/** /**
* Opens an SDK Updater Window. * 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 * @param userCanChangeSdkRoot If true, the window lets the user change the SDK path
* being browsed. * being browsed.
*/ */
public UpdaterWindow(ISdkLog sdkLog, String osSdkRoot, boolean userCanChangeSdkRoot) { public UpdaterWindow(Shell parentShell, ISdkLog sdkLog, String osSdkRoot,
mWindow = new UpdaterWindowImpl(sdkLog, osSdkRoot, userCanChangeSdkRoot); boolean userCanChangeSdkRoot) {
mWindow = new UpdaterWindowImpl(parentShell, sdkLog, osSdkRoot, userCanChangeSdkRoot);
} }
/** /**