am 68c32ee4: am d582592e: Merge change 26495 into eclair

Merge commit '68c32ee43e88e19b42caaeddb620a7f2cbf482dd'

* commit '68c32ee43e88e19b42caaeddb620a7f2cbf482dd':
  Disable menu items based on device/app selection.
This commit is contained in:
Xavier Ducrohet
2009-09-25 08:47:35 -07:00
committed by Android Git Automerger

View File

@@ -256,7 +256,6 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
private Image mTracingStopImage; private Image mTracingStopImage;
private class TableFocusListener implements ITableFocusListener { private class TableFocusListener implements ITableFocusListener {
private IFocusedTableActivator mCurrentActivator; private IFocusedTableActivator mCurrentActivator;
@@ -753,16 +752,16 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
actionMenu.addMenuListener(new MenuAdapter() { actionMenu.addMenuListener(new MenuAdapter() {
@Override @Override
public void menuShown(MenuEvent e) { public void menuShown(MenuEvent e) {
actionHaltItem.setEnabled(mTBHalt.getEnabled()); actionHaltItem.setEnabled(mTBHalt.getEnabled() && mCurrentClient != null);
actionCauseGcItem.setEnabled(mTBCauseGc.getEnabled()); actionCauseGcItem.setEnabled(mTBCauseGc.getEnabled() && mCurrentClient != null);
} }
}); });
// create Device menu items // create Device menu items
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem screenShotItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("&Screen capture...\tCTrl-S"); screenShotItem.setText("&Screen capture...\tCTrl-S");
item.setAccelerator('S' | SWT.CONTROL); screenShotItem.setAccelerator('S' | SWT.CONTROL);
item.addSelectionListener(new SelectionAdapter() { screenShotItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (mCurrentDevice != null) { if (mCurrentDevice != null) {
@@ -774,9 +773,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
new MenuItem(deviceMenu, SWT.SEPARATOR); new MenuItem(deviceMenu, SWT.SEPARATOR);
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem explorerItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("File Explorer..."); explorerItem.setText("File Explorer...");
item.addSelectionListener(new SelectionAdapter() { explorerItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
createFileExplorer(); createFileExplorer();
@@ -785,9 +784,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
new MenuItem(deviceMenu, SWT.SEPARATOR); new MenuItem(deviceMenu, SWT.SEPARATOR);
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem processItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("Show &process status..."); processItem.setText("Show &process status...");
item.addSelectionListener(new SelectionAdapter() { processItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
DeviceCommandDialog dlg; DeviceCommandDialog dlg;
@@ -796,9 +795,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
} }
}); });
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem deviceStateItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("Dump &device state..."); deviceStateItem.setText("Dump &device state...");
item.addSelectionListener(new SelectionAdapter() { deviceStateItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
DeviceCommandDialog dlg; DeviceCommandDialog dlg;
@@ -808,10 +807,10 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
} }
}); });
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem appStateItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("Dump &app state..."); appStateItem.setText("Dump &app state...");
item.setEnabled(false); appStateItem.setEnabled(false);
item.addSelectionListener(new SelectionAdapter() { appStateItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
DeviceCommandDialog dlg; DeviceCommandDialog dlg;
@@ -820,9 +819,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
} }
}); });
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem radioStateItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("Dump &radio state..."); radioStateItem.setText("Dump &radio state...");
item.addSelectionListener(new SelectionAdapter() { radioStateItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
DeviceCommandDialog dlg; DeviceCommandDialog dlg;
@@ -835,9 +834,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
} }
}); });
item = new MenuItem(deviceMenu, SWT.NONE); final MenuItem logCatItem = new MenuItem(deviceMenu, SWT.NONE);
item.setText("Run &logcat..."); logCatItem.setText("Run &logcat...");
item.addSelectionListener(new SelectionAdapter() { logCatItem.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
DeviceCommandDialog dlg; DeviceCommandDialog dlg;
@@ -847,6 +846,21 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
} }
}); });
// configure Action items based on current state
deviceMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
boolean deviceEnabled = mCurrentDevice != null;
screenShotItem.setEnabled(deviceEnabled);
explorerItem.setEnabled(deviceEnabled);
processItem.setEnabled(deviceEnabled);
deviceStateItem.setEnabled(deviceEnabled);
appStateItem.setEnabled(deviceEnabled);
radioStateItem.setEnabled(deviceEnabled);
logCatItem.setEnabled(deviceEnabled);
}
});
// create Help menu items // create Help menu items
item = new MenuItem(helpMenu, SWT.NONE); item = new MenuItem(helpMenu, SWT.NONE);
item.setText("&Contents..."); item.setText("&Contents...");