public ShellMenu(final Matcher<String>... matchers) { this.matchers = matchers; setMacOsMenuProperties(); if (!isSubmenuOfMacEclipseMenu) { MenuLookup ml = new MenuLookup(); menuItem = ml.lookFor(ml.getActiveShellTopMenuItems(), matchers); } }
@Override public boolean isSelected() { MenuLookup l = new MenuLookup(); if (menuItem != null) { return l.isSelected(menuItem); } else { return false; } }
@Override public String getText() { if (!isSubmenuOfMacEclipseMenu) { MenuLookup ml = new MenuLookup(); MenuItem i = ml.lookFor(ml.getActiveShellTopMenuItems(), matchers); String text = ml.getMenuItemText(i); return text; } else { return "&" + macEclipseMenuCommand.text; } }
@Override public void select() { if (!isSubmenuOfMacEclipseMenu) { MenuLookup ml = new MenuLookup(); ml.select(menuItem); } else { if (macEclipseMenuCommand.equals(MacEclipseMenuCommand.PREFERENCES)) { openPreferencesDialog(); } else if (macEclipseMenuCommand.equals(MacEclipseMenuCommand.ABOUT)) { openAboutDialog(); } else { throw new SWTLayerException( "Unsupported Mac Eclispe menu command: " + macEclipseMenuCommand); } } }