コード例 #1
0
 /** Find the data for a given id */
 public SOAPMonitorData findData(Long id) {
   SOAPMonitorData soap = null;
   for (int row = data.size(); (row > 0) && (soap == null); row--) {
     soap = (SOAPMonitorData) data.elementAt(row - 1);
     if (soap.getId().longValue() != id.longValue()) {
       soap = null;
     }
   }
   return soap;
 }
コード例 #2
0
 /** Get value at (part of table model interface) */
 public Object getValueAt(int row, int col) {
   SOAPMonitorData soap;
   String value = null;
   soap = (SOAPMonitorData) data.elementAt(row);
   if (filter_data != null) {
     soap = (SOAPMonitorData) filter_data.elementAt(row);
   }
   switch (col) {
     case 0:
       value = soap.getTime();
       break;
     case 1:
       value = soap.getTargetService();
       break;
     case 2:
       value = soap.getStatus();
       break;
   }
   return value;
 }
コード例 #3
0
 /** 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;
 }
コード例 #4
0
 /** Listener to handle table selection changes */
 public void valueChanged(ListSelectionEvent e) {
   int row = table.getSelectedRow();
   // Check if they selected a specific row
   if (row > 0) {
     remove_button.setEnabled(true);
   } else {
     remove_button.setEnabled(false);
   }
   // Check for "most recent" selection
   if (row == 0) {
     row = model.getRowCount() - 1;
     if (row == 0) {
       row = -1;
     }
   }
   if (row == -1) {
     // Clear the details panel
     details_time_value.setText("");
     details_target_value.setText("");
     details_status_value.setText("");
     request_text.setText("");
     response_text.setText("");
   } else {
     // Show the details for the row
     SOAPMonitorData soap = model.getData(row);
     details_time_value.setText(soap.getTime());
     details_target_value.setText(soap.getTargetService());
     details_status_value.setText(soap.getStatus());
     if (soap.getSOAPRequest() == null) {
       request_text.setText("");
     } else {
       request_text.setText(soap.getSOAPRequest());
       request_text.setCaretPosition(0);
     }
     if (soap.getSOAPResponse() == null) {
       response_text.setText("");
     } else {
       response_text.setText(soap.getSOAPResponse());
       response_text.setCaretPosition(0);
     }
   }
 }
コード例 #5
0
    /** Background thread used to receive data from the server. */
    public void run() {
      Long id;
      Integer message_type;
      String target;
      String soap;
      SOAPMonitorData data;
      int selected;
      int row;
      boolean update_needed;
      while (socket != null) {
        try {
          // Get the data from the server
          message_type = (Integer) in.readObject();
          // Process the data depending on its type
          switch (message_type.intValue()) {
            case SOAPMonitorConstants.SOAP_MONITOR_REQUEST:
              // Get the id, target and soap info
              id = (Long) in.readObject();
              target = (String) in.readObject();
              soap = (String) in.readObject();
              // Add new request data to the table
              data = new SOAPMonitorData(id, target, soap);
              model.addData(data);
              // If "most recent" selected then update
              // the details area if needed
              selected = table.getSelectedRow();
              if ((selected == 0) && model.filterMatch(data)) {
                valueChanged(null);
              }
              break;
            case SOAPMonitorConstants.SOAP_MONITOR_RESPONSE:
              // Get the id and soap info
              id = (Long) in.readObject();
              soap = (String) in.readObject();
              data = model.findData(id);
              if (data != null) {
                update_needed = false;
                // Get the selected row
                selected = table.getSelectedRow();
                // If "most recent", then always
                // update details area
                if (selected == 0) {
                  update_needed = true;
                }
                // If the data being updated is
                // selected then update details
                row = model.findRow(data);
                if ((row != -1) && (row == selected)) {
                  update_needed = true;
                }
                // Set the response and update table
                data.setSOAPResponse(soap);
                model.updateData(data);
                // Refresh details area (if needed)
                if (update_needed) {
                  valueChanged(null);
                }
              }
              break;
          }

        } catch (Exception e) {
          // Exceptions are expected here when the
          // server communication has been terminated.
          if (stop_button.isEnabled()) {
            stop();
            setErrorStatus(STATUS_CLOSED);
          }
        }
      }
    }