示例#1
0
  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);
  }
示例#2
0
  public void postState(int newState, int oldState) {
    if (newState == Player.STATE_DISCONNECTED) {
      frame.setTitle("RDV");

      controlAction.setEnabled(false);
      disconnectAction.setEnabled(false);
      saveAction.setEnabled(false);
      importAction.setEnabled(false);
      exportAction.setEnabled(false);

      controlPanel.setEnabled(false);
      markerSubmitPanel.setEnabled(false);

      ActionFactory.getInstance().getOfflineAction().setSelected(false);
    } else if (oldState == Player.STATE_DISCONNECTED) {
      frame.setTitle(rbnb.getServerName() + " - RDV");

      controlAction.setEnabled(true);
      disconnectAction.setEnabled(true);

      LocalServer localServer = LocalServer.getInstance();
      boolean offline =
          rbnb.getRBNBHostName().equals(localServer.getHost())
              && rbnb.getRBNBPortNumber() == localServer.getPort();
      saveAction.setEnabled(!offline);
      importAction.setEnabled(offline);
      exportAction.setEnabled(true);

      controlPanel.setEnabled(true);
      markerSubmitPanel.setEnabled(true);
    }

    if (newState == Player.STATE_LOADING
        || newState == Player.STATE_PLAYING
        || newState == Player.STATE_MONITORING) {
      startThrobber();
    } else if (oldState == Player.STATE_LOADING
        || oldState == Player.STATE_PLAYING
        || oldState == Player.STATE_MONITORING) {
      stopThrobber();
    }

    if (newState == Player.STATE_LOADING) {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      loadingDialog = new LoadingDialog(frame);

      new Thread() {
        public void run() {
          synchronized (loadingMonitor) {
            if (loadingDialog == null) {
              return;
            }

            try {
              loadingMonitor.wait(1000);
            } catch (InterruptedException e) {
            }

            if (loadingDialog != null) {
              loadingDialog.setVisible(true);
              loadingDialog.start();
            }
          }
        }
      }.start();
    } else if (oldState == Player.STATE_LOADING) {
      setCursor(null);

      synchronized (loadingMonitor) {
        loadingMonitor.notify();

        if (loadingDialog != null) {
          loadingDialog.close();
          loadingDialog = null;
        }
      }
    }
  }