Example #1
0
  /**
   * List results by date
   *
   * @param reslist result list
   * @param ldisp
   */
  private void listByDateRun(ResultList reslist, boolean ldisp) {
    StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n");

    Vector vdata = new Vector();
    while (tokenizer.hasMoreTokens()) {
      String data = convertToPretty(tokenizer.nextToken());
      if (datasets.contains(data) || ldisp) vdata.add(data);
    }
    datasets.removeAllElements();

    Enumeration en = vdata.elements();
    while (en.hasMoreElements()) datasets.addElement(en.nextElement());
  }
Example #2
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);
  }