/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JMeter.plugins.functional.controler.websocketapp;

import JMeter.plugins.functional.samplers.websocket.*;
import java.awt.Color;
import org.apache.jmeter.config.gui.ArgumentsPanel;
import org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;

/**
 *
 * @author Maciej Zaleski
 */
public class WebSocketApplicationRequest extends javax.swing.JPanel {
    private static final Logger log = LoggingManager.getLoggerForClass();
    private HTTPArgumentsPanel attributePanel;

    /**
     * Creates new form WebSocketSamplerPanel
     */
    public WebSocketApplicationRequest() {
        initComponents();

        attributePanel = new HTTPArgumentsPanel();
        querystringAttributesPanel.add(attributePanel);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        requestPayloadEditorPane = new javax.swing.JEditorPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Client Request"));

        jScrollPane1.setViewportView(requestPayloadEditorPane);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 135, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 493, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Response handlers"));

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Successfull", "Quote received", "trade",  new Boolean(true)},
                {"Market closed", "Quote failed", "quote",  new Boolean(true)},
                {"System unavailable", "Quote failed", "quote",  new Boolean(true)}
            },
            new String [] {
                "Handler name", "Response handler", "Application state", "Enabled"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Boolean.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JEditorPane requestPayloadEditorPane;
    // End of variables declaration//GEN-END:variables

    public void initFields() {
    }

    public void setCloseConncectionPattern(String closeConncectionPattern) {
        closeConncectionPatternTextField.setText(closeConncectionPattern);
    }

    public String getCloseConncectionPattern() {
        return closeConncectionPatternTextField.getText();
    }

    public void setConnectionId(String connectionId) {
        connectionIdTextField.setText(connectionId);
    }

    public String getConnectionId() {
        return connectionIdTextField.getText();
    }

    public void setContentEncoding(String contentEncoding) {
        contentEncodingTextField.setText(contentEncoding);
    }

    public String getContentEncoding() {
        return contentEncodingTextField.getText();
    }

    public void setContextPath(String contextPath) {
        contextPathTextField.setText(contextPath);
    }

    public String getContextPath() {
        return contextPathTextField.getText();
    }

    public void setProtocol(String protocol) {
        protocolTextField.setText(protocol);
    }

    public String getProtocol() {
        return protocolTextField.getText();
    }

    public void setProxyAddress(String proxyAddress) {
        proxyAddressTextField.setText(proxyAddress);
    }

    public String getProxyAddress() {
        return proxyAddressTextField.getText();
    }

    public void setProxyPassword(String proxyPassword) {
        proxyPasswordTextField.setText(proxyPassword);
    }

    public String getProxyPassword() {
        return proxyPasswordTextField.getText();
    }

    public void setProxyPort(String proxyPort) {
        proxyPortTextField.setText(proxyPort);
    }

    public String getProxyPort() {
        return proxyPortTextField.getText();
    }

    public void setProxyUsername(String proxyUsername) {
        proxyUsernameTextField.setText(proxyUsername);
    }

    public String getProxyUsername() {
        return proxyUsernameTextField.getText();
    }

    public void setResponsePattern(String responsePattern) {
        responsePatternTextField.setText(responsePattern);
    }

    public String getResponsePattern() {
        return responsePatternTextField.getText();
    }

    public void setResponseTimeout(String responseTimeout) {
        responseTimeoutTextField.setText(responseTimeout);
    }

    public String getResponseTimeout() {
        return responseTimeoutTextField.getText();
    }

    public void setConnectionTimeout(String connectionTimeout) {
        connectionTimeoutTextField.setText(connectionTimeout);
    }

    public String getConnectionTimeout() {
        return connectionTimeoutTextField.getText();
    }

    public void setServerAddress(String serverAddress) {
        serverAddressTextField.setText(serverAddress);
    }

    public String getServerAddress() {
        return serverAddressTextField.getText();
    }

    public void setServerPort(String serverPort) {
        serverPortTextField.setText(serverPort);
    }

    public String getServerPort() {
        return serverPortTextField.getText();
    }

    public void setRequestPayload(String requestPayload) {
        requestPayloadEditorPane.setText(requestPayload);
    }

    public String getRequestPayload() {
        return requestPayloadEditorPane.getText();
    }

    public void setStreamingConnection(Boolean streamingConnection) {
        streamingConnectionCheckBox.setSelected(streamingConnection);
    }

    public Boolean isStreamingConnection() {
        return streamingConnectionCheckBox.isSelected();
    }

    public void setIgnoreSslErrors(Boolean ignoreSslErrors) {
        ignoreSslErrorsCheckBox.setSelected(ignoreSslErrors);
    }

    public Boolean isIgnoreSslErrors() {
        return ignoreSslErrorsCheckBox.isSelected();
    }

    public void setImplementation(String implementation) {
        implementationComboBox.setSelectedItem(implementation);
    }

    public String getImplementation() {
        return (String) implementationComboBox.getSelectedItem();
    }

    public void setMessageBacklog(String messageBacklog) {
        messageBacklogTextField.setText(messageBacklog);
    }

    public String getMessageBacklog() {
        return messageBacklogTextField.getText();
    }    

    /**
     * @return the attributePanel
     */
    public ArgumentsPanel getAttributePanel() {
        return attributePanel;
    }
}