public void runInBackground() {
   ApplicationContext appC = qedit.QEditApp.getInstance().getContext();
   TaskMonitor taskMonitor = appC.getTaskMonitor();
   TaskService taskService = appC.getTaskService();
   taskService.execute(this);
   taskMonitor.setForegroundTask(this);
 }
Beispiel #2
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);
   }
 }
Beispiel #3
0
 private JMenu createFileMenu() {
   ActionMap actionMap = context.getActionMap(this);
   final JMenu file = new JMenu("File");
   file.setMnemonic('f');
   file.add(actionMap.get("openProject"));
   final JMenu fileRecent = new JMenu("Recent Projects");
   fileRecent.setIcon(new ImageIcon("/resources/icons/open.png"));
   fileRecent.addMenuListener(new RecentProjectsMenuManager(application, projectService));
   file.add(fileRecent);
   file.addSeparator();
   final JMenu fileExport = new JMenu("Export To");
   fileExport.setIcon(new ImageIcon("/resources/icons/exportTo.png"));
   fileExport.add(application.getAction(ExportToHtml.COMMAND));
   fileExport.add(application.getAction(ExportToRecordBundle.COMMAND));
   file.add(fileExport);
   final JMenu fileImport = new JMenu("Import From");
   fileExport.setIcon(new ImageIcon("/resources/icons/import.png"));
   fileImport.add(application.getAction(ImportFromRecordBundle.COMMAND));
   file.add(fileImport);
   file.addSeparator();
   file.add(application.getAction(NewRvConnection.COMMAND));
   final JMenu connRecent = new JMenu("Recent Connections");
   connRecent.addMenuListener(new RecentConnectionsMenuManager(application));
   file.add(connRecent);
   return file;
 }
Beispiel #4
0
 private JToolBar createToolBar() {
   ActionMap actionMap = context.getActionMap(this);
   final JToolBar toolbar = new JToolBar();
   toolbar.setFloatable(false);
   toolbar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));
   toolbar.setRollover(true);
   toolbar.add(actionMap.get("openProject"));
   toolbar.addSeparator();
   toolbar.add(application.getAction(NewRvConnection.COMMAND));
   toolbar.addSeparator();
   toolbar.add(application.getAction(ClearLedger.COMMAND));
   toolbar.addSeparator();
   toolbar.add(application.getAction(PauseAllConnections.COMMAND));
   final Component[] components = toolbar.getComponents();
   for (int i = 0, imax = components.length; i < imax; ++i) {
     Component component = components[i];
     if (component instanceof AbstractButton) {
       ((AbstractButton) component).setBorderPainted(false);
       ((AbstractButton) component).setOpaque(false);
     }
   }
   return toolbar;
 }
Beispiel #5
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);
  }
Beispiel #6
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);
  }
  public ContactsView(@Service ApplicationContext context, @Uses ContactsModel model) {
    super(new BorderLayout());

    this.model = model;

    ActionMap am = context.getActionMap(this);
    setActionMap(am);
    setPreferredSize(new Dimension(200, 0));

    this.setBorder(Borders.createEmptyBorder("2dlu, 2dlu, 2dlu, 2dlu"));

    contacts = new JList(new EventListModel<ContactDTO>(model.getEventList()));
    contacts.setPreferredSize(new Dimension(200, 1000));
    contacts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane contactsScrollPane = new JScrollPane();
    contactsScrollPane.setViewportView(contacts);
    contacts.setCellRenderer(
        new DefaultListCellRenderer() {

          @Override
          public Component getListCellRendererComponent(
              JList jList, Object o, int i, boolean b, boolean b1) {
            ContactDTO contact = (ContactDTO) o;
            if ("".equals(contact.name().get())) {
              Component cell =
                  super.getListCellRendererComponent(
                      jList, i18n.text(WorkspaceResources.name_label), i, b, b1);
              cell.setForeground(Color.GRAY);
              return cell;
            }

            String text = contact.name().get();

            return super.getListCellRendererComponent(jList, text, i, b, b1);
          }
        });
    add(contactsScrollPane, BorderLayout.CENTER);

    JPanel toolbar = new JPanel();
    toolbar.add(new StreamflowButton(am.get("add")));
    toolbar.add(new StreamflowButton(am.get("remove")));
    add(toolbar, BorderLayout.SOUTH);

    model.addObserver(new RefreshComponents().visibleOn("add", toolbar));

    contacts
        .getSelectionModel()
        .addListSelectionListener(new SelectionActionEnabler(am.get("remove")));

    /*
          setFocusTraversalPolicy( new LayoutFocusTraversalPolicy() );
          setFocusCycleRoot( true );
          setFocusable( true );
          addFocusListener( new FocusListener()
          {
             public void focusGained( FocusEvent e )
             {
                Component defaultComp = getFocusTraversalPolicy().getDefaultComponent( contactView );
                if (defaultComp != null)
                {
                   defaultComp.requestFocusInWindow();
                }
             }

             public void focusLost( FocusEvent e )
             {
             }
          } );
    */

    new RefreshWhenShowing(this, this);
  }
  public AttachmentsView(@Service ApplicationContext context, @Uses AttachmentsModel model) {
    setLayout(new BorderLayout());

    final ActionMap am = context.getActionMap(this);

    this.attachmentsModel = model;
    TableFormat tableFormat = new AttachmentsTableFormatter();
    tableModel = new EventJXTableModel<AttachmentDTO>(attachmentsModel.getEventList(), tableFormat);

    attachments = new JXTable(tableModel);

    attachments.setFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    attachments.setFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));

    attachments.getColumn(0).setPreferredWidth(20);
    attachments.getColumn(0).setMaxWidth(20);
    attachments.getColumn(0).setResizable(false);
    attachments.getColumn(2).setPreferredWidth(100);
    attachments.getColumn(2).setMaxWidth(100);
    attachments.getColumn(3).setPreferredWidth(100);
    attachments.getColumn(3).setMaxWidth(100);

    attachments.setAutoCreateColumnsFromModel(false);

    attachments.addHighlighter(HighlighterFactory.createAlternateStriping());

    attachments.setModel(tableModel);
    attachments.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JPanel toolbar = new JPanel();
    StreamflowButton addButton = new StreamflowButton(am.get("add"));
    toolbar.add(addButton);
    StreamflowButton removeButton = new StreamflowButton(am.get("remove"));
    toolbar.add(removeButton);
    final StreamflowButton openButton = new StreamflowButton(am.get("open"));
    toolbar.add(openButton);
    attachments
        .getSelectionModel()
        .addListSelectionListener(new SelectionActionEnabler(am.get("open")));
    attachments
        .getSelectionModel()
        .addListSelectionListener(
            new SelectionActionEnabler(am.get("remove")) {

              @Override
              public boolean isSelectedValueValid(javax.swing.Action action) {
                return !attachments
                    .getValueAt(attachments.convertRowIndexToModel(attachments.getSelectedRow()), 0)
                    .equals(Icons.formSubmitted);
              }
            });

    attachmentsModel.addObserver(
        new RefreshComponents().visibleOn("createattachment", addButton, removeButton));

    attachments.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "open");
    attachments.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove");
    attachments.setActionMap(am);

    attachments.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent me) {
            int obj = attachments.getSelectedRow();
            if (obj == -1) return;
            if (me.getClickCount() == 2) {
              am.get("open")
                  .actionPerformed(
                      new ActionEvent(openButton, ActionEvent.ACTION_PERFORMED, "open"));
              me.consume();
            }
          }
        });

    attachments
        .getColumn(0)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {

                JLabel iconLabel = new JLabel(" ");
                switch ((Icons) value) {
                  case attachments:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;

                  case conversations:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;

                  case formSubmitted:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;
                }

                iconLabel.setOpaque(true);

                if (isSelected) iconLabel.setBackground(attachments.getSelectionBackground());
                return iconLabel;
              }
            });

    JScrollPane attachmentsScrollPane = new JScrollPane(attachments);

    add(attachmentsScrollPane, BorderLayout.CENTER);
    add(toolbar, BorderLayout.SOUTH);

    new RefreshWhenShowing(this, attachmentsModel);
  }