⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soapmonitorapplet.java

📁 Spring2.0宝典
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    service_data.addElement(text);                    service_list.setListData(service_data);                }                add_service_field.setText("");                add_service_field.requestFocus();            }            // Check if the user pressed the remove service button            if (e.getSource() == remove_service_button) {                Object[] sels = service_list.getSelectedValues();                for (int i=0; i<sels.length; i++) {                    service_data.removeElement(sels[i]);                }                service_list.setListData(service_data);                service_list.clearSelection();            }        }        /**         * Handle changes to the text field         */        public void changedUpdate(DocumentEvent e) {            String text = add_service_field.getText();            if ((text != null) && (text.length() > 0)) {                add_service_button.setEnabled(true);            } else {                add_service_button.setEnabled(false);            }        }        /**         * Handle changes to the text field         */        public void insertUpdate(DocumentEvent e) {            changedUpdate(e);        }        /**         * Handle changes to the text field         */        public void removeUpdate(DocumentEvent e) {            changedUpdate(e);        }        /**         * Listener to handle service list selection changes         */        public void valueChanged(ListSelectionEvent e) {            if (service_list.getSelectedIndex() == -1) {                remove_service_button.setEnabled(false);            } else {                remove_service_button.setEnabled(true);            }        }    }    /**     * Class for showing the filter dialog     */    class SOAPMonitorFilter implements ActionListener {        /**         * Private data         */        private JDialog            dialog = null;        private JPanel             panel = null;        private JPanel             buttons = null;        private JButton            ok_button = null;        private JButton            cancel_button = null;        private ServiceFilterPanel include_panel = null;        private ServiceFilterPanel exclude_panel = null;        private JPanel             status_panel = null;        private JCheckBox          status_box = null;        private EmptyBorder  empty_border = null;        private EmptyBorder  indent_border = null;        private JPanel             status_options = null;        private ButtonGroup        status_group = null;        private JRadioButton       status_active = null;        private JRadioButton       status_complete = null;        private Vector             filter_include_list = null;        private Vector             filter_exclude_list = null;        private boolean            filter_active = false;        private boolean            filter_complete = false;        private boolean            ok_pressed = false;        /**         * Constructor         */        public SOAPMonitorFilter() {            // By default, exclude NotificationService and            // EventViewerService messages            filter_exclude_list = new Vector();            filter_exclude_list.addElement("NotificationService");            filter_exclude_list.addElement("EventViewerService");        }        /**         * Get list of services to be included         */        public Vector getFilterIncludeList() {            return filter_include_list;        }        /**         * Get list of services to be excluded         */        public Vector getFilterExcludeList() {            return filter_exclude_list;        }        /**         * Check if filter active messages         */        public boolean getFilterActive() {            return filter_active;        }        /**         * Check if filter complete messages         */        public boolean getFilterComplete() {            return filter_complete;        }        /**         * Show the filter dialog         */        public void showDialog() {            empty_border = new EmptyBorder(5,5,0,5);            indent_border = new EmptyBorder(5,25,5,5);            include_panel = new ServiceFilterPanel("Include messages based on target service:",                                                   filter_include_list);            exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:",                                                   filter_exclude_list);            status_box = new JCheckBox("Filter messages based on status:");            status_box.addActionListener(this);            status_active = new JRadioButton("Active messages only");            status_active.setSelected(true);            status_active.setEnabled(false);            status_complete = new JRadioButton("Complete messages only");            status_complete.setEnabled(false);            status_group = new ButtonGroup();            status_group.add(status_active);            status_group.add(status_complete);            if (filter_active || filter_complete) {                status_box.setSelected(true);                status_active.setEnabled(true);                status_complete.setEnabled(true);                if (filter_complete) {                    status_complete.setSelected(true);                }            }            status_options = new JPanel();            status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));            status_options.add(status_active);            status_options.add(status_complete);            status_options.setBorder(indent_border);            status_panel = new JPanel();            status_panel.setLayout(new BorderLayout());            status_panel.add(status_box, BorderLayout.NORTH);            status_panel.add(status_options, BorderLayout.CENTER);            status_panel.setBorder(empty_border);            ok_button = new JButton("Ok");            ok_button.addActionListener(this);            cancel_button = new JButton("Cancel");            cancel_button.addActionListener(this);            buttons = new JPanel();            buttons.setLayout(new FlowLayout());            buttons.add(ok_button);            buttons.add(cancel_button);            panel = new JPanel();            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));            panel.add(include_panel);            panel.add(exclude_panel);            panel.add(status_panel);            panel.add(buttons);            dialog = new JDialog();            dialog.setTitle("SOAP Monitor Filter");            dialog.setContentPane(panel);            dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);            dialog.setModal(true);            dialog.pack();            Dimension d = dialog.getToolkit().getScreenSize();            dialog.setLocation((d.width-dialog.getWidth())/2,                               (d.height-dialog.getHeight())/2);            ok_pressed = false;            dialog.show();        }        /**         * Listener to handle button actions         */        public void actionPerformed(ActionEvent e) {            // Check if the user pressed the ok button            if (e.getSource() == ok_button) {                filter_include_list = include_panel.getServiceList();                filter_exclude_list = exclude_panel.getServiceList();                if (status_box.isSelected()) {                    filter_active = status_active.isSelected();                    filter_complete = status_complete.isSelected();                } else {                    filter_active = false;                    filter_complete = false;                }                ok_pressed = true;                dialog.dispose();            }            // Check if the user pressed the cancel button            if (e.getSource() == cancel_button) {                dialog.dispose();            }            // Check if the user changed the status filter option            if (e.getSource() == status_box) {                status_active.setEnabled(status_box.isSelected());                status_complete.setEnabled(status_box.isSelected());            }        }        /**         * Check if the user pressed the ok button         */        public boolean okPressed() {            return ok_pressed;        }    }    /**     * Text panel class that supports XML reflow     */    class SOAPMonitorTextArea extends JTextArea {        /**         * Private data         */        private boolean format = false;        private String  original = "";        private String  formatted = null;         /**         * Constructor         */        public SOAPMonitorTextArea() {        }        /**          * Override setText to do formatting         */        public void setText(String text) {            original = text;            formatted = null;            if (format) {                doFormat();                super.setText(formatted);            } else {                super.setText(original);            }        }        /**         * Turn reflow on or off         */        public void setReflowXML(boolean reflow) {            format = reflow;            if (format) {                if (formatted == null) {                    doFormat();                }                super.setText(formatted);            } else {                super.setText(original);            }        }        /**         * Reflow XML         */        public void doFormat() {            Vector       parts = new Vector();            char[]       chars = original.toCharArray();            int          index = 0;            int          first = 0;            String       part = null;            while (index < chars.length) {                // Check for start of tag                if (chars[index] == '<') {                    // Did we have data before this tag?                    if (first < index) {                        part = new String(chars,first,index-first);                        part = part.trim();                        // Save non-whitespace data                        if (part.length() > 0) {                            parts.addElement(part);                        }                    }                    // Save the start of tag                    first = index;                }                // Check for end of tag                if (chars[index] == '>') {                    // Save the tag                    part = new String(chars,first,index-first+1);                    parts.addElement(part);                    first = index+1;                }                // Check for end of line                if ((chars[index] == '\n') || (chars[index] == '\r')) {                    // Was there data on this line?                    if (first < index) {                        part = new String(chars,first,index-first);                        part = part.trim();                        // Save non-whitespace data                        if (part.length() > 0) {                            parts.addElement(part);                        }                    }                    first = index+1;                }                index++;            }            // Reflow as XML            StringBuffer buf = new StringBuffer();            Object[] list = parts.toArray();            int indent = 0;            int pad = 0;            index = 0;            while (index < list.length) {                part = (String) list[index];                if (buf.length() == 0) {                    // Just add first tag (should be XML header)                    buf.append(part);                } else {                    // All other parts need to start on a new line                    buf.append('\n');                    // If we're at an end tag then decrease indent                    if (part.startsWith("</")) {                        indent--;                    }                                // Add any indent                    for (pad = 0; pad < indent; pad++) {                        buf.append("  ");                    }                    // Add the tag or data                    buf.append(part);                    // If this is a start tag then increase indent                    if (part.startsWith("<") &&                        !part.startsWith("</") &&                        !part.endsWith("/>")) {                        indent++;                        // Check for special <tag>data</tag> case                        if ((index + 2) < list.length) {                            part = (String) list[index+2];                            if (part.startsWith("</")) {                                part = (String) list[index+1];                                if (!part.startsWith("<")) {                                    buf.append(part);                                    part = (String) list[index+2];                                    buf.append(part);                                    index = index + 2;                                    indent--;                                }                            }                        }                    }                }                index++;            }            formatted = new String(buf);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -