本文整理了Java中org.eclipse.swt.widgets.MenuItem.getMenu()
方法的一些代码示例,展示了MenuItem.getMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.getMenu()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:getMenu
[英]Returns the receiver's cascade menu if it has one or null if it does not. Only CASCADE
menu items can have a pull down menu. The sequence of key strokes, button presses and/or button releases that are used to request a pull down menu is platform specific.
[中]如果有,则返回接收器的级联菜单;如果没有,则返回null。只有CASCADE
菜单项可以有下拉菜单。用于请求下拉菜单的按键、按钮按下和/或按钮释放顺序是特定于平台的。
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
public boolean doVisit( final Widget widget ) {
if( widget instanceof MenuItem ) {
MenuItem menuItem = ( MenuItem )widget;
if( menuItem.getMenu() == menu ) {
menuItems.add( menuItem );
}
}
// TODO [rh] find a way to cancel visitor after all menus are done?
return true;
}
} );
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Plugins menu item and all it's children
*/
public static MenuItem createPluginsMenuItem(final Menu menuParent,
final boolean showPluginViews) {
MenuItem pluginsMenuItem = createTopLevelMenuItem(menuParent,
MENU_ID_PLUGINS);
MenuBuildUtils.addMaintenanceListenerForMenu(pluginsMenuItem.getMenu(),
new MenuBuildUtils.MenuBuilder() {
@Override
public void buildMenu(Menu menu, MenuEvent menuEvent) {
PluginsMenuHelper.getInstance().buildPluginMenu(menu, showPluginViews);
}
});
return pluginsMenuItem;
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static Menu createTorrentMenuItem(final Menu menuParent) {
final Menu torrentMenu = createTopLevelMenuItem(menuParent,
MENU_ID_TORRENT).getMenu();
/*
* The Torrents menu is context-sensitive to which torrent is selected in the UI.
* For this reason we need to dynamically build the menu when ever it is about to be displayed
* so that the states of the menu items accurately reflect what was selected in the UI.
*/
MenuBuildUtils.addMaintenanceListenerForMenu(torrentMenu,
new MenuBuildUtils.MenuBuilder() {
@Override
public void buildMenu(Menu menu, MenuEvent menuEvent) {
buildTorrentMenu(menu);
}
});
return torrentMenu;
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static void createCommunityMenuItem( Menu menuParent) {
final Menu communityMenu = createTopLevelMenuItem(menuParent, MENU_ID_COMMUNITY).getMenu();
MenuBuildUtils.addMaintenanceListenerForMenu(communityMenu,
new MenuBuildUtils.MenuBuilder() {
@Override
public void buildMenu(Menu menu, MenuEvent menuEvent) {
MenuFactory.addMenuItem(communityMenu, MENU_ID_COMMUNITY_FORUMS,
new Listener() {
@Override
public void handleEvent(Event e) {
Utils.launch(Constants.URL_FORUMS);
}
});
MenuFactory.addMenuItem(communityMenu, MENU_ID_COMMUNITY_WIKI,
new Listener() {
@Override
public void handleEvent(Event e) {
Utils.launch(Constants.URL_WIKI);
}
});
MenuBuildUtils.addCommunityChatMenu( communityMenu );
MenuFactory.addVoteMenuItem(communityMenu);
MenuFactory.addBugReportMenuItem(communityMenu);
}
});
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
@Override
public Object getUIContainer(MUIElement element) {
if (!(element instanceof MMenuElement))
return null;
if (element.getParent().getWidget() instanceof MenuItem) {
MenuItem mi = (MenuItem) element.getParent().getWidget();
if (mi.getMenu() == null) {
mi.setMenu(new Menu(mi));
}
return mi.getMenu();
}
return super.getUIContainer(element);
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
@Override
public Object getUIContainer(MUIElement element) {
if (!(element instanceof MMenuElement))
return null;
if (element.getParent().getWidget() instanceof MenuItem) {
MenuItem mi = (MenuItem) element.getParent().getWidget();
if (mi.getMenu() == null) {
mi.setMenu(new Menu(mi));
}
return mi.getMenu();
}
return super.getUIContainer(element);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the File menu and all its children
*/
private void addFileMenu() {
MenuItem fileItem = MenuFactory.createFileMenuItem(menuBar);
final Menu fileMenu = fileItem.getMenu();
builFileMenu(fileMenu);
fileMenu.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
MenuItem[] menuItems = fileMenu.getItems();
for (int i = 0; i < menuItems.length; i++) {
menuItems[i].dispose();
}
builFileMenu(fileMenu);
}
});
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
@Override
public Object getUIContainer(MUIElement element) {
if (!(element instanceof MMenuElement))
return null;
if (element.getParent().getWidget() instanceof MenuItem) {
MenuItem mi = (MenuItem) element.getParent().getWidget();
if (mi.getMenu() == null) {
mi.setMenu(new Menu(mi));
}
return mi.getMenu();
}
return super.getUIContainer(element);
}
代码示例来源:origin: BiglySoftware/BiglyBT
protected void addMenuItemListener(Menu menu, Listener l) {
for (MenuItem item : menu.getItems()) {
if (item.getStyle() == SWT.CASCADE) {
addMenuItemListener(item.getMenu(), l);
} else {
item.addListener(SWT.Selection, l);
}
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the View menu and all its children
* @param parent
*/
private void addViewMenu(final Shell parent) {
try {
MenuItem viewItem = MenuFactory.createViewMenuItem(menuBar);
final Menu viewMenu = viewItem.getMenu();
viewMenu.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
Utils.disposeSWTObjects(viewMenu.getItems());
buildSimpleViewMenu(viewMenu);
}
});
} catch (Exception e) {
Debug.out("Error creating View Menu", e);
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static void performOneTimeDisable(MenuItem item,
boolean affectsChildMenuItems) {
item.setEnabled(false);
if (affectsChildMenuItems) {
Menu childMenu = item.getMenu();
if (childMenu == null)
return;
for (int i = 0; i < childMenu.getItemCount(); i++) {
childMenu.getItem(i).setEnabled(false);
}
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
@Override
public void runSupport() {
final MenuItem torrentItem = MenuFactory.findMenuItem(
mainWindow.getMainMenu().getMenu(IMenuConstants.MENU_ID_MENU_BAR),
MenuFactory.MENU_ID_TORRENT, false);
if (null != torrentItem) {
DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
final DownloadManager[] dm_final = dms;
final boolean detailed_view_final = false;
if (null == dm_final) {
torrentItem.setEnabled(false);
} else {
TableView<?> tv = SelectedContentManager.getCurrentlySelectedTableView();
torrentItem.getMenu().setData("TableView", tv);
torrentItem.getMenu().setData("downloads", dm_final);
torrentItem.getMenu().setData("is_detailed_view",
Boolean.valueOf(detailed_view_final));
torrentItem.setEnabled(true);
}
}
}
});
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
public void preserveValues( MenuItem item ) {
preserveProperty( item, PROP_TEXT, item.getText() );
preserveProperty( item, PROP_IMAGE, item.getImage() );
preserveProperty( item, PROP_MENU, item.getMenu() );
preserveProperty( item, PROP_ENABLED, item.getEnabled() );
preserveProperty( item, PROP_SELECTION, item.getSelection() );
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Window menu and all its children
* @param parent
*/
private void addWindowMenu(final Shell parent) {
MenuItem menu_window = MenuFactory.createWindowMenuItem(menuBar);
Menu windowMenu = menu_window.getMenu();
MenuFactory.addMinimizeWindowMenuItem(windowMenu);
MenuFactory.addZoomWindowMenuItem(windowMenu);
MenuFactory.addSeparatorMenuItem(windowMenu);
MenuFactory.addBlockedIPsMenuItem(windowMenu);
MenuFactory.addSeparatorMenuItem(windowMenu);
MenuFactory.addBringAllToFrontMenuItem(windowMenu);
MenuFactory.addSeparatorMenuItem(windowMenu);
MenuFactory.appendWindowMenuItems(windowMenu);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Window menu and all its children
*/
private void addWindowMenu() {
MenuItem menu_window = MenuFactory.createWindowMenuItem(menuBar);
Menu windowMenu = menu_window.getMenu();
MenuFactory.addMinimizeWindowMenuItem(windowMenu);
MenuFactory.addZoomWindowMenuItem(windowMenu);
MenuFactory.addCloseWindowMenuItem(windowMenu);
MenuFactory.addSeparatorMenuItem(windowMenu);
MenuFactory.addBringAllToFrontMenuItem(windowMenu);
MenuFactory.addCloseDetailsMenuItem(windowMenu);
MenuFactory.addCloseDownloadBarsToMenu(windowMenu);
MenuFactory.addSeparatorMenuItem(windowMenu);
MenuFactory.appendWindowMenuItems(windowMenu);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Tools menu and all its children
* @param parent
*/
private void addToolsMenu(final Shell parent) {
MenuItem item = MenuFactory.createToolsMenuItem(menuBar);
Menu toolsMenu = item.getMenu();
MenuFactory.addBlockedIPsMenuItem(toolsMenu);
MenuFactory.addConsoleMenuItem(toolsMenu);
MenuFactory.addStatisticsMenuItem(toolsMenu);
MenuFactory.addSpeedLimitsToMenu(toolsMenu);
MenuFactory.addNatTestMenuItem(toolsMenu);
MenuFactory.addSpeedTestMenuItem(toolsMenu);
MenuFactory.addSeparatorMenuItem(toolsMenu);
MenuFactory.addConfigWizardMenuItem(toolsMenu);
MenuFactory.addOptionsMenuItem(toolsMenu);
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
public void renderChanges( MenuItem item ) throws IOException {
WidgetLCAUtil.renderCustomVariant( item );
WidgetLCAUtil.renderData( item );
renderText( item );
renderMnemonicIndex( item );
renderProperty( item, PROP_IMAGE, item.getImage(), null );
WidgetLCAUtil.renderMenu( item, item.getMenu() );
renderProperty( item, PROP_ENABLED, item.getEnabled(), true );
renderProperty( item, PROP_SELECTION, item.getSelection(), false );
renderListenSelection( item );
renderListenHelp( item );
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static void updateMenuText(Object menu) {
if (menu == null)
return;
if (menu instanceof Menu) {
MenuItem[] menus = ((Menu) menu).getItems();
for (int i = 0; i < menus.length; i++) {
updateMenuText(menus[i]);
}
} else if (menu instanceof MenuItem) {
MenuItem item = (MenuItem) menu;
if (item.getData(KEY_MENU_ID) instanceof String) {
String localizationKey = (String) item.getData(KEY_MENU_ID);
if ( MessageText.keyExists( localizationKey )){
item.setText(MessageText.getString(localizationKey));
KeyBindings.setAccelerator(item, localizationKey);
}else{
Messages.updateLanguageForControl(item);
}
updateMenuText(item.getMenu());
} else {
Messages.updateLanguageForControl(item);
}
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Tools menu and all its children
*/
private void addToolsMenu() {
MenuItem toolsItem = MenuFactory.createToolsMenuItem(menuBar);
Menu toolsMenu = toolsItem.getMenu();
MenuFactory.addMyTrackerMenuItem(toolsMenu);
MenuFactory.addMySharesMenuItem(toolsMenu);
MenuFactory.addConsoleMenuItem(toolsMenu);
MenuFactory.addStatisticsMenuItem(toolsMenu);
MenuFactory.addSpeedLimitsToMenu(toolsMenu);
MenuFactory.addTransferBarToMenu(toolsMenu);
MenuFactory.addAllPeersMenuItem(toolsMenu);
MenuFactory.addClientStatsMenuItem(toolsMenu);
MenuFactory.addBlockedIPsMenuItem(toolsMenu);
MenuFactory.addSeparatorMenuItem(toolsMenu);
MenuFactory.createPluginsMenuItem(toolsMenu, false);
MenuFactory.addPairingMenuItem(toolsMenu);
MenuFactory.addOptionsMenuItem(toolsMenu);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Creates the Help menu and all its children
* @param parent
*/
private void addV2HelpMenu(final Shell parent) {
MenuItem helpItem = MenuFactory.createHelpMenuItem(menuBar);
Menu helpMenu = helpItem.getMenu();
if (!Constants.isOSX) {
MenuFactory.addAboutMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
}
MenuFactory.addReleaseNotesMenuItem(helpMenu);
MenuFactory.addWhatsNewMenuItem(helpMenu);
MenuFactory.addWikiMenuItem(helpMenu);
MenuFactory.addGetPluginsMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
if (!SystemProperties.isJavaWebStartInstance()) {
MenuFactory.addCheckUpdateMenuItem(helpMenu);
MenuFactory.addBetaMenuItem(helpMenu);
}
MenuFactory.addDonationMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
MenuFactory.addAdvancedHelpMenuItem(helpMenu);
MenuFactory.addDebugHelpMenuItem(helpMenu);
}
内容来源于网络,如有侵权,请联系作者删除!