/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import config.SwingComponents;
import controller.DisciplinaController;
import design.factory.JPanelFactory;
import java.awt.Container;

/**
 *
 * @author evson
 */
public class PanelAdicionarDisciplina extends javax.swing.JPanel {

    /**
     * Creates new form PanelAdicionarDisciplina
     */
    public PanelAdicionarDisciplina() {
        initComponents();
    }

    /**
     * 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        subTitulo = new javax.swing.JLabel();
        separador1 = new javax.swing.JSeparator();
        labelNome = new javax.swing.JLabel();
        textNome = new javax.swing.JTextField();
        separador2 = new javax.swing.JSeparator();
        buttonSalvar = new javax.swing.JButton();
        buttonVoltar = new javax.swing.JButton();

        setName("body"); // NOI18N
        setPreferredSize(new java.awt.Dimension(670, 325));
        setLayout(new java.awt.GridBagLayout());

        subTitulo.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        subTitulo.setText("Adicionar Disciplina");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(subTitulo, gridBagConstraints);

        separador1.setPreferredSize(new java.awt.Dimension(100, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        add(separador1, gridBagConstraints);

        labelNome.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        labelNome.setText("Nome:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(labelNome, gridBagConstraints);

        textNome.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        textNome.setPreferredSize(new java.awt.Dimension(200, 30));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(textNome, gridBagConstraints);

        separador2.setPreferredSize(new java.awt.Dimension(100, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        add(separador2, gridBagConstraints);

        buttonSalvar.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        buttonSalvar.setText("Salvar");
        buttonSalvar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonSalvarMouseClicked(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(buttonSalvar, gridBagConstraints);

        buttonVoltar.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        buttonVoltar.setText("Voltar");
        buttonVoltar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonVoltarMouseClicked(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(buttonVoltar, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonVoltarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonVoltarMouseClicked
        Container parent = getParent();
        parent.setVisible(false);
        parent.remove(this);
        parent.add(SwingComponents.setPainelBody(JPanelFactory.getPanel("menu")));
        parent.setVisible(true);
    }//GEN-LAST:event_buttonVoltarMouseClicked

    private void buttonSalvarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonSalvarMouseClicked
        // TODO add your handling code here:
        DisciplinaController.getInstance().adicionarDisciplina(textNome.getText());
        buttonVoltarMouseClicked(evt);
    }//GEN-LAST:event_buttonSalvarMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonSalvar;
    private javax.swing.JButton buttonVoltar;
    private javax.swing.JLabel labelNome;
    private javax.swing.JSeparator separador1;
    private javax.swing.JSeparator separador2;
    private javax.swing.JLabel subTitulo;
    private javax.swing.JTextField textNome;
    // End of variables declaration//GEN-END:variables
}
