<commit_before>package sidebar;

import javax.swing.*;
import java.awt.*;

/**
 * Created by amir on 5/31/16.
 */
public class LeftTopSideBar extends JPanel {

    // Components
    private JComboBox<String> stateType, stateBacktrack;
    private JTextField finalStateToken;
    private JButton addStateButton, exportButton, loadButton;

    // Values
    private String[] typeValues = { "Initial", "Normal", "Final"};
    private String[] backtrackValues = { "Yes", "No"};

    public LeftTopSideBar() {

        // Set layout
        setLayout(new GridBagLayout());

        // Init components
        stateType = new JComboBox<>(typeValues);
        stateBacktrack = new JComboBox<>(backtrackValues);
        finalStateToken = new JTextField(10);
        addStateButton = new JButton("Add new state");
        exportButton = new JButton("Export to JSON");
        loadButton = new JButton("Load from JSON");

        GridBagConstraints gc = new GridBagConstraints();

        // Set border
        setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

        gc.fill = GridBagConstraints.NONE;
        gc.weightx = 1;
        gc.weighty = 1;

        // Add components
        gc.gridx=0;
        gc.gridy=0;
        add(new JLabel("Type: "), gc);
        gc.gridx=1;
        add(stateType, gc);

        gc.gridx=0;
        gc.gridy=1;
        add(new JLabel("Backtrack: "), gc);
        gc.gridx=1;
        add(stateBacktrack, gc);

        gc.gridx=0;
        gc.gridy=2;
        add(new JLabel("Token: "), gc);
        gc.gridx=1;
        add(finalStateToken, gc);

        gc.gridx=0;
        gc.gridy=3;
        gc.gridwidth = 2;
        add(addStateButton, gc);

        gc.gridx=0;
        gc.gridy=4;
        gc.gridwidth = 2;
        add(exportButton, gc);

        gc.gridx=0;
        gc.gridy=5;
        gc.gridwidth = 2;
        add(loadButton, gc);

    }
}<commit_msg>Added more components to lexical generator<commit_after>package sidebar;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * Created by amir on 5/31/16.
 */
public class LeftTopSideBar extends JPanel {

    // Components
    private JComboBox<String> stateType, stateBacktrack;
    private JTextField finalStateToken;
    private JButton addStateButton, exportButton, loadButton, deleteSelectedEdgeRowButton, addEdgeRowsButton;
    private JPanel statePanel;
    private JTable edgesTable;
    private JScrollPane edgesTableSP;

    // Values
    private String[] typeValues = { "Initial", "Normal", "Final"};
    private String[] backtrackValues = { "Yes", "No"};

    public LeftTopSideBar() {

        // Init components
        stateType = new JComboBox<>(typeValues);
        stateBacktrack = new JComboBox<>(backtrackValues);
        finalStateToken = new JTextField(10);
        addStateButton = new JButton("Add new state");
        exportButton = new JButton("Export to JSON");
        loadButton = new JButton("Load from JSON");
        deleteSelectedEdgeRowButton = new JButton("Delete edge row");
        addEdgeRowsButton = new JButton("Add 10 edge rows");
        statePanel = new JPanel();
        DefaultTableModel tableModel = new DefaultTableModel(null, new Object[]{"From", "To", "Label"});
        edgesTable = new JTable(tableModel);
        edgesTableSP = new JScrollPane(edgesTable);

        // Set layout
        setLayout(new GridBagLayout());
        statePanel.setLayout(new GridBagLayout());

        GridBagConstraints gc = new GridBagConstraints();

        // Set border
        setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

        // Add listeners
        addListeners();

        // Configure components
        configureComponents();

        gc.fill = GridBagConstraints.NONE;
        gc.weightx = 1;
        gc.weighty = 1;
        gc.anchor = GridBagConstraints.FIRST_LINE_START;
        gc.insets = new Insets(5,5,5,5);

        // Add components to state panel
        gc.gridx=0;
        gc.gridy=0;
        statePanel.add(new JLabel("Type: "), gc);
        gc.gridx=1;
        statePanel.add(stateType, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(new JLabel("Backtrack: "), gc);
        gc.gridx=1;
        statePanel.add(stateBacktrack, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(new JLabel("Token: "), gc);
        gc.gridx=1;
        statePanel.add(finalStateToken, gc);

        gc.anchor = GridBagConstraints.CENTER;
        gc.gridx=0;
        gc.gridy++;
        gc.gridwidth = 2;
        statePanel.add(addStateButton, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(edgesTableSP, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(deleteSelectedEdgeRowButton, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(addEdgeRowsButton, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(exportButton, gc);

        gc.gridx=0;
        gc.gridy++;
        statePanel.add(loadButton, gc);

        // Add components to left panel
        gc.anchor = GridBagConstraints.FIRST_LINE_START;
        gc.gridx=0;
        gc.gridy=0;
        add(statePanel, gc);
    }

    public void configureComponents() {

        // By default
        stateBacktrack.setEnabled(false);
        finalStateToken.setEnabled(false);

        // Configure edges table
        edgesTableSP.setPreferredSize(new Dimension(200, 200));
        edgesTable.getTableHeader().setReorderingAllowed(false);

    }

    /**
     * Add buttons listeners
     */
    public void addListeners() {
        stateType.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                // If final state
                if(stateType.getSelectedIndex() == 2) {
                    stateBacktrack.setEnabled(true);
                    finalStateToken.setEnabled(true);
                } else {
                    stateBacktrack.setEnabled(false);
                    finalStateToken.setEnabled(false);
                    finalStateToken.setText("");
                }
            }
        });
    }
}
{'fraction_non_alphanumeric': 0.11502423263327949, 'fraction_numerical': 0.01308562197092084, 'mean_word_length': 2.179763739085773, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2895405', 'n_tokens_mistral': 1947, 'n_tokens_neox': 1806, 'n_words': 383}