List of usage examples for javax.swing JMenuItem getAction
public Action getAction()
Action
for this ActionEvent
source, or null
if no Action
is set. From source file:org.kepler.gui.MenuMapper.java
/** * Recurse through all the submenu heirarchy beneath the passed JMenu * parameter, and for each "leaf node" (ie a menu item that is not a * container for other menu items), add the Action and its menu path to the * passed Map/*from ww w . j a v a 2 s . c o m*/ * * @param nextMenuItem * the JMenu to recurse into * @param menuPathBuff * a delimited String representation of the hierarchical "path" * to this menu item. This will be used as the key in the * actionsMap. For example, the "Graph Editor" menu item beneath * the "New" item on the "File" menu would have a menuPath of * File->New->Graph Editor. Delimeter is "->" (no quotes), and * spaces are allowed within menu text strings, but not around * the delimiters; i.e: New->Graph Editor is OK, but File ->New * is not. * @param MENU_PATH_DELIMITER * String * @param actionsMap * the Map containing key => value pairs of the form: menuPath * (as described above) => Action (the javax.swing.Action * assigned to this menu item) */ public static void storePTIIMenuItems(JMenuItem nextMenuItem, StringBuffer menuPathBuff, final String MENU_PATH_DELIMITER, Map<String, Action> actionsMap) { menuPathBuff.append(MENU_PATH_DELIMITER); if (nextMenuItem != null && nextMenuItem.getText() != null) { String str = nextMenuItem.getText(); // do not make the recent files menu item upper case since // it contains paths in the file system. if (menuPathBuff.toString().startsWith("FILE->RECENT FILES->")) { menuPathBuff = new StringBuffer("File->Recent Files->"); } else { str = str.toUpperCase(); } menuPathBuff.append(str); } if (isDebugging) { log.debug(menuPathBuff.toString()); } // System.out.println(menuPathBuff.toString()); if (nextMenuItem instanceof JMenu) { storePTIITopLevelMenus((JMenu) nextMenuItem, menuPathBuff.toString(), MENU_PATH_DELIMITER, actionsMap); } else { Action nextAction = nextMenuItem.getAction(); // if there is no Action, look for an ActionListener // System.out.println("Processing menu " + nextMenuItem.getText()); if (nextAction == null) { final ActionListener[] actionListeners = nextMenuItem.getActionListeners(); // System.out.println("No Action for " + nextMenuItem.getText() // + "; found " + actionListeners.length // + " ActionListeners"); if (actionListeners.length > 0) { if (isDebugging) { log.debug(actionListeners[0].getClass().getName()); } // ASSUMPTION: there is only one ActionListener nextAction = new AbstractAction() { public void actionPerformed(ActionEvent a) { actionListeners[0].actionPerformed(a); } }; // add all these values - @see diva.gui.GUIUtilities nextAction.putValue(Action.NAME, nextMenuItem.getText()); // System.out.println("storing ptII action for menu " + // nextMenuItem.getText()); nextAction.putValue(GUIUtilities.LARGE_ICON, nextMenuItem.getIcon()); nextAction.putValue(GUIUtilities.MNEMONIC_KEY, new Integer(nextMenuItem.getMnemonic())); nextAction.putValue("tooltip", nextMenuItem.getToolTipText()); nextAction.putValue(GUIUtilities.ACCELERATOR_KEY, nextMenuItem.getAccelerator()); nextAction.putValue("menuItem", nextMenuItem); } else { if (isDebugging) { log.warn("No Action or ActionListener found for " + nextMenuItem.getText()); } } } if (!actionsMap.containsValue(nextAction)) { actionsMap.put(menuPathBuff.toString(), nextAction); if (isDebugging) { log.debug(menuPathBuff.toString() + " :: ACTION: " + nextAction); } } } }
From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java
/** * Makes and returns a copy of the specified item. * * @param original The item to handle.//from ww w . j av a 2 s . c om * @return See above. */ private JMenuItem copyItem(JMenuItem original) { JMenuItem item = new JMenuItem(original.getAction()); item.setIcon(original.getIcon()); item.setText(original.getText()); item.setToolTipText(original.getToolTipText()); ActionListener[] al = original.getActionListeners(); for (int j = 0; j < al.length; j++) item.addActionListener(al[j]); return item; }
From source file:org.photovault.swingui.BrowserWindow.java
protected void createUI(PhotoCollection collection) { window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tabPane = new JTabbedPane(); queryPane = new QueryPane(); PhotoFolderTreeController treeCtrl = new PhotoFolderTreeController(window, this); viewCtrl = new PhotoViewController(window, this); treePane = treeCtrl.folderTree;// ww w . jav a2s. com viewPane = viewCtrl.getThumbPane(); previewPane = viewCtrl.getPreviewPane(); tabPane.addTab("Query", queryPane); tabPane.addTab("Folders", treePane); VolumeTreeController volTreeCtrl = new VolumeTreeController(this); JTree volumeTree = volTreeCtrl.getView(); JScrollPane voltreeScrollPane = new JScrollPane(volumeTree); voltreeScrollPane.setPreferredSize(new Dimension(200, 500)); tabPane.add("Volumes", voltreeScrollPane); // TODO: get rid of this!!!! EditSelectionColorsAction colorAction = (EditSelectionColorsAction) viewPane.getEditSelectionColorsAction(); colorAction.setPreviewCtrl(previewPane); // Set listeners to both query and folder tree panes /* If an actionEvent comes from query pane, swich to query results. */ queryPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewCtrl.setCollection(queryPane.getResultCollection()); } }); /* If the selected folder is changed in treePane, switch to that immediately */ treeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof PhotoFolder) { PhotoFolder f = (PhotoFolder) c; if (f.getExternalDir() != null) { ExternalDir ed = f.getExternalDir(); folderIndexer.updateDir(ed.getVolume(), ed.getPath()); viewCtrl.setIndexingOngoing(true); } } } } }); volTreeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof ExtDirPhotos) { ExtDirPhotos photos = (ExtDirPhotos) c; ExternalVolume vol = (ExternalVolume) viewCtrl.getDAOFactory().getVolumeDAO() .getVolume(photos.getVolId()); folderIndexer.updateDir(vol, photos.getDirPath()); viewCtrl.setIndexingOngoing(true); } } } }); collectionPane = viewCtrl.getCollectionPane(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabPane, collectionPane); split.putClientProperty(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY, new Boolean(true)); Container cp = window.getContentPane(); cp.setLayout(new BorderLayout()); cp.add(split, BorderLayout.CENTER); statusBar = new StatusBar(); cp.add(statusBar, BorderLayout.SOUTH); // Create actions for BrowserWindow UI ImageIcon indexDirIcon = getIcon("index_dir.png"); DefaultAction indexDirAction = new DefaultAction("Index directory...", indexDirIcon) { public void actionPerformed(ActionEvent e) { indexDir(); } }; indexDirAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_D); indexDirAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Index all images in a directory"); this.registerAction("new_ext_vol", indexDirAction); ImageIcon importIcon = getIcon("import.png"); importAction = new AbstractAction("Import image...", importIcon) { public void actionPerformed(ActionEvent e) { importFile(); } }; importAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); importAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); importAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Import new image into database"); ImageIcon updateIcon = getIcon("update_indexed_dirs.png"); UpdateIndexAction updateIndexAction = new UpdateIndexAction(viewCtrl, "Update indexed dirs", updateIcon, "Check for changes in previously indexed directories", KeyEvent.VK_U); this.registerAction("update_indexed_dirs", updateIndexAction); updateIndexAction.addStatusChangeListener(statusBar); ImageIcon previewTopIcon = getIcon("view_preview_top.png"); DefaultAction previewTopAction = new DefaultAction("Preview on top", previewTopIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_HORIZONTAL_THUMBS); } }; previewTopAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on top of thumbnails"); previewTopAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_T); this.registerAction("view_preview_top", previewTopAction); ImageIcon previewRightIcon = getIcon("view_preview_right.png"); DefaultAction previewRightAction = new DefaultAction("Preview on right", previewRightIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_VERTICAL_THUMBS); } }; previewRightAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on right of thumbnails"); previewRightAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_R); this.registerAction("view_preview_right", previewRightAction); ImageIcon previewNoneIcon = getIcon("view_no_preview.png"); DefaultAction previewNoneAction = new DefaultAction("No preview", previewNoneIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.ONLY_THUMBS); } }; previewNoneAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show no preview image"); previewNoneAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); this.registerAction("view_no_preview", previewNoneAction); DefaultAction previewLargeAction = new DefaultAction("Large", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(200); } }; DefaultAction previewSmallAction = new DefaultAction("Small", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(100); } }; JToolBar tb = createToolbar(); cp.add(tb, BorderLayout.NORTH); // Create the menu bar & menus JMenuBar menuBar = new JMenuBar(); window.setJMenuBar(menuBar); // File menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); JMenuItem newWindowItem = new JMenuItem("New window", KeyEvent.VK_N); newWindowItem.setIcon(getIcon("window_new.png")); newWindowItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BrowserWindow br = new BrowserWindow(getParentController(), null); // br.setVisible( true ); } }); fileMenu.add(newWindowItem); JMenuItem importItem = new JMenuItem(importAction); fileMenu.add(importItem); JMenuItem indexDirItem = new JMenuItem(indexDirAction); fileMenu.add(indexDirItem); fileMenu.add(new JMenuItem(viewCtrl.getActionAdapter("update_indexed_dirs"))); ExportSelectedAction exportAction = (ExportSelectedAction) viewPane.getExportSelectedAction(); JMenuItem exportItem = new JMenuItem(exportAction); exportAction.addStatusChangeListener(statusBar); fileMenu.add(exportItem); JMenu dbMenu = new JMenu("Database"); dbMenu.setMnemonic(KeyEvent.VK_B); dbMenu.setIcon(getIcon("empty_icon.png")); ExportMetadataAction exportMetadata = new ExportMetadataAction("Export as XML...", null, "Export whole database as XML file", KeyEvent.VK_E); dbMenu.add(new JMenuItem(exportMetadata)); ImportXMLAction importMetadata = new ImportXMLAction("Import XML data...", null, "Import data from other Photovault database as XML", KeyEvent.VK_I); importMetadata.addStatusChangeListener(statusBar); dbMenu.add(new JMenuItem(importMetadata)); fileMenu.add(dbMenu); JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.setIcon(getIcon("exit.png")); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exitItem); JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); menuBar.add(viewMenu); JMenuItem vertIconsItem = new JMenuItem(previewRightAction); viewMenu.add(vertIconsItem); JMenuItem horzIconsItem = new JMenuItem(previewTopAction); viewMenu.add(horzIconsItem); JMenuItem noPreviewItem = new JMenuItem(previewNoneAction); viewMenu.add(noPreviewItem); JMenuItem nextPhotoItem = new JMenuItem(viewPane.getSelectNextAction()); viewMenu.add(nextPhotoItem); JMenuItem prevPhotoItem = new JMenuItem(viewPane.getSelectPreviousAction()); viewMenu.add(prevPhotoItem); viewMenu.add(new JMenuItem(previewSmallAction)); viewMenu.add(new JMenuItem(previewLargeAction)); JMenu sortMenu = new JMenu("Sort by"); sortMenu.setMnemonic(KeyEvent.VK_S); sortMenu.setIcon(getIcon("empty_icon.png")); JMenuItem byDateItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingDateComparator(), "Date", null, "Order photos by date", KeyEvent.VK_D)); sortMenu.add(byDateItem); JMenuItem byPlaceItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingPlaceComparator(), "Place", null, "Order photos by shooting place", KeyEvent.VK_P)); sortMenu.add(byPlaceItem); JMenuItem byQualityItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new QualityComparator(), "Quality", null, "Order photos by quality", KeyEvent.VK_Q)); sortMenu.add(byQualityItem); viewMenu.add(sortMenu); // Set default ordering by date byDateItem.getAction().actionPerformed(new ActionEvent(this, 0, "Setting default")); JMenu imageMenu = new JMenu("Image"); imageMenu.setMnemonic(KeyEvent.VK_I); menuBar.add(imageMenu); imageMenu.add(new JMenuItem(viewPane.getEditSelectionPropsAction())); imageMenu.add(new JMenuItem(viewPane.getShowSelectedPhotoAction())); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_cw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_ccw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_180"))); imageMenu.add(new JMenuItem(previewPane.getCropAction())); imageMenu.add(new JMenuItem(viewPane.getEditSelectionColorsAction())); imageMenu.add(new JMenuItem(viewPane.getDeleteSelectedAction())); // Create the Quality submenu JMenu qualityMenu = new JMenu("Quality"); qualityMenu.setIcon(getIcon("empty_icon.png")); for (int n = 0; n < 6; n++) { Action qualityAction = viewCtrl.getActionAdapter("quality_" + n); JMenuItem qualityMenuItem = new JMenuItem(qualityAction); qualityMenu.add(qualityMenuItem); } imageMenu.add(qualityMenu); JMenu aboutMenu = new JMenu("About"); aboutMenu.setMnemonic(KeyEvent.VK_A); aboutMenu.add(new JMenuItem(new ShowAboutDlgAction("About Photovault...", null, "", null))); menuBar.add(Box.createHorizontalGlue()); menuBar.add(aboutMenu); window.pack(); window.setVisible(true); }
From source file:processing.app.Base.java
public void rebuildBoardsMenu() throws Exception { boardsCustomMenus = new LinkedList<>(); // The first custom menu is the "Board" selection submenu JMenu boardMenu = new JMenu(tr("Board")); boardMenu.putClientProperty("removeOnWindowDeactivation", true); MenuScroller.setScrollerFor(boardMenu).setTopFixedCount(1); boardMenu.add(new JMenuItem(new AbstractAction(tr("Boards Manager...")) { public void actionPerformed(ActionEvent actionevent) { String filterText = ""; String dropdownItem = ""; if (actionevent instanceof Event) { filterText = ((Event) actionevent).getPayload().get("filterText").toString(); dropdownItem = ((Event) actionevent).getPayload().get("dropdownItem").toString(); }//from w w w . j a va2 s . c om try { openBoardsManager(filterText, dropdownItem); } catch (Exception e) { //TODO show error e.printStackTrace(); } } })); boardsCustomMenus.add(boardMenu); // If there are no platforms installed we are done if (BaseNoGui.packages.size() == 0) return; // Separate "Install boards..." command from installed boards boardMenu.add(new JSeparator()); // Generate custom menus for all platforms Set<String> customMenusTitles = new LinkedHashSet<>(); for (TargetPackage targetPackage : BaseNoGui.packages.values()) { for (TargetPlatform targetPlatform : targetPackage.platforms()) { customMenusTitles.addAll(targetPlatform.getCustomMenus().values()); } } for (String customMenuTitle : customMenusTitles) { JMenu customMenu = new JMenu(tr(customMenuTitle)); customMenu.putClientProperty("removeOnWindowDeactivation", true); boardsCustomMenus.add(customMenu); } List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>(); ButtonGroup boardsButtonGroup = new ButtonGroup(); Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>(); // Cycle through all packages boolean first = true; for (TargetPackage targetPackage : BaseNoGui.packages.values()) { // For every package cycle through all platform for (TargetPlatform targetPlatform : targetPackage.platforms()) { // Add a separator from the previous platform if (!first) boardMenu.add(new JSeparator()); first = false; // Add a title for each platform String platformLabel = targetPlatform.getPreferences().get("name"); if (platformLabel != null && !targetPlatform.getBoards().isEmpty()) { JMenuItem menuLabel = new JMenuItem(tr(platformLabel)); menuLabel.setEnabled(false); boardMenu.add(menuLabel); } // Cycle through all boards of this platform for (TargetBoard board : targetPlatform.getBoards().values()) { if (board.getPreferences().get("hide") != null) continue; JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup, buttonGroupsMap, board, targetPlatform, targetPackage); boardMenu.add(item); boardsButtonGroup.add(item); } } } if (menuItemsToClickAfterStartup.isEmpty()) { menuItemsToClickAfterStartup.add(selectFirstEnabledMenuItem(boardMenu)); } for (JMenuItem menuItemToClick : menuItemsToClickAfterStartup) { menuItemToClick.setSelected(true); menuItemToClick.getAction().actionPerformed(new ActionEvent(this, -1, "")); } }
From source file:processing.app.Base.java
private void filterVisibilityOfSubsequentBoardMenus(List<JMenu> boardsCustomMenus, TargetBoard board, int fromIndex) { for (int i = fromIndex; i < boardsCustomMenus.size(); i++) { JMenu menu = boardsCustomMenus.get(i); for (int m = 0; m < menu.getItemCount(); m++) { JMenuItem menuItem = menu.getItem(m); menuItem.setVisible(menuItem.getAction().getValue("board").equals(board)); }/*from w w w . j a v a 2 s . c o m*/ menu.setVisible(ifThereAreVisibleItemsOn(menu)); if (menu.isVisible()) { JMenuItem visibleSelectedOrFirstMenuItem = selectVisibleSelectedOrFirstMenuItem(menu); if (!visibleSelectedOrFirstMenuItem.isSelected()) { visibleSelectedOrFirstMenuItem.setSelected(true); visibleSelectedOrFirstMenuItem.getAction().actionPerformed(null); } } } }
From source file:studio.ui.Studio.java
private void rebuildMenus(TabIndexChanged event) { AppMenuBar appMenubar = getJMenuBar() instanceof AppMenuBar ? (AppMenuBar) getJMenuBar() : null; ToolBarActions toolBar = null;//from ww w . j a v a 2s. c o m ActionMenu menuBar = null; if (appToolbar == null && appMenubar == null) { appToolbar = new ToolBarActions(); getContentPane().add(appToolbar, BorderLayout.NORTH); appMenubar = new AppMenuBar(); setJMenuBar(appMenubar); toolBar = new ToolBarActions("File"); menuBar = new ActionMenu("File", 'f', "File operations", (MouseAdapter) null); Action action = new NewFileAction(tabEditors, tabConsoles); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem item = new JMenuItem("Script"); item.setToolTipText("New script"); item.addMouseListener(new ActionHintsListener(tabEditors, "Create new script")); item.addActionListener(action); popupMenu.add(item); item = new JMenuItem("Project"); item.setToolTipText("New project"); item.addMouseListener(new ActionHintsListener(tabEditors, "Create new project")); try { item.addActionListener(new AddProjectAction(treeProjects)); popupMenu.add(item); } catch (StudioException ex) { } JButton button = new DropDownButton(action, popupMenu); if (button instanceof DataListener) { tabEditors.addFireDataListener((DataListener) button); } button.addMouseListener(new ActionHintsListener(tabEditors, action)); toolBar.add(button); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); action = new OpenFileAction(tabEditors, tabConsoles); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); popupMenu = null; if (studioConfig.getOpenedFiles() != null && !studioConfig.getOpenedFiles().isEmpty()) { popupMenu = new JPopupMenu(); int pos = 0; for (EditorFile file : studioConfig.getOpenedFiles()) { item = new JMenuItem((char) (pos + 48) + " " + file.getPath(), pos + 48); item.addMouseListener(new ActionHintsListener(tabEditors, "Open file " + file)); popupMenu.add(item); if (++pos > 9) { break; } } } button = new DropDownButton(action, popupMenu); if (button instanceof DataListener) { tabEditors.addFireDataListener((DataListener) button); } button.addMouseListener(new ActionHintsListener(tabEditors, action)); toolBar.add(button); appToolbar.add(toolBar); appMenubar.add(menuBar); appToolbar.add(new ToolBarActions("KDB+")); appMenubar.add(new ActionMenu("KDB+", 'k', "KDB+ databse operations", (MouseAdapter) null)); appToolbar.add(new ToolBarActions("Edit")); appMenubar.add(new ActionMenu("Edit", 'E', "Editor operations", (MouseAdapter) null)); toolBar = new ToolBarActions("Options"); appToolbar.add(toolBar); menuBar = new ActionMenu("Tools", 'T', "Tools", (MouseAdapter) null); ActionMenu opMenuBar = new ActionMenu("Options", 'O', "Studio settings", (MouseAdapter) null); ActionMenu lfMenuBar = new ActionMenu("Look and feel", 'L', "L&F", (MouseAdapter) null); LookAndFeelAction.getActionLookAndFeel(this, lfMenuBar, studioConfig); opMenuBar.add(lfMenuBar); opMenuBar.addSeparator(); action = new EditorSettingsAction(this); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); action = new TokensSettingsAction(this); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); opMenuBar.addSeparator(); action = new ConsoleSettingsAction(this); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); opMenuBar.addSeparator(); action = new ConnectionsSettingsAction(treeConnections); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); menuBar.add(opMenuBar); opMenuBar.addSeparator(); action = new GlobalSettingsAction(this); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); appMenubar.add(menuBar); opMenuBar.addSeparator(); action = new ProjectSettingsAction(this); opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); appMenubar.add(menuBar); menuBar = new ActionMenu("Help", 'H', "Help...", (MouseAdapter) null); action = new VisitKxAction(); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); menuBar.addSeparator(); action = new VisitWroclawAction(); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); menuBar.addSeparator(); action = new KeyListAction(tabEditors); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); menuBar.addSeparator(); action = new AboutAction(tabEditors); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); appMenubar.add(menuBar); menuBar.addSeparator(); action = new CheckUpdate(this); menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action))); appMenubar.add(menuBar); toolBar = null; this.setJMenuBar(appMenubar); } appToolbar.getToolBar("Edit").setVisible(event != null && event.getData() != -1); appToolbar.getToolBar("Options").setVisible(event != null && event.getData() != -1); appToolbar.getToolBar("KDB+").setVisible(event != null && event.getData() != -1); appToolbar.getToolBar("File").setVisible(event != null && event.getData() != -1); appMenubar.getMenu("Edit").setVisible(event != null && event.getData() != -1); appMenubar.getMenu("Tools").setVisible(event != null && event.getData() != -1); appMenubar.getMenu("KDB+").setVisible(event != null && event.getData() != -1); appMenubar.getMenu("File").setVisible(event != null && event.getData() != -1); if (event != null && event.getSource() instanceof EditorsTabbedPane && event.getData() != -1) { Editor editor = ((EditorsTabbedPane) event.getSource()).getEditor(event.getData()); if (editor != null) { JPopupMenu menu = editor.getComponentPopupMenu(); if (menu != null) { for (int count = 0; count < menu.getComponentCount(); count++) { if (menu.getComponent(count) instanceof JMenuItem) { JMenuItem menuItem = (JMenuItem) menu.getComponent(count); if (menuItem.getAction().getClass() == SaveAction.class) { appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction(), true); appMenubar.getMenu("File").update(tabEditors, menuItem.getAction(), true); } else { if (menuItem.getAction().getClass() == SaveAsAction.class || menuItem.getAction().getClass() == SaveAllAction.class) { appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction()); appMenubar.getMenu("File").update(tabEditors, menuItem.getAction()); } else { if (menuItem.getAction().getClass() == CloseAction.class) { appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction(), true); appMenubar.getMenu("File").update(tabEditors, menuItem.getAction(), true); } else { if (menuItem.getAction().getClass() == CloseAllAction.class) { appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction()); appMenubar.getMenu("File").update(tabEditors, menuItem.getAction()); } else { if (menuItem.getAction().getClass() == RunAction.class || menuItem.getAction().getClass() == RunLineAction.class || menuItem.getAction().getClass() == CancelRunAction.class) { appToolbar.getToolBar("KDB+").update(tabEditors, menuItem.getAction()); appMenubar.getMenu("KDB+").update(tabEditors, menuItem.getAction()); } else { if (menuItem.getAction().getClass() == ExtKit.ReplaceAction.class || menuItem.getAction() .getClass() == ActionFactory.RedoAction.class || menuItem.getAction() .getClass() == ActionFactory.UndoAction.class || menuItem.getAction() .getClass() == BaseKit.CopyAction.class || menuItem.getAction() .getClass() == BaseKit.PasteAction.class || menuItem.getAction() .getClass() == ExtKit.GotoAction.class || menuItem.getAction() .getClass() == BaseKit.SelectAllAction.class || menuItem.getAction() .getClass() == BaseKit.SelectLineAction.class || menuItem.getAction() .getClass() == BaseKit.CutAction.class) { appToolbar.getToolBar("Edit").update(tabEditors, menuItem.getAction()); if (menuItem.getAction().getClass() == ExtKit.GotoAction.class || menuItem.getAction() .getClass() == BaseKit.CopyAction.class || menuItem.getAction() .getClass() == BaseKit.SelectAllAction.class) { appMenubar.getMenu("Edit").update(tabEditors, menuItem.getAction(), true); } else { appMenubar.getMenu("Edit").update(tabEditors, menuItem.getAction()); } } } } } } } } } } } } if (event != null && event.getData() != -1 && event.getSource() instanceof EditorsTabbedPane && ((EditorsTabbedPane) event.getSource()).getEditor(event.getData()) != null) { ((EditorsTabbedPane) event.getSource()).getEditor(event.getData()).requestFocus(); } }