📄 soapmonitor.java
字号:
*/ /** * Method stop */ 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(); } } } /** * This class is for the Login Dialog */ class LoginDlg extends JDialog implements ActionListener { /** * Field ok_button */ private JButton ok_button = null; /** * Field cancel_button */ private JButton cancel_button = null; /** * Field user */ private JTextField user = new JTextField(20); /** * Field pass */ private JPasswordField pass = new JPasswordField(20); /** * Field url */ private JTextField url = new JTextField(20); /** * Field loginState */ private boolean loginState = false; /** * Constructor (create and layout page) */ public LoginDlg() { setTitle("SOAP Monitor Login"); UIManager.put("Label.font", new Font("Dialog", Font.BOLD, 12)); JPanel panel = new JPanel(); ok_button = new JButton("OK"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); // default URL for AxisServlet url.setText(axisURL); JLabel userLabel = new JLabel("User:"); JLabel passLabel = new JLabel("Password:"); JLabel urlLabel = new JLabel("Axis URL:"); userLabel.setHorizontalAlignment(JTextField.RIGHT); passLabel.setHorizontalAlignment(JTextField.RIGHT); urlLabel.setHorizontalAlignment(JTextField.RIGHT); panel.add(userLabel); panel.add(user); panel.add(passLabel); panel.add(pass); panel.add(urlLabel); panel.add(url); panel.add(ok_button); panel.add(cancel_button); setContentPane(panel); user.setText(SOAPMonitor.axisUser); pass.setText(SOAPMonitor.axisPass); GridLayout layout = new GridLayout(4, 2); layout.setHgap(15); layout.setVgap(5); panel.setLayout(layout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setModal(true); pack(); Dimension d = getToolkit().getScreenSize(); setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2); } /** * Listener to handle button actions * * @param e */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the OK button if (e.getSource() == ok_button) { loginState = true; SOAPMonitor.axisUser = user.getText(); SOAPMonitor.axisPass = new String(pass.getPassword()); this.hide(); } else if (e.getSource() == cancel_button) { this.dispose(); } } /** * Get the URL of the AxisServlet we are using * * @return */ public String getURL() { return url.getText(); } /** * Get the login status as a boolean * * @return */ public boolean isLogin() { return loginState; } } /** * This class provides the contents of a notebook page * representing a server connection. */ class SOAPMonitorPage extends JPanel implements Runnable, ListSelectionListener, ActionListener { /** * Status Strings */ private final String STATUS_ACTIVE = "The SOAP Monitor is started."; /** * Field STATUS_STOPPED */ private final String STATUS_STOPPED = "The SOAP Monitor is stopped."; /** * Field STATUS_CLOSED */ private final String STATUS_CLOSED = "The server communication has been terminated."; /** * Field STATUS_NOCONNECT */ private final String STATUS_NOCONNECT = "The SOAP Monitor is unable to communcate with the server."; /** * Private data */ private String host = null; /** * Field socket */ private Socket socket = null; /** * Field in */ private ObjectInputStream in = null; /** * Field out */ private ObjectOutputStream out = null; /** * Field model */ private SOAPMonitorTableModel model = null; /** * Field table */ private JTable table = null; /** * Field scroll */ private JScrollPane scroll = null; /** * Field list_panel */ private JPanel list_panel = null; /** * Field list_buttons */ private JPanel list_buttons = null; /** * Field remove_button */ private JButton remove_button = null; /** * Field remove_all_button */ private JButton remove_all_button = null; /** * Field filter_button */ private JButton filter_button = null; /** * Field details_panel */ private JPanel details_panel = null; /** * Field details_header */ private JPanel details_header = null; /** * Field details_soap */ private JSplitPane details_soap = null; /** * Field details_buttons */ private JPanel details_buttons = null; /** * Field details_time */ private JLabel details_time = null; /** * Field details_target */ private JLabel details_target = null; /** * Field details_status */ private JLabel details_status = null; /** * Field details_time_value */ private JLabel details_time_value = null; /** * Field details_target_value */ private JLabel details_target_value = null; /** * Field details_status_value */ private JLabel details_status_value = null; /** * Field empty_border */ private EmptyBorder empty_border = null; /** * Field etched_border */ private EtchedBorder etched_border = null; /** * Field request_panel */ private JPanel request_panel = null; /** * Field response_panel */ private JPanel response_panel = null; /** * Field request_label */ private JLabel request_label = null; /** * Field response_label */ private JLabel response_label = null; /** * Field request_text */ private SOAPMonitorTextArea request_text = null; /** * Field response_text */ private SOAPMonitorTextArea response_text = null; /** * Field request_scroll */ private JScrollPane request_scroll = null; /** * Field response_scroll */ private JScrollPane response_scroll = null; /** * Field layout_button */ private JButton layout_button = null; /** * Field split */ private JSplitPane split = null; /** * Field status_area */ private JPanel status_area = null; /** * Field status_buttons */ private JPanel status_buttons = null; /** * Field start_button */ private JButton start_button = null; /** * Field stop_button */ private JButton stop_button = null; /** * Field status_text */ private JLabel status_text = null; /** * Field status_text_panel */ private JPanel status_text_panel = null; /** * Field filter */ private SOAPMonitorFilter filter = null; /** * Field details_header_layout */ private GridBagLayout details_header_layout = null; /** * Field details_header_constraints */ private GridBagConstraints details_header_constraints = null; /** * Field reflow_xml */ private JCheckBox reflow_xml = null; /** * Constructor (create and layout page) * * @param host_name */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -