public MainPanel() { super(); this.rbnb = RBNBController.getInstance(); this.dataPanelManager = DataPanelManager.getInstance(); busyDialog = null; loadingDialog = null; // set the menu shortcut key mask in a platform independent way menuShortcutKeyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); initFrame(); }
private void initDataPanelContainer() { dataPanelContainer = dataPanelManager.getDataPanelContainer(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 0, 8, 6); c.anchor = GridBagConstraints.NORTHWEST; rightPanel.add(dataPanelContainer, c); log.info("Added data panel container."); }
private void initMenuBar() { Application application = RDV.getInstance(); ApplicationContext context = application.getContext(); ResourceMap resourceMap = context.getResourceMap(); String platform = resourceMap.getString("platform"); boolean isMac = (platform != null && platform.equals("osx")); ActionFactory actionFactory = ActionFactory.getInstance(); Actions actions = Actions.getInstance(); ActionMap actionMap = context.getActionMap(actions); menuBar = new JMenuBar(); JMenuItem menuItem; JMenu fileMenu = new JMenu(fileAction); menuItem = new JMenuItem(connectAction); fileMenu.add(menuItem); menuItem = new JMenuItem(disconnectAction); fileMenu.add(menuItem); fileMenu.addSeparator(); menuItem = new JMenuItem(loginAction); fileMenu.add(menuItem); menuItem = new JMenuItem(logoutAction); fileMenu.add(menuItem); fileMenu.addMenuListener( new MenuListener() { public void menuCanceled(MenuEvent arg0) {} public void menuDeselected(MenuEvent arg0) {} public void menuSelected(MenuEvent arg0) { if (AuthenticationManager.getInstance().getAuthentication() == null) { loginAction.setEnabled(true); logoutAction.setEnabled(false); } else { loginAction.setEnabled(false); logoutAction.setEnabled(true); } } }); fileMenu.addSeparator(); menuItem = new JMenuItem(loadAction); fileMenu.add(menuItem); menuItem = new JMenuItem(saveAction); fileMenu.add(menuItem); fileMenu.addSeparator(); fileMenu.add(new JMenuItem(actionMap.get("addLocalChannel"))); fileMenu.addSeparator(); JMenu importSubMenu = new JMenu(importAction); menuItem = new JMenuItem(actionFactory.getDataImportAction()); importSubMenu.add(menuItem); menuItem = new JMenuItem(actionFactory.getOpenSeesDataImportAction()); importSubMenu.add(menuItem); importSubMenu.add(new JMenuItem(actionMap.get("importJPEGs"))); fileMenu.add(importSubMenu); JMenu exportSubMenu = new JMenu(exportAction); menuItem = new JMenuItem(actionFactory.getDataExportAction()); exportSubMenu.add(menuItem); menuItem = new JMenuItem(exportVideoAction); exportSubMenu.add(menuItem); fileMenu.add(exportSubMenu); fileMenu.addSeparator(); menuItem = new DataViewerCheckBoxMenuItem(actionFactory.getOfflineAction()); fileMenu.add(menuItem); if (!isMac) { menuItem = new JMenuItem(exitAction); fileMenu.add(menuItem); } menuBar.add(fileMenu); JMenu controlMenu = new JMenu(controlAction); menuItem = new SelectableCheckBoxMenuItem(realTimeAction); controlMenu.add(menuItem); menuItem = new SelectableCheckBoxMenuItem(playAction); controlMenu.add(menuItem); menuItem = new SelectableCheckBoxMenuItem(pauseAction); controlMenu.add(menuItem); controlMenu.addMenuListener( new MenuListener() { public void menuCanceled(MenuEvent arg0) {} public void menuDeselected(MenuEvent arg0) {} public void menuSelected(MenuEvent arg0) { int state = rbnb.getState(); realTimeAction.setSelected(state == Player.STATE_MONITORING); playAction.setSelected(state == Player.STATE_PLAYING); pauseAction.setSelected(state == Player.STATE_STOPPED); } }); controlMenu.addSeparator(); menuItem = new JMenuItem(beginningAction); controlMenu.add(menuItem); menuItem = new JMenuItem(endAction); controlMenu.add(menuItem); menuItem = new JMenuItem(gotoTimeAction); controlMenu.add(menuItem); menuBar.add(controlMenu); controlMenu.addSeparator(); menuItem = new JMenuItem(updateChannelListAction); controlMenu.add(menuItem); controlMenu.addSeparator(); menuItem = new JCheckBoxMenuItem(dropDataAction); controlMenu.add(menuItem); JMenu viewMenu = new JMenu(viewAction); menuItem = new JCheckBoxMenuItem(showChannelListAction); menuItem.setSelected(true); viewMenu.add(menuItem); menuItem = new JCheckBoxMenuItem(showMetadataPanelAction); menuItem.setSelected(true); viewMenu.add(menuItem); menuItem = new JCheckBoxMenuItem(showControlPanelAction); menuItem.setSelected(true); viewMenu.add(menuItem); menuItem = new JCheckBoxMenuItem(showAudioPlayerPanelAction); menuItem.setSelected(false); viewMenu.add(menuItem); menuItem = new JCheckBoxMenuItem(showMarkerPanelAction); menuItem.setSelected(true); viewMenu.add(menuItem); viewMenu.addSeparator(); menuItem = new JCheckBoxMenuItem(showHiddenChannelsAction); menuItem.setSelected(false); viewMenu.add(menuItem); menuItem = new JCheckBoxMenuItem(hideEmptyTimeAction); menuItem.setSelected(false); viewMenu.add(menuItem); viewMenu.addSeparator(); menuItem = new JCheckBoxMenuItem(fullScreenAction); menuItem.setSelected(false); viewMenu.add(menuItem); menuBar.add(viewMenu); JMenu windowMenu = new JMenu(windowAction); List<Extension> extensions = dataPanelManager.getExtensions(); for (final Extension extension : extensions) { Action action = new DataViewerAction("Add " + extension.getName(), "", KeyEvent.VK_J) { /** serialization version identifier */ private static final long serialVersionUID = 36998228704476723L; public void actionPerformed(ActionEvent ae) { try { dataPanelManager.createDataPanel(extension); } catch (Exception e) { log.error( "Unable to open data panel provided by extension " + extension.getName() + " (" + extension.getID() + ")."); e.printStackTrace(); } } }; menuItem = new JMenuItem(action); windowMenu.add(menuItem); } windowMenu.addSeparator(); menuItem = new JMenuItem(closeAllDataPanelsAction); windowMenu.add(menuItem); windowMenu.addSeparator(); JMenu dataPanelSubMenu = new JMenu(dataPanelAction); ButtonGroup dataPanelLayoutGroup = new ButtonGroup(); menuItem = new JRadioButtonMenuItem(dataPanelHorizontalLayoutAction); dataPanelSubMenu.add(menuItem); dataPanelLayoutGroup.add(menuItem); menuItem = new JRadioButtonMenuItem(dataPanelVerticalLayoutAction); menuItem.setSelected(true); dataPanelSubMenu.add(menuItem); dataPanelLayoutGroup.add(menuItem); windowMenu.add(dataPanelSubMenu); menuBar.add(windowMenu); JMenu helpMenu = new JMenu(helpAction); menuItem = new JMenuItem(usersGuideAction); helpMenu.add(menuItem); menuItem = new JMenuItem(supportAction); helpMenu.add(menuItem); menuItem = new JMenuItem(releaseNotesAction); helpMenu.add(menuItem); if (!isMac) { helpMenu.addSeparator(); menuItem = new JMenuItem(aboutAction); helpMenu.add(menuItem); } menuBar.add(helpMenu); menuBar.add(Box.createHorizontalGlue()); throbberStop = DataViewer.getIcon("icons/throbber.png"); throbberAnim = DataViewer.getIcon("icons/throbber_anim.gif"); throbber = new JLabel(throbberStop); throbber.setBorder(new EmptyBorder(0, 0, 0, 4)); menuBar.add(throbber, BorderLayout.EAST); if (isMac) { registerMacOSXEvents(); } frame.setJMenuBar(menuBar); }