All actions in AdvManager now receives their own ISdkLog.

Also added 'update' action to AvdSelector.
This commit is contained in:
Xavier Ducrohet
2009-07-01 03:07:01 -07:00
parent 1ceaaeae68
commit 59fc8c9d06
6 changed files with 204 additions and 115 deletions

View File

@@ -195,7 +195,7 @@ class UpdaterData {
// reload AVDs
if (mAvdManager != null) {
try {
mAvdManager.reloadAvds();
mAvdManager.reloadAvds(mSdkLog);
} catch (AndroidLocationException e) {
// FIXME
}
@@ -217,7 +217,7 @@ class UpdaterData {
// reload AVDs
if (mAvdManager != null) {
try {
mAvdManager.reloadAvds();
mAvdManager.reloadAvds(mSdkLog);
} catch (AndroidLocationException e) {
mSdkLog.error(e, null);
}

View File

@@ -441,28 +441,18 @@ final class AvdCreationDialog extends Dialog {
return false;
}
ISdkLog oldLog = null;
boolean success = false;
try {
// Temporarily change the AvdManager's logger for ours, since the API no longer
// takes a logger argument.
// TODO revisit this later. See comments in AvdManager#mSdkLog.
oldLog = mAvdManager.setSdkLog(log);
AvdInfo avdInfo = mAvdManager.createAvd(
avdFolder,
avdName,
target,
skinName,
sdName,
null, // hardwareConfig,
force,
log);
AvdInfo avdInfo = mAvdManager.createAvd(
avdFolder,
avdName,
target,
skinName,
sdName,
null, // hardwareConfig,
force);
success = avdInfo != null;
} finally {
mAvdManager.setSdkLog(oldLog);
}
success = avdInfo != null;
log.displayResult(success);

View File

@@ -19,6 +19,7 @@ package com.android.sdkuilib.internal.widgets;
import com.android.prefs.AndroidLocation.AndroidLocationException;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.ISdkLog;
import com.android.sdklib.NullSdkLog;
import com.android.sdklib.internal.avd.AvdManager;
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
import com.android.sdklib.internal.avd.AvdManager.AvdInfo.AvdStatus;
@@ -48,6 +49,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import java.io.IOException;
import java.util.ArrayList;
@@ -71,6 +73,7 @@ public final class AvdSelector {
private Button mNewButton;
private Button mRefreshButton;
private Button mManagerButton;
private Button mUpdateButton;
private SelectionListener mSelectionListener;
private IAvdFilter mTargetFilter;
@@ -227,7 +230,7 @@ public final class AvdSelector {
mDeleteButton = new Button(buttons, SWT.PUSH | SWT.FLAT);
mDeleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mDeleteButton.setText("Delete");
mDeleteButton.setText("Delete...");
mDeleteButton.setToolTipText("Deletes the selected AVD.");
mDeleteButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -236,6 +239,17 @@ public final class AvdSelector {
}
});
mUpdateButton = new Button(buttons, SWT.PUSH | SWT.FLAT);
mUpdateButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mUpdateButton.setText("Update...");
mUpdateButton.setToolTipText("Updates the path of the selected AVD.");
mUpdateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
onUpdate();
}
});
Label l = new Label(buttons, SWT.SEPARATOR | SWT.HORIZONTAL);
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
@@ -366,7 +380,7 @@ public final class AvdSelector {
public boolean refresh(boolean reload) {
if (reload) {
try {
mAvdManager.reloadAvds();
mAvdManager.reloadAvds(NullSdkLog.getLogger());
} catch (AndroidLocationException e) {
return false;
}
@@ -720,12 +734,29 @@ public final class AvdSelector {
return null;
}
/**
* Updates the enable state of the Details, Delete and Update buttons.
*/
private void enableActionButtons() {
boolean enabled = mIsEnabled == false ? false : getTableSelection() != null;
if (mIsEnabled == false) {
mDetailsButton.setEnabled(false);
if (mDeleteButton != null) {
mDeleteButton.setEnabled(false);
}
if (mUpdateButton != null) {
mUpdateButton.setEnabled(false);
}
} else {
AvdInfo selection = getTableSelection();
mDetailsButton.setEnabled(enabled);
if (mDeleteButton != null) {
mDeleteButton.setEnabled(enabled);
mDetailsButton.setEnabled(selection != null);
if (mDeleteButton != null) {
mDeleteButton.setEnabled(selection != null);
}
if (mUpdateButton != null) {
mUpdateButton.setEnabled(selection != null &&
selection.getStatus() == AvdStatus.ERROR_IMAGE_DIR);
}
}
}
@@ -783,6 +814,31 @@ public final class AvdSelector {
}
}
private void onUpdate() {
final AvdInfo avdInfo = getTableSelection();
// get the current Display
final Display display = mTable.getDisplay();
// log for this action.
SdkLog log = new SdkLog(
String.format("Result of updating AVD '%s':", avdInfo.getName()),
display);
// delete the AVD
try {
mAvdManager.updateAvd(avdInfo, log);
// display the result
log.displayResult(true /* success */);
refresh(false /*reload*/);
} catch (IOException e) {
log.error(e, null);
log.displayResult(false /* success */);
}
}
private void onManager() {
UpdaterWindow window = new UpdaterWindow(
mTable.getShell(),