private void initMenu() { menuSavePanel = diagramWindowManager.getCurrentSavePanel(parentComponent); boolean savePanelFocused = menuSavePanel != null; selectAllMenu.setEnabled(savePanelFocused); selectRelatedMenu.setEnabled(savePanelFocused); expandSelectionMenu.setEnabled(savePanelFocused); deselectAllMenu.setEnabled(savePanelFocused); recalculateDiagramMenuItem.setEnabled(savePanelFocused); }
// private SavePanel getGraphPanel() { // return diagramWindowManager.getCurrentSavePanel(); // // todo: this might not be the best way to do this when the tab change event could be // used // // todo: this could be casuing issues with the keyboard short cuts when the needed menu // items are dissabled //// Component focusedComponent = // FocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); //// GraphPanel graphPanel = null; //// while (focusedComponent != null) { ////// System.out.println("focus on: " + focusedComponent.toString()); //// if (focusedComponent instanceof GraphPanel) { ////// System.out.println("bingo"); //// graphPanel = (GraphPanel) focusedComponent; //// break; //// } //// focusedComponent = focusedComponent.getParent(); //// } //// return graphPanel; // } public void actionPerformed(ActionEvent e) { if (menuSavePanel == null) { // if this is a menu action then menuSavePanel was set as the menu was shown, if this is a key // event then the current save panel must be abtained menuSavePanel = diagramWindowManager.getCurrentSavePanel(parentComponent); } if (menuSavePanel != null) { if (e.getActionCommand().equals("RecalculateDiagram")) { menuSavePanel.updateGraph(); } else { menuSavePanel.doActionCommand(MouseListenerSvg.ActionCode.valueOf(e.getActionCommand())); } } enableMenuKeys(); }