org.eclipse.swt.events.MenuAdapter Java Examples
The following examples show how to use
org.eclipse.swt.events.MenuAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefactorActionGroup.java From typescript.java with MIT License | 6 votes |
private void refactorMenuShown(IMenuManager refactorSubmenu) { // we know that we have an MenuManager since we created it in // addRefactorSubmenu. Menu menu = ((MenuManager) refactorSubmenu).getMenu(); menu.addMenuListener(new MenuAdapter() { @Override public void menuHidden(MenuEvent e) { refactorMenuHidden(); } }); ITextSelection textSelection = (ITextSelection) fEditor.getSelectionProvider().getSelection(); // JavaTextSelection javaSelection= new // JavaTextSelection(getEditorInput(), getDocument(), // textSelection.getOffset(), textSelection.getLength()); for (Iterator<SelectionDispatchAction> iter = fActions.iterator(); iter.hasNext();) { SelectionDispatchAction action = iter.next(); action.update(textSelection); } refactorSubmenu.removeAll(); if (fillRefactorMenu(refactorSubmenu) == 0) refactorSubmenu.add(fNoActionAvailable); }
Example #2
Source File: RefactorActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void refactorMenuShown(IMenuManager refactorSubmenu) { // we know that we have an MenuManager since we created it in // addRefactorSubmenu. Menu menu= ((MenuManager)refactorSubmenu).getMenu(); menu.addMenuListener(new MenuAdapter() { @Override public void menuHidden(MenuEvent e) { refactorMenuHidden(); } }); ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection(); JavaTextSelection javaSelection= new JavaTextSelection(getEditorInput(), getDocument(), textSelection.getOffset(), textSelection.getLength()); for (Iterator<SelectionDispatchAction> iter= fActions.iterator(); iter.hasNext(); ) { SelectionDispatchAction action= iter.next(); action.update(javaSelection); } refactorSubmenu.removeAll(); if (fillRefactorMenu(refactorSubmenu) == 0) refactorSubmenu.add(fNoActionAvailable); }
Example #3
Source File: OccurrencesSearchMenuAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void initMenu(Menu menu) { menu.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Menu m= (Menu) e.widget; MenuItem[] items= m.getItems(); for (int i= 0; i < items.length; i++) { items[i].dispose(); } fillMenu(m); } }); }
Example #4
Source File: SurroundWithTemplateMenuAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void initMenu() { fMenu.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); for (int i=0; i < items.length; i++) { items[i].dispose(); } fillMenu(m); } }); }
Example #5
Source File: ToolbarAction.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
private void initMenu(Menu fMenu) { fMenu.addMenuListener(new MenuAdapter() { public void menuShown(MenuEvent e) { Menu m = (Menu) e.widget; MenuItem[] items = m.getItems(); for (int i = 0; i < items.length; i++) { items[i].dispose(); } fillMenu(m); } }); }
Example #6
Source File: Commands.java From Rel with Apache License 2.0 | 5 votes |
public static void linkCommand(Do command, AcceleratedMenuItem menuItem) { menuDoMapping.put(command, menuItem); menuItem.getParent().addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent arg0) { CommandActivator activator = getCommandActivator(command); if (activator != null && activator.isFullyEnabled()) { menuItem.setEnabled(true); // remove old listeners Listener[] oldListeners = menuItem.getListeners(SWT.Selection); for (Listener oldListener: oldListeners) menuItem.removeListener(SWT.Selection, oldListener); // handle CHECK and RADIO menu items if ((menuItem.getStyle() & (SWT.CHECK | SWT.RADIO)) != 0) { menuItem.setSelection(activator.getSelection()); menuItem.addListener(SWT.Selection, e -> activator.setSelection(!activator.getSelection())); } // add new listener menuItem.addListener(SWT.Selection, e -> activator.click()); // acquire the CommandActivator's tooltip menuItem.setToolTipText(activator.getToolTipText()); } else menuItem.setEnabled(false); } }); menuItem.setEnabled(false); }
Example #7
Source File: DBrowser.java From Rel with Apache License 2.0 | 5 votes |
private static void createFileMenu(Menu bar) { MenuItem fileItem = new MenuItem(bar, SWT.CASCADE); fileItem.setText("File"); Menu menu = new Menu(fileItem); fileItem.setMenu(menu); if (hasLocalRel()) { new AcceleratedMenuItem(menu, "New database\tCtrl-n", SWT.MOD1 | 'n', "NewDBIcon", e -> Core.newDatabase()); new AcceleratedMenuItem(menu, "New database from a backup", 0, "database_restore", e -> Core.restoreDatabase()); new AcceleratedMenuItem(menu, "Open local database\tCtrl-l", SWT.MOD1 | 'l', "OpenDBLocalIcon", e -> Core.openLocalDatabase()); } new AcceleratedMenuItem(menu, "Open remote database\tCtrl-r", SWT.MOD1 | 'r', "OpenDBRemoteIcon", e-> Core.openRemoteDatabase()); MenuItem recentItem = new MenuItem(menu, SWT.CASCADE); recentItem.setText("Recently-opened databases"); menu.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent arg0) { Menu recentDatabases = new Menu(menu); recentItem.setMenu(recentDatabases); String[] dbURLs = Core.getRecentlyUsedDatabaseList(); if (dbURLs.length > 0) { int recentlyUsedCount = 0; for (String dbURL: dbURLs) { if (dbURL.startsWith("db:") && !hasLocalRel()) continue; (new AcceleratedMenuItem(recentDatabases, "Open " + dbURL, 0, "OpenDBLocalIcon", e -> Core.openDatabase(dbURL))).setEnabled(Core.databaseMayExist(dbURL)); if (++recentlyUsedCount >= 20) // arbitrarily decide 20 is enough break; } new MenuItem(recentDatabases, SWT.SEPARATOR); new AcceleratedMenuItem(recentDatabases, "Clear this list...", 0, null, e -> Core.clearRecentlyUsedDatabaseList()); } } }); OSSpecific.addFileMenuItems(menu); }