Exemple #1
0
  /**
   * Define the main Circuit menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineCircuitMenu(ActionListener al) {
    JMenu circuitMenu = new JMenu(Globals.messages.getString("Circuit"));
    JMenuItem defineCircuit = new JMenuItem(Globals.messages.getString("Define"));

    defineCircuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, Globals.shortcutKey));

    circuitMenu.add(defineCircuit);

    JMenuItem updateLibraries = new JMenuItem(Globals.messages.getString("LibraryUpdate"));

    updateLibraries.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, Globals.shortcutKey));

    circuitMenu.add(updateLibraries);
    defineCircuit.addActionListener(al);
    updateLibraries.addActionListener(al);

    return circuitMenu;
  }
Exemple #2
0
  /**
   * Define the main View menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineViewMenu(ActionListener al) {
    JMenu viewMenu = new JMenu(Globals.messages.getString("View"));
    JMenuItem layerOptions = new JMenuItem(Globals.messages.getString("Layer_opt"));

    layerOptions.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Globals.shortcutKey));

    viewMenu.add(layerOptions);

    layerOptions.addActionListener(al);
    return viewMenu;
  }
  // Private helper methods
  private void createMenuBar() {
    menuBar = new JMenuBar();
    fileMenu = new JMenu("File");

    miOpen = new JMenuItem("Open...");
    miOpen.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.Event.META_MASK));
    fileMenu.add(miOpen).setEnabled(false);
    miOpen.addActionListener(new MenuActionListener());

    miSave = new JMenuItem("Save Selected...");
    miSave.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.Event.META_MASK));
    fileMenu.add(miSave).setEnabled(false);
    miSave.addActionListener(new MenuActionListener());

    miSaveAll = new JMenuItem("Save All...");
    fileMenu.add(miSaveAll).setEnabled(false);
    miSaveAll.addActionListener(new MenuActionListener());

    menuBar.add(fileMenu);
  }
    public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) {
      JMenuBar menuBar = new JMenuBar();
      final JCheckBoxMenuItem resizeNewShapesItem;
      final JCheckBoxMenuItem enableEditItem;

      JMenu menu = new JMenu("File");
      {
        JMenuItem item = new JMenuItem("Open...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(OPEN);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Open URL...");
        item.setActionCommand(OPEN_URL);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Save...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(SAVE);
        item.addActionListener(controller);
        menu.add(item);

        menu.addSeparator();

        item = new JMenuItem("Load Demo Shapes");
        item.setActionCommand(OPEN_DEMO_AIRSPACES);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      menu = new JMenu("Shape");
      {
        JMenu subMenu = new JMenu("New");
        for (final AirspaceFactory factory : defaultAirspaceFactories) {
          JMenuItem item = new JMenuItem(factory.toString());
          item.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  controller.createNewEntry(factory);
                }
              });
          subMenu.add(item);
        }
        menu.add(subMenu);

        resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport");
        resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesItem.addActionListener(controller);
        resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport());
        menu.add(resizeNewShapesItem);

        enableEditItem = new JCheckBoxMenuItem("Enable shape editing");
        enableEditItem.setActionCommand(ENABLE_EDIT);
        enableEditItem.addActionListener(controller);
        enableEditItem.setState(controller.isEnableEdit());
        menu.add(enableEditItem);
      }
      menuBar.add(menu);

      menu = new JMenu("Selection");
      {
        JMenuItem item = new JMenuItem("Deselect");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(CLEAR_SELECTION);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Delete");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        item.setActionCommand(REMOVE_SELECTED);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      frame.setJMenuBar(menuBar);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) {
                resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditItem.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
  /** Adds the menu items to the menuber. */
  protected void arrangeMenu() {

    // Build the first menu.
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);
    menuBar.add(viewMenu);

    runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    menuBar.add(runMenu);

    // Build the second menu.
    helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    programMenuItem = new JMenuItem("Load Program", KeyEvent.VK_O);
    programMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            programMenuItem_actionPerformed();
          }
        });
    fileMenu.add(programMenuItem);

    scriptMenuItem = new JMenuItem("Load Script", KeyEvent.VK_P);
    scriptMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptMenuItem_actionPerformed();
          }
        });
    fileMenu.add(scriptMenuItem);
    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
    exitMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exitMenuItem_actionPerformed();
          }
        });
    fileMenu.add(exitMenuItem);

    viewMenu.addSeparator();

    ButtonGroup animationRadioButtons = new ButtonGroup();

    animationSubMenu = new JMenu("Animate");
    animationSubMenu.setMnemonic(KeyEvent.VK_A);
    viewMenu.add(animationSubMenu);

    partAnimMenuItem = new JRadioButtonMenuItem("Program flow");
    partAnimMenuItem.setMnemonic(KeyEvent.VK_P);
    partAnimMenuItem.setSelected(true);
    partAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            partAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(partAnimMenuItem);
    animationSubMenu.add(partAnimMenuItem);

    fullAnimMenuItem = new JRadioButtonMenuItem("Program & data flow");
    fullAnimMenuItem.setMnemonic(KeyEvent.VK_D);
    fullAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(fullAnimMenuItem);
    animationSubMenu.add(fullAnimMenuItem);

    noAnimMenuItem = new JRadioButtonMenuItem("No Animation");
    noAnimMenuItem.setMnemonic(KeyEvent.VK_N);
    noAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(noAnimMenuItem);
    animationSubMenu.add(noAnimMenuItem);

    ButtonGroup additionalDisplayRadioButtons = new ButtonGroup();

    additionalDisplaySubMenu = new JMenu("View");
    additionalDisplaySubMenu.setMnemonic(KeyEvent.VK_V);
    viewMenu.add(additionalDisplaySubMenu);

    scriptDisplayMenuItem = new JRadioButtonMenuItem("Script");
    scriptDisplayMenuItem.setMnemonic(KeyEvent.VK_S);
    scriptDisplayMenuItem.setSelected(true);
    scriptDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(scriptDisplayMenuItem);
    additionalDisplaySubMenu.add(scriptDisplayMenuItem);

    outputMenuItem = new JRadioButtonMenuItem("Output");
    outputMenuItem.setMnemonic(KeyEvent.VK_O);
    outputMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(outputMenuItem);
    additionalDisplaySubMenu.add(outputMenuItem);

    compareMenuItem = new JRadioButtonMenuItem("Compare");
    compareMenuItem.setMnemonic(KeyEvent.VK_C);
    compareMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            compareMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(compareMenuItem);
    additionalDisplaySubMenu.add(compareMenuItem);

    noAdditionalDisplayMenuItem = new JRadioButtonMenuItem("Screen");
    noAdditionalDisplayMenuItem.setMnemonic(KeyEvent.VK_N);
    noAdditionalDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAdditionalDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(noAdditionalDisplayMenuItem);
    additionalDisplaySubMenu.add(noAdditionalDisplayMenuItem);

    ButtonGroup formatRadioButtons = new ButtonGroup();

    numericFormatSubMenu = new JMenu("Format");
    numericFormatSubMenu.setMnemonic(KeyEvent.VK_F);
    viewMenu.add(numericFormatSubMenu);

    decMenuItem = new JRadioButtonMenuItem("Decimal");
    decMenuItem.setMnemonic(KeyEvent.VK_D);
    decMenuItem.setSelected(true);
    decMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            decMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(decMenuItem);
    numericFormatSubMenu.add(decMenuItem);

    hexaMenuItem = new JRadioButtonMenuItem("Hexadecimal");
    hexaMenuItem.setMnemonic(KeyEvent.VK_H);
    hexaMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hexaMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(hexaMenuItem);
    numericFormatSubMenu.add(hexaMenuItem);

    binMenuItem = new JRadioButtonMenuItem("Binary");
    binMenuItem.setMnemonic(KeyEvent.VK_B);
    binMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            binMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(binMenuItem);
    numericFormatSubMenu.add(binMenuItem);

    viewMenu.addSeparator();

    singleStepMenuItem = new JMenuItem("Single Step", KeyEvent.VK_S);
    singleStepMenuItem.setAccelerator(KeyStroke.getKeyStroke("F11"));
    singleStepMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepMenuItem_actionPerformed();
          }
        });
    runMenu.add(singleStepMenuItem);

    ffwdMenuItem = new JMenuItem("Run", KeyEvent.VK_F);
    ffwdMenuItem.setAccelerator(KeyStroke.getKeyStroke("F5"));
    ffwdMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdMenuItem_actionPerformed();
          }
        });
    runMenu.add(ffwdMenuItem);

    stopMenuItem = new JMenuItem("Stop", KeyEvent.VK_T);
    stopMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F5"));
    stopMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopMenuItem_actionPerformed();
          }
        });
    runMenu.add(stopMenuItem);

    rewindMenuItem = new JMenuItem("Reset", KeyEvent.VK_R);
    rewindMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindMenuItem_actionPerformed();
          }
        });
    runMenu.add(rewindMenuItem);

    runMenu.addSeparator();

    breakpointsMenuItem = new JMenuItem("Breakpoints", KeyEvent.VK_B);
    breakpointsMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            breakpointsMenuItem_actionPerformed();
          }
        });
    runMenu.add(breakpointsMenuItem);

    profilerMenuItem = new JMenuItem("Profiler", KeyEvent.VK_I);
    profilerMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showProfiler();
          }
        });
    profilerMenuItem.setEnabled(false);
    runMenu.add(profilerMenuItem);

    usageMenuItem = new JMenuItem("Usage", KeyEvent.VK_U);
    usageMenuItem.setAccelerator(KeyStroke.getKeyStroke("F1"));
    usageMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            usageMenuItem_actionPerformed();
          }
        });
    helpMenu.add(usageMenuItem);

    aboutMenuItem = new JMenuItem("About ...", KeyEvent.VK_A);
    aboutMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            aboutMenuItem_actionPerformed();
          }
        });
    helpMenu.add(aboutMenuItem);
  }
  /**
   * Adds the menus to the main frame Includes adding ActionListeners to respond to menu commands
   */
  private void addMenus() {
    JMenuBar menuBar = new JMenuBar();
    JMenu gameMenu = new JMenu("Game");
    gameMenu.setMnemonic('G');

    JMenuItem newMenu = new JMenuItem("New Game");
    newMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    newMenu.addActionListener(
        new ActionListener() {
          /**
           * Responds to the New menu option
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent e) {
            newGame();
            time = 0;
          }
        });

    JMenuItem exitMenu = new JMenuItem("Exit");
    exitMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));

    exitMenu.addActionListener(
        new ActionListener() {
          /**
           * Responds to the exit game option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });
    gameMenu.add(newMenu);
    gameMenu.add(exitMenu);
    menuBar.add(gameMenu);

    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('H');
    JMenuItem instructionsMenuItem = new JMenuItem("Instructions", 'I');
    instructionsMenuItem.addActionListener(
        new ActionListener() {
          /**
           * Responds to the help option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                BearSweeper.this,
                "The objective of the game is to flag Fabear's hiding spots so people know where to avoid.\n"
                    + "If you click on an area that Fabear does not reside, a digit is revealed.\n"
                    + "This digit indicates the number of adjacent squares in which Fabear resides.\n"
                    + "Mark Fabear's hiding spots by right clicking."
                    + "If you click on a spot where Fabear resides, you will wake up and unleash his wrath.\n"
                    + "Note: You only have enough flags for exactly the number of hiding spots!",
                "Help",
                JOptionPane.INFORMATION_MESSAGE);
          }
        });
    instructionsMenuItem.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
    JMenuItem aboutMenuItem = new JMenuItem("About...", 'A');
    aboutMenuItem.addActionListener(
        new ActionListener() {
          /**
           * Responds to the about option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                BearSweeper.this,
                "Fabear is now a well-known hero on Earth.\n"
                    + "He has saved Earth in the Tera sagas, but not without sacrifice.\n"
                    + "Although the Earth is now clean from the dangerous substances left behind by the aliens, Fabear has changed...\n"
                    + "He had come in contact with the substance and is now under the control of the aliens.\n"
                    + "It is your turn to save Fabear, from himself..."
                    + "He is currently sleeping.\n"
                    + "Find Fabear's hiding spots without waking him from his sleep."
                    + "When all of his possible hiding spots are marked with flags,\n"
                    + "special task forces will take over to secure Fabear and take him to a lab "
                    + "where scientists will do everything they can to\n"
                    + "return Fabear to his original self.\n"
                    + "\nBy: Christopher Li and Aaron Lee - 2009-2010",
                "The Adventures of Fabear",
                JOptionPane.INFORMATION_MESSAGE);
          }
        });
    aboutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));

    helpMenu.add(instructionsMenuItem);
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
  }
Exemple #7
0
  /**
   * Show the saved results on the server.
   *
   * @param mysettings jemboss settings
   * @param frameName title name for frame
   */
  public ShowSavedResults(final JembossParams mysettings, final JFrame f) {

    this("Saved results list" + (Jemboss.withSoap ? " on server" : ""));

    try {
      final ResultList reslist = new ResultList(mysettings);
      JMenu resFileMenu = new JMenu("File");
      resMenu.add(resFileMenu);

      final JCheckBoxMenuItem listByProgram = new JCheckBoxMenuItem("List by program");
      listByProgram.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByProgramName();
            }
          });
      resFileMenu.add(listByProgram);

      JCheckBoxMenuItem listByDate = new JCheckBoxMenuItem("List by date", true);
      listByDate.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByDateRun(reslist, false);
            }
          });
      resFileMenu.add(listByDate);

      ButtonGroup group = new ButtonGroup();
      group.add(listByProgram);
      group.add(listByDate);

      JButton refresh = new JButton(rfii);
      refresh.setMargin(new Insets(0, 1, 0, 1));
      refresh.setToolTipText("Refresh");
      resMenu.add(refresh);

      refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                setCursor(cbusy);
                ResultList newlist = new ResultList(mysettings);
                setCursor(cdone);
                if (newlist.getStatus().equals("0")) {
                  reslist.updateRes(newlist.hash());
                  datasets.removeAllElements();

                  StringTokenizer tok = new StringTokenizer((String) reslist.get("list"), "\n");
                  while (tok.hasMoreTokens()) datasets.addElement(convertToPretty(tok.nextToken()));

                  if (listByProgram.isSelected()) listByProgramName();
                  else listByDateRun(reslist, false);
                } else {
                  JOptionPane.showMessageDialog(
                      null, newlist.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);
                }
              } catch (JembossSoapException eae) {
                AuthPopup ap = new AuthPopup(mysettings, f);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          });

      resFileMenu.addSeparator();
      JMenuItem resFileMenuExit = new JMenuItem("Close");
      resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));

      resFileMenuExit.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          });
      resFileMenu.add(resFileMenuExit);
      setJMenuBar(resMenu);

      // this is the list of saved results
      listByDateRun(reslist, true);

      final JList st = new JList(datasets);
      st.setCellRenderer(new TabListCellRenderer());

      st.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;

              JList theList = (JList) e.getSource();
              if (theList.isSelectionEmpty()) {
                System.out.println("Empty selection");
              } else {
                int index = theList.getSelectedIndex();
                String thisdata = convertToOriginal(datasets.elementAt(index));
                aboutRes.setText((String) reslist.get(thisdata));
                aboutRes.setCaretPosition(0);
              }
            }
          });

      st.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                try {
                  setCursor(cbusy);
                  String project = convertToOriginal(st.getSelectedValue());
                  ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                  new ShowResultSet(thisres.hash(), project, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              }
            }
          });
      sp.add(st);

      // display retrieves all files and shows them in a window
      JPanel resButtonPanel = new JPanel();
      JButton showResButton = new JButton("Display");
      showResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres = new ResultList(mysettings, sel, "show_saved_results");
                  if (thisres.hash().size() == 0)
                    JOptionPane.showMessageDialog(
                        sp,
                        "This application launch '" + sel + "' didn't produce any result files.");
                  else new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Nothing selected to be displayed.");
              }
            }
          });

      // add a users note for that project
      JButton addNoteButton = new JButton("Edit Notes");
      addNoteButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres =
                      new ResultList(mysettings, sel, "Notes", "show_saved_results");
                  new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Selected a project!");
              }
            }
          });

      // delete removes the file on the server & edits the list
      JButton delResButton = new JButton("Delete");
      delResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Object sel[] = st.getSelectedValues();
              if (sel != null) {
                String selList = new String("");
                JTextPane delList = new JTextPane();
                FontMetrics fm = delList.getFontMetrics(delList.getFont());
                int maxWidth = 0;
                for (int i = 0; i < sel.length; i++) {
                  if (i == sel.length - 1) selList = selList.concat((String) sel[i]);
                  else selList = selList.concat(sel[i] + "\n");

                  int width = fm.stringWidth((String) sel[i]);
                  if (width > maxWidth) maxWidth = width;
                }
                int ok = JOptionPane.OK_OPTION;
                if (sel.length > 1) {
                  JScrollPane scrollDel = new JScrollPane(delList);
                  delList.setText(selList);
                  delList.setEditable(false);
                  delList.setCaretPosition(0);

                  Dimension d1 = delList.getPreferredSize();
                  int maxHeight = (int) d1.getHeight() + 5;
                  if (maxHeight > 350) maxHeight = 350;
                  else if (maxHeight < 50) maxHeight = 50;

                  scrollDel.setPreferredSize(new Dimension(maxWidth + 30, maxHeight));

                  ok =
                      JOptionPane.showConfirmDialog(
                          null, scrollDel, "Confirm Deletion", JOptionPane.YES_NO_OPTION);
                }
                if (ok == JOptionPane.OK_OPTION) {
                  try // ask the server to delete these results
                  {
                    setCursor(cbusy);
                    selList = convertToOriginal(selList);
                    new ResultList(mysettings, selList, "delete_saved_results");
                    setCursor(cdone);

                    // amend the list
                    for (int i = 0; i < sel.length; i++) datasets.removeElement(sel[i]);

                    statusField.setText("Deleted " + sel.length + "  result(s)");

                    aboutRes.setText("");
                    st.setSelectedIndex(-1);
                  } catch (JembossSoapException eae) {
                    AuthPopup ap = new AuthPopup(mysettings, f);
                    ap.setBottomPanel();
                    ap.setSize(380, 170);
                    ap.pack();
                    ap.setVisible(true);
                  }
                }
              } else {
                statusField.setText("Nothing selected for deletion.");
              }
            }
          });
      resButtonPanel.add(delResButton);
      resButtonPanel.add(addNoteButton);
      resButtonPanel.add(showResButton);
      resButtonStatus.add(resButtonPanel, BorderLayout.CENTER);
      resButtonStatus.add(statusField, BorderLayout.SOUTH);

      Container c = getContentPane();
      c.add(ss, BorderLayout.WEST);
      c.add(aboutScroll, BorderLayout.CENTER);
      c.add(resButtonStatus, BorderLayout.SOUTH);
      pack();

      setVisible(true);
    } catch (JembossSoapException eae) {
      AuthPopup ap = new AuthPopup(mysettings, f);
      ap.setBottomPanel();
      ap.setSize(380, 170);
      ap.pack();
      ap.setVisible(true);
    }
  }
Exemple #8
0
  /**
   * Show the results sent to a batch queue.
   *
   * @param mysettings jemboss settings
   * @param epr pending results
   * @throws JembossSoapException when server connection fails
   */
  public ShowSavedResults(final JembossParams mysettings, final PendingResults epr)
      throws JembossSoapException {
    this("Current Sessions Results");

    Dimension d = new Dimension(270, 100);
    ss.setPreferredSize(d);
    //  ss.setMaximumSize(d);

    JMenu resFileMenu = new JMenu("File");
    resMenu.add(resFileMenu);

    JButton refresh = new JButton(rfii);
    refresh.setMargin(new Insets(0, 1, 0, 1));
    refresh.setToolTipText("Refresh");
    resMenu.add(refresh);
    refresh.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setCursor(cbusy);
            epr.updateStatus();
            setCursor(cdone);
            datasets.removeAllElements();
            Enumeration enumer = epr.descriptionHash().keys();
            while (enumer.hasMoreElements()) {
              String image = convertToPretty((String) enumer.nextElement());
              datasets.addElement(image);
            }
          }
        });

    JMenuItem resFileMenuExit = new JMenuItem("Close");
    resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));

    resFileMenuExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    resFileMenu.add(resFileMenuExit);
    setJMenuBar(resMenu);

    // set up the results list in the gui
    Enumeration enumer = epr.descriptionHash().keys();
    while (enumer.hasMoreElements())
      datasets.addElement(convertToPretty((String) enumer.nextElement()));

    final JList st = new JList(datasets);
    st.setCellRenderer(new TabListCellRenderer());
    st.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) return;

            JList theList = (JList) e.getSource();
            if (!theList.isSelectionEmpty()) {
              int index = theList.getSelectedIndex();
              String thisdata = convertToOriginal(datasets.elementAt(index));
              aboutRes.setText((String) epr.descriptionHash().get(thisdata));
              aboutRes.setCaretPosition(0);
              aboutRes.setEditable(false);
            }
          }
        });

    st.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              try {
                setCursor(cbusy);
                String project = convertToOriginal(st.getSelectedValue());
                ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                setCursor(cdone);
                if (thisres.getStatus().equals("0"))
                  new ShowResultSet(thisres.hash(), project, mysettings);
                else
                  JOptionPane.showMessageDialog(
                      null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);

              } catch (JembossSoapException eae) {
                AuthPopup ap = new AuthPopup(mysettings, null);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          }
        });
    sp.add(st);

    // display retrieves all the files and shows them in a window

    JPanel resButtonPanel = new JPanel();
    JButton showResButton = new JButton("Display");
    showResButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (st.getSelectedValue() != null) {
              try {
                setCursor(cbusy);
                String project = convertToOriginal(st.getSelectedValue());
                ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                setCursor(cdone);
                if (thisres.getStatus().equals("0"))
                  new ShowResultSet(thisres.hash(), project, mysettings);
                else
                  JOptionPane.showMessageDialog(
                      null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);
              } catch (JembossSoapException eae) {
                setCursor(cdone);
                AuthPopup ap = new AuthPopup(mysettings, null);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          }
        });

    // delete removes the file on the server and edits the list
    JButton delResButton = new JButton("Delete");
    delResButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object sel[] = st.getSelectedValues();
            if (sel != null) {
              String selList = new String("");
              for (int i = 0; i < sel.length; i++) selList = selList.concat(sel[i] + "\n");

              int ok = JOptionPane.OK_OPTION;
              if (sel.length > 1)
                ok =
                    JOptionPane.showConfirmDialog(
                        null,
                        "Delete the following results:\n" + selList,
                        "Confirm Deletion",
                        JOptionPane.YES_NO_OPTION);

              if (ok == JOptionPane.OK_OPTION) {

                try {
                  setCursor(cbusy);
                  selList = convertToOriginal(selList);
                  new ResultList(mysettings, selList, "delete_saved_results");
                  setCursor(cdone);

                  for (int i = 0; i < sel.length; i++) {
                    JembossProcess jp = epr.getResult(convertToOriginal(sel[i]));
                    epr.removeResult(jp);
                    datasets.removeElement(sel[i]); // amend the list
                  }
                  statusField.setText("Deleted " + sel.length + "  result(s)");
                  aboutRes.setText("");
                  st.setSelectedIndex(-1);
                } catch (JembossSoapException eae) {
                  // shouldn't happen
                  AuthPopup ap = new AuthPopup(mysettings, null);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              }
            }
          }
        });
    resButtonPanel.add(delResButton);
    resButtonPanel.add(showResButton);
    resButtonStatus.add(resButtonPanel, BorderLayout.CENTER);
    resButtonStatus.add(statusField, BorderLayout.SOUTH);

    Container c = getContentPane();
    c.add(ss, BorderLayout.WEST);
    c.add(aboutScroll, BorderLayout.CENTER);
    c.add(resButtonStatus, BorderLayout.SOUTH);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    pack();
    setVisible(true);

    // add in automatic updates
    String freq = (String) AdvancedOptions.jobMgr.getSelectedItem();
    int ind = freq.indexOf(" ");
    new ResultsUpdateTimer(Integer.parseInt(freq.substring(0, ind)), datasets, this);
    statusField.setText("Window refresh rate " + freq);
  }
Exemple #9
0
  /**
   * Create the main File menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineFileMenu(ActionListener al) {
    JMenu fileMenu = new JMenu(Globals.messages.getString("File"));
    JMenuItem fileNew = new JMenuItem(Globals.messages.getString("New"));
    fileNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Globals.shortcutKey));
    JMenuItem fileOpen = new JMenuItem(Globals.messages.getString("Open"));
    fileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Globals.shortcutKey));
    JMenuItem fileSave = new JMenuItem(Globals.messages.getString("Save"));
    fileSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Globals.shortcutKey));
    JMenuItem fileSaveName = new JMenuItem(Globals.messages.getString("SaveName"));
    fileSaveName.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, Globals.shortcutKey | InputEvent.SHIFT_MASK));

    JMenuItem fileSaveNameSplit = new JMenuItem(Globals.messages.getString("Save_split"));

    JMenuItem fileExport = new JMenuItem(Globals.messages.getString("Export"));

    fileExport.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, Globals.shortcutKey));

    JMenuItem filePrint = new JMenuItem(Globals.messages.getString("Print"));

    filePrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Globals.shortcutKey));

    JMenuItem fileClose = new JMenuItem(Globals.messages.getString("Close"));

    fileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Globals.shortcutKey));

    JMenuItem options = new JMenuItem(Globals.messages.getString("Circ_opt"));

    // Add the items in the file menu.

    fileMenu.add(fileNew);
    fileMenu.add(fileOpen);
    fileMenu.add(fileSave);
    fileMenu.add(fileSaveName);
    fileMenu.addSeparator();
    fileMenu.add(fileSaveNameSplit);
    fileMenu.addSeparator();

    fileMenu.add(fileExport);
    fileMenu.add(filePrint);
    fileMenu.addSeparator();

    // On a MacOSX system, options is associated to preferences menu
    // in the application menu. We do not need to show it in File.
    // This needs the AppleSpecific extensions to be active.

    if (!Globals.weAreOnAMac) {
      fileMenu.add(options);
      fileMenu.addSeparator();
    }
    fileMenu.add(fileClose);

    // Define all the action listeners

    fileNew.addActionListener(al);
    fileOpen.addActionListener(al);
    fileExport.addActionListener(al);
    filePrint.addActionListener(al);
    fileClose.addActionListener(al);

    fileSave.addActionListener(al);
    fileSaveName.addActionListener(al);
    fileSaveNameSplit.addActionListener(al);

    options.addActionListener(al);

    return fileMenu;
  }
Exemple #10
0
  /**
   * Define the Edit main menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineEditMenu(ActionListener al) {
    JMenu editMenu = new JMenu(Globals.messages.getString("Edit_menu"));

    JMenuItem editUndo = new JMenuItem(Globals.messages.getString("Undo"));
    editUndo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Globals.shortcutKey));
    // editUndo.setEnabled(false);
    JMenuItem editRedo = new JMenuItem(Globals.messages.getString("Redo"));
    editRedo.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_Z, Globals.shortcutKey | InputEvent.SHIFT_MASK));
    // editRedo.setEnabled(false);
    JMenuItem editCut = new JMenuItem(Globals.messages.getString("Cut"));
    editCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Globals.shortcutKey));

    JMenuItem editCopy = new JMenuItem(Globals.messages.getString("Copy"));
    editCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Globals.shortcutKey));

    JMenuItem editCopySplit = new JMenuItem(Globals.messages.getString("Copy_split"));
    editCopySplit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Globals.shortcutKey));

    JMenuItem editPaste = new JMenuItem(Globals.messages.getString("Paste"));
    editPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Globals.shortcutKey));
    JMenuItem clipboardCircuit = new JMenuItem(Globals.messages.getString("DefineClipboard"));

    JMenuItem editSelectAll = new JMenuItem(Globals.messages.getString("SelectAll"));
    editSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Globals.shortcutKey));

    JMenuItem editDuplicate = new JMenuItem(Globals.messages.getString("Duplicate"));
    editDuplicate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Globals.shortcutKey));

    JMenuItem editRotate = new JMenuItem(Globals.messages.getString("Rotate"));
    editRotate.setAccelerator(KeyStroke.getKeyStroke("R"));

    JMenuItem editMirror = new JMenuItem(Globals.messages.getString("Mirror_E"));
    editMirror.setAccelerator(KeyStroke.getKeyStroke("S"));

    editUndo.addActionListener(al);
    editRedo.addActionListener(al);
    editCut.addActionListener(al);
    editCopy.addActionListener(al);
    editCopySplit.addActionListener(al);
    editPaste.addActionListener(al);
    editSelectAll.addActionListener(al);
    editDuplicate.addActionListener(al);
    editMirror.addActionListener(al);
    editRotate.addActionListener(al);
    clipboardCircuit.addActionListener(al);

    editMenu.add(editUndo);
    editMenu.add(editRedo);
    editMenu.addSeparator();

    editMenu.add(editCut);
    editMenu.add(editCopy);
    editMenu.add(editCopySplit);
    editMenu.add(editPaste);
    editMenu.add(clipboardCircuit);
    editMenu.add(editDuplicate);

    editMenu.addSeparator();

    editMenu.add(editSelectAll);
    editMenu.addSeparator();
    editMenu.add(editRotate);
    editMenu.add(editMirror);

    return editMenu;
  }