示例#1
0
 @Action()
 public void openProject() {
   final JFileChooser chooser = new JFileChooser();
   chooser.setFileFilter(new ProjectFileFilter());
   final int option = chooser.showOpenDialog(this);
   if (JFileChooser.APPROVE_OPTION != option) {
     return;
   }
   File file = chooser.getSelectedFile();
   ResourceMap resourceMap = context.getResourceMap();
   try {
     file = file.getCanonicalFile();
     logger.info(resourceMap.getString("openProject.info.loading"), file.getName());
     projectService.openProject(file);
     logger.info(resourceMap.getString("openProject.info.loaded"), file.getName());
   } catch (IOException e) {
     logger.error(e, resourceMap.getString("openProject.error.loading"), file.getName());
   }
   try {
     // XXX we should really save connection state in the project file
     //     and restore it after re-opening
     RvConnection.resumeQueue();
   } catch (TibrvException e) {
     logger.error(e, resourceMap.getString("openProject.error.starting"), e.error);
   }
 }
示例#2
0
  private void initEditor() {
    ApplicationContext c = Application.getInstance(RoutingDemo.class).getContext();
    ActionMap appActionMap = c.getActionMap(RoutingDemo.getApplication());
    ActionMap editorActionMap = c.getActionMap(EditorController.getInstance());
    ActionMap simulationActionMap = c.getActionMap(SimulationController.getInstance());
    ResourceMap fileRm = c.getResourceMap(DocumentController.class);
    ActionMap fileActionMap = c.getActionMap(DocumentController.getInstance());

    btnNew = new JButton();
    btnNew.setAction(fileActionMap.get("newFileAction"));
    add(btnNew);

    btnLoad = new JButton();
    btnLoad.setAction(fileActionMap.get("loadFileAction"));
    add(btnLoad);

    btnReload = new JButton();
    btnReload.setAction(fileActionMap.get("reloadFileAction"));
    add(btnReload);

    btnSave = new JButton();
    btnSave.setAction(fileActionMap.get("saveFileAction"));
    add(btnSave);

    btnSaveAs = new JButton();
    btnSaveAs.setAction(fileActionMap.get("saveFileAsAction"));
    add(btnSaveAs);

    btnClose = new JButton();
    btnClose.setAction(fileActionMap.get("closeFileAction"));
    add(btnClose);

    btnExit = new JButton();
    btnExit.setAction(appActionMap.get("quit"));
    btnExit.setText("");
    btnExit.setIcon(fileRm.getImageIcon("quitAction.Action.icon"));
    add(btnExit);

    addSeparator();

    btngGroup = new ButtonGroup();

    btnSelection = new JToggleButton();
    btnSelection.setAction(editorActionMap.get("setSelectionEditorStateAction"));
    btnSelection.setText("");
    btnSelection.setIcon(fileRm.getImageIcon("selectionAction.Action.icon"));
    btnSelection.setSelected(true);
    btngGroup.add(btnSelection);
    add(btnSelection);

    btnAddNode = new JToggleButton();
    btnAddNode.setAction(editorActionMap.get("setAddNodeEditorStateAction"));
    btnAddNode.setText("");
    btnAddNode.setIcon(fileRm.getImageIcon("addPointAction.Action.icon"));
    btngGroup.add(btnAddNode);
    add(btnAddNode);

    btnAddEdge = new JToggleButton();
    btnAddEdge.setAction(editorActionMap.get("setAddEdgeEditorStateAction"));
    btnAddEdge.setText("");
    btngGroup.add(btnAddEdge);
    btnAddEdge.setIcon(fileRm.getImageIcon("addEdgeAction.Action.icon"));
    add(btnAddEdge);

    btnSetProperties = new JToggleButton();
    btnSetProperties.setAction(editorActionMap.get("setSetPropertiesEditorStateAction"));
    btnSetProperties.setText("");
    btngGroup.add(btnSetProperties);
    btnSetProperties.setIcon(fileRm.getImageIcon("setPropertiesAction.Action.icon"));
    add(btnSetProperties);

    btnSimulate = new JButton();
    btnSimulate.setAction(simulationActionMap.get("showSimulationDialogAction"));
    btnSimulate.setText("");
    btngGroup.add(btnSimulate);
    btnSimulate.setIcon(fileRm.getImageIcon("simulateAction.Action.icon"));
    add(btnSimulate);
  }
示例#3
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);
  }