Exemplo n.º 1
0
 /** Description of the Method */
 public void removeAllElements() {
   for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) {
     BPM_Element elm = e.nextElement();
     elm.stopMonitor();
   }
   listModel.removeAllElements();
 }
 /*
  * Applet is no longer displayed
  */
 public void stop() {
   // Tell all pages to stop talking to the server
   Enumeration e = pages.elements();
   while (e.hasMoreElements()) {
     SOAPMonitorPage pg = (SOAPMonitorPage) e.nextElement();
     if (pg != null) {
       pg.stop();
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Returns the bPM attribute of the BPMsTable object
  *
  * @param name The Parameter
  * @return The bPM value
  */
 public BPM_Element getBPM(String name) {
   BPM_Element bpmElm = null;
   Enumeration<BPM_Element> bpm_enum = listModel.elements();
   while (bpm_enum.hasMoreElements()) {
     BPM_Element bpmElm1 = bpm_enum.nextElement();
     if (bpmElm1.getName().equals(name)) {
       bpmElm = bpmElm1;
     }
   }
   return bpmElm;
 }
 public void save(PrintStream stream) {
   saved = true;
   stream.println("<?xml version=\"1.0\"?>");
   stream.println("<scale>");
   stream.println("  <name>" + nameTF.getText() + "</name>");
   for (Enumeration en = sp.notes.elements(); en.hasMoreElements(); ) {
     ScalePanel.Notik cur = (ScalePanel.Notik) en.nextElement();
     stream.println("  <note>" + cur.n + "</note>");
   }
   stream.println("</scale>");
 }
 /** Check if soap data matches filter */
 public boolean filterMatch(SOAPMonitorData soap) {
   boolean match = true;
   if (filter_include != null) {
     // Check for service match
     Enumeration e = filter_include.elements();
     match = false;
     while (e.hasMoreElements() && !match) {
       String service = (String) e.nextElement();
       if (service.equals(soap.getTargetService())) {
         match = true;
       }
     }
   }
   if (filter_exclude != null) {
     // Check for service match
     Enumeration e = filter_exclude.elements();
     while (e.hasMoreElements() && match) {
       String service = (String) e.nextElement();
       if (service.equals(soap.getTargetService())) {
         match = false;
       }
     }
   }
   if (filter_active) {
     // Check for active status match
     if (soap.getSOAPResponse() != null) {
       match = false;
     }
   }
   if (filter_complete) {
     // Check for complete status match
     if (soap.getSOAPResponse() == null) {
       match = false;
     }
   }
   // The "most recent" is always a match
   if (soap.getId() == null) {
     match = true;
   }
   return match;
 }
Exemplo n.º 6
0
  private void createClusterManagerElement() {
    ConfigElementFactory factory = new ConfigElementFactory(mBroker.getRepository().getAllLatest());
    ConfigElement cluster_manager = factory.create("Sample Cluster", "cluster_manager");
    for (Enumeration e = mNodesListModel.elements(); e.hasMoreElements(); ) {
      cluster_manager.addProperty("cluster_node", (String) e.nextElement());
    }

    cluster_manager.addProperty("plugin_path", "${VJ_BASE_DIR}/lib/gadgeteer/plugins/");
    cluster_manager.addProperty("plugin", "RemoteInputManager");
    cluster_manager.addProperty("plugin", "ApplicationDataManager");
    mBroker.add(mContext, cluster_manager);
  }
Exemplo n.º 7
0
 private void save() {
   try {
     Document doc = XmlUtil.getDocument();
     Element root = doc.createElement("profiles");
     doc.appendChild(root);
     Enumeration<String> keys = table.keys();
     while (keys.hasMoreElements()) {
       table.get(keys.nextElement()).appendTo(root);
     }
     FileUtil.setText(new File(filename), FileUtil.utf8, XmlUtil.toString(doc));
   } catch (Exception ignore) {
   }
 }
Exemplo n.º 8
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());
  }
Exemplo n.º 9
0
 // Take a tree of files starting in a directory in a zip file
 // and copy them to a disk directory, recreating the tree.
 private int unpackZipFile(
     File inZipFile, String directory, String parent, boolean suppressFirstPathElement) {
   int count = 0;
   if (!inZipFile.exists()) return count;
   parent = parent.trim();
   if (!parent.endsWith(File.separator)) parent += File.separator;
   if (!directory.endsWith(File.separator)) directory += File.separator;
   File outFile = null;
   try {
     ZipFile zipFile = new ZipFile(inZipFile);
     Enumeration zipEntries = zipFile.entries();
     while (zipEntries.hasMoreElements()) {
       ZipEntry entry = (ZipEntry) zipEntries.nextElement();
       String name = entry.getName().replace('/', File.separatorChar);
       if (name.startsWith(directory)) {
         if (suppressFirstPathElement) name = name.substring(directory.length());
         outFile = new File(parent + name);
         // Create the directory, just in case
         if (name.indexOf(File.separatorChar) >= 0) {
           String p = name.substring(0, name.lastIndexOf(File.separatorChar) + 1);
           File dirFile = new File(parent + p);
           dirFile.mkdirs();
         }
         if (!entry.isDirectory()) {
           System.out.println("Installing " + outFile);
           // Copy the file
           BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
           BufferedInputStream in = new BufferedInputStream(zipFile.getInputStream(entry));
           int size = 1024;
           int n = 0;
           byte[] b = new byte[size];
           while ((n = in.read(b, 0, size)) != -1) out.write(b, 0, n);
           in.close();
           out.flush();
           out.close();
           // Count the file
           count++;
         }
       }
     }
     zipFile.close();
   } catch (Exception e) {
     System.err.println("...an error occured while installing " + outFile);
     e.printStackTrace();
     System.err.println("Error copying " + outFile.getName() + "\n" + e.getMessage());
     return -count;
   }
   System.out.println(count + " files were installed.");
   return count;
 }
 /** Refilter the list of messages */
 public void applyFilter() {
   // Re-filter using new criteria
   filter_data = null;
   if ((filter_include != null)
       || (filter_exclude != null)
       || filter_active
       || filter_complete) {
     filter_data = new Vector();
     Enumeration e = data.elements();
     SOAPMonitorData soap;
     while (e.hasMoreElements()) {
       soap = (SOAPMonitorData) e.nextElement();
       if (filterMatch(soap)) {
         filter_data.addElement(soap);
       }
     }
   }
   fireTableDataChanged();
 }
Exemplo n.º 11
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);
  }
Exemplo n.º 12
0
 /** Description of the Method */
 public void startMonitor() {
   for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) {
     BPM_Element elm = e.nextElement();
     elm.startMonitor();
   }
 }