From fd47d7cf39065ee72b3de3a671a59bae19f9cfec Mon Sep 17 00:00:00 2001 From: Raphael Moll Date: Thu, 17 May 2012 13:04:50 -0700 Subject: SDK Manager: display options menu when invoked from IDE. Change-Id: I03c75be4d624f841c6f4c0ba93b0951bc8da8850 --- .../repository/sdkman2/AvdManagerWindowImpl1.java | 55 ++++++++++------------ .../repository/sdkman2/SdkUpdaterWindowImpl2.java | 10 +--- 2 files changed, 28 insertions(+), 37 deletions(-) (limited to 'sdkmanager/libs/sdkuilib') diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java index 74c061f..0070097 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AvdManagerWindowImpl1.java @@ -178,6 +178,11 @@ public class AvdManagerWindowImpl1 { @SuppressWarnings("unused") // MenuBarWrapper works using side effects private void createMenuBar() { + // Only create the menu when running as standalone. + // We don't need the menu when invoked from the IDE, or the SDK Manager + // or from the AVD Chooser dialog. The only point of the menu is to + // get the about box, and invoke Tools > SDK Manager, which we don't + // need to do in these cases. if (mContext != AvdInvocationContext.STANDALONE) { return; } @@ -200,38 +205,30 @@ public class AvdManagerWindowImpl1 { } }); - if (mContext != AvdInvocationContext.IDE) { - // Note: when invoked from an IDE, the SwtMenuBar library isn't - // available. This means this source should not directly import - // any of SwtMenuBar classes, otherwise the whole window class - // would fail to load. The MenuBarWrapper below helps to make - // that indirection. - - try { - new MenuBarWrapper(APP_NAME_MAC_MENU, menuTools) { - @Override - public void onPreferencesMenuSelected() { - SettingsDialog sd = new SettingsDialog(mShell, mUpdaterData); - sd.open(); - } + try { + new MenuBarWrapper(APP_NAME_MAC_MENU, menuTools) { + @Override + public void onPreferencesMenuSelected() { + SettingsDialog sd = new SettingsDialog(mShell, mUpdaterData); + sd.open(); + } - @Override - public void onAboutMenuSelected() { - AboutDialog ad = new AboutDialog(mShell, mUpdaterData); - ad.open(); - } + @Override + public void onAboutMenuSelected() { + AboutDialog ad = new AboutDialog(mShell, mUpdaterData); + ad.open(); + } - @Override - public void printError(String format, Object... args) { - if (mUpdaterData != null) { - mUpdaterData.getSdkLog().error(null, format, args); - } + @Override + public void printError(String format, Object... args) { + if (mUpdaterData != null) { + mUpdaterData.getSdkLog().error(null, format, args); } - }; - } catch (Exception e) { - mUpdaterData.getSdkLog().error(e, "Failed to setup menu bar"); - e.printStackTrace(); - } + } + }; + } catch (Throwable e) { + mUpdaterData.getSdkLog().error(e, "Failed to setup menu bar"); + e.printStackTrace(); } } diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java index 9a7ffe1..7a7a5b3 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java @@ -320,13 +320,7 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow { mPkgPage.registerMenuAction( MenuAction.SHOW_ADDON_SITES, manageSources); - if (mContext == SdkInvocationContext.STANDALONE) { - // Note: when invoked from an IDE, the SwtMenuBar library isn't - // available. This means this source should not directly import - // any of SwtMenuBar classes, otherwise the whole window class - // would fail to load. The MenuBarWrapper below helps to make - // that indirection. - + if (mContext == SdkInvocationContext.STANDALONE || mContext == SdkInvocationContext.IDE) { try { new MenuBarWrapper(APP_NAME, menuTools) { @Override @@ -348,7 +342,7 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow { } } }; - } catch (Exception e) { + } catch (Throwable e) { mUpdaterData.getSdkLog().error(e, "Failed to setup menu bar"); e.printStackTrace(); } -- cgit v1.1