Package org.salamanca.ui

Source Code of org.salamanca.ui.CalificacionesFrame_compomenteABMCListPeriodos_eliminarAdapter

package org.salamanca.ui;

import java.awt.BorderLayout;

import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.*;
import javax.swing.BorderFactory;
import componenteTabla.compomenteABMCList;
import org.salamanca.domain.Alumno;
import org.salamanca.broker.BrokerServer;
import java.util.Vector;
import java.util.Iterator;
import java.util.*;
import org.salamanca.domain.Periodo;
import org.salamanca.domain.Curso;
import java.text.SimpleDateFormat;
import org.salamanca.domain.Persona;
import com.borland.jbcl.layout.VerticalFlowLayout;
import com.borland.jbcl.layout.PaneLayout;
import com.borland.jbcl.layout.*;
import java.awt.Rectangle;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Font;
import componenteTabla.InsertarEvent;
import componenteTabla.InsertarListener;
import org.salamanca.commands.periodo.InsertarPeriodo;
import componenteTabla.ClickTableEvent;
import componenteTabla.ClickTableListener;
import org.jdoinstruments.runtime.discfilemodel.util.DirectOID;
import org.salamanca.commands.*;
import componenteTabla.ModificarEvent;
import componenteTabla.ModificarListener;
import org.salamanca.commands.periodo.ModificarPeriodo;
import componenteTabla.EliminarEvent;
import componenteTabla.EliminarListener;
import org.salamanca.commands.periodo.EliminarPeriodo;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CalificacionesFrame extends JInternalFrame implements
        CursoSelectableI {

    BorderLayout borderLayout1 = new BorderLayout();
    JLabel jLabel1 = new JLabel();
    JPanel jPanel1 = new JPanel();
    compomenteABMCList compomenteABMCListPeriodos = new
            compomenteABMCList();
    compomenteABMCList compomenteABMCListAlumnos = new
            compomenteABMCList();
    JPanel jPanel2 = new JPanel();
    BorderLayout borderLayout2 = new BorderLayout();
    BorderLayout borderLayout3 = new BorderLayout();
    JPanel jPanel3 = new JPanel();
    GridLayout gridLayout1 = new GridLayout();
    Curso curso;
    public CalificacionesFrame() {

        try {
            jbInit();

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public void setCurso(Curso curso) {
        this.curso = curso;
        this.jLabel1.setText("Curso : " + curso.getNombre());
        loadListAlumnoDeCurso();
    }


    private void jbInit() throws Exception {
        getContentPane().setLayout(borderLayout1);
        jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 22));
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("Curso xxxx");
        jPanel1.setLayout(borderLayout3);
        jPanel2.setLayout(borderLayout2);
        //------------------------ Periodos
        compomenteABMCListPeriodos.setVisibleCantidadRegistros(false);
        compomenteABMCListPeriodos.setVisibleBuscar(false);
        compomenteABMCListPeriodos.setInfoColumna(new String[][] { {"nombre",
                                                  "tipo", "editable", "editor",
                                                  "val.Combo", "Ancho Columna"}
                                                  , {"Periodo", "String",
                                                  "true", "comun", "0", "50"}
                                                  ,
                                                  {"Inasistencia Injustificadas",
                                                  "Integer",
                                                  "true", "comun", "0", "30"}
                                                  ,
                                                  {"Inasistencias Justificadas",
                                                  "Integer",
                                                  "true", "comun", "0", "30"}
                                                  , {"Leer", "Double", "true",
                                                  "comun", "", "30"}
                                                  , {"Escuchar", "Double",
                                                  "true", "comun", "", "30"}
                                                  , {"Hablar", "Double",
                                                  "true", "comun", "", "30"}
                                                  , {"Escribir", "Double",
                                                  "true", "comun", "", "30"}
                                                  , {"Uso de la lengua",
                                                  "Double",
                                                  "true", "comun", "", "30"},
                                                  {"Conducta", "String",
                                                  "true", "comun", "", "30"},
                                                  {"Observaciones", "String",
                                                  "true", "comun", "", "60"},
                                                  {"oid", "String", "false",
                                                  "comun", "", "1"}
        });

        compomenteABMCListPeriodos.setVisibleAgregar(true);
        compomenteABMCListPeriodos.setVisibleOrdenar(false);
        compomenteABMCListPeriodos.setVisibleModificar(true);
        compomenteABMCListPeriodos.setVisibleImprimir(true);
        compomenteABMCListPeriodos.setVisibleGuardarComo(false);
        compomenteABMCListPeriodos.setVisibleHeaderTabla(true);
        compomenteABMCListPeriodos.setVisibleFiltrar(false);
        compomenteABMCListPeriodos.setVisibleEliminar(true);
        compomenteABMCListPeriodos.setVisibleCopyclipboard(true);
        compomenteABMCListPeriodos.setVisibleReportes(true);

        compomenteABMCListPeriodos.addEliminarListener(new
                CalificacionesFrame_compomenteABMCListPeriodos_eliminarAdapter(this));
        compomenteABMCListPeriodos.addModificarListener(new
                CalificacionesFrame_compomenteABMCListPeriodos_modificarAdapter(this));
        compomenteABMCListPeriodos.addInsertarListener(new
                CalificacionesFrame_compomenteABMCListPeriodos_insertarAdapter(this));
        jPanel1.setBorder(null);
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        this.setMaximizable(true);
        compomenteABMCListAlumnos.addClickTableListener(new
                CalificacionesFrame_compomenteABMCListAlumnos_clickTableAdapter(this));
        this.getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);
        jPanel3.setBorder(BorderFactory.createEtchedBorder());
        jPanel3.setLayout(gridLayout1);
        jPanel1.add(compomenteABMCListPeriodos, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(jLabel1, java.awt.BorderLayout.NORTH);
        jPanel3.add(jPanel2, null);
        jPanel2.add(compomenteABMCListAlumnos, java.awt.BorderLayout.CENTER);
        jPanel3.add(jPanel1, null);
        compomenteABMCListAlumnos.setVisibleCantidadRegistros(true);
        compomenteABMCListAlumnos.setVisibleBuscar(true);
        compomenteABMCListAlumnos.setInfoColumna(new String[][] { {"nombre",
                                                 "tipo", "editable", "editor",
                                                 "val.Combo", "Ancho Columna"}
                                                 , {"Nombre", "String", "true",
                                                 "comun", "", "90"}
                                                 , {"Apellido", "String",
                                                 "true",
                                                 "comun", "", "90"}
                                                 , {"DNI", "Long", "true",
                                                 "comun",
                                                 "", "50"}
                                                 , {"Masculino", "Boolean",
                                                 "false",
                                                 "comun", "", "60"}
                                                 , {"Domicilio", "String",
                                                 "true",
                                                 "comun", "", "50"}
                                                 , {"Localidad", "String",
                                                 "true",
                                                 "comun", "", "50"}
                                                 , {"Codigo Postal", "String",
                                                 "true", "comun", "", "70"}
                                                 , {"Telefono", "String",
                                                 "true",
                                                 "comun", "", "50"}
                                                 , {"Fecha de Nacimiento",
                                                 "String",
                                                 "true", "comun", "", "180"},
                                                 {"oid", "String", "false",
                                                 "comun", "", "1"}

        });
        compomenteABMCListAlumnos.setEditableBoolean(false);
        compomenteABMCListAlumnos.setVisibleAgregar(false);
        compomenteABMCListAlumnos.setVisibleOrdenar(false);
        compomenteABMCListAlumnos.setVisibleModificar(false);
        compomenteABMCListAlumnos.setVisibleImprimir(true);
        compomenteABMCListAlumnos.setVisibleGuardarComo(false);
        compomenteABMCListAlumnos.setVisibleHeaderTabla(true);
        compomenteABMCListAlumnos.setVisibleFiltrar(false);
        compomenteABMCListAlumnos.setVisibleEliminar(false);
        compomenteABMCListAlumnos.setVisibleCopyclipboard(true);
        compomenteABMCListAlumnos.setVisibleReportes(true);

        compomenteABMCListAlumnos.setTituloImprimir("Alumnos del Curso ");

    }


    /**
     * loadListAlumnoDeCurso
     *
     * @param curso Curso
     */
    private void loadListAlumnoDeCurso() {
        if (curso != null) {
            try {

                //actualizo el curso
                curso = (Curso) BrokerServer.instance().getPMF().
                        getPersistenceManager().getObjectById(javax.jdo.
                        JDOHelper.getObjectId(curso),true);

                Vector v = new Vector();
                Iterator iter = curso.getSetAlumnos().iterator();
                while (iter.hasNext()) {
                    Alumno itemAlumno = (Alumno) iter.next();

                    if (itemAlumno.isHabilitado()) { //solo se muestran los alumnos habilitados
                        v.add(itemAlumno);
                    }
                }

                compomenteABMCListAlumnos.clearDatos();
                if (v.size() > 0) {
                    Object[][] trabajo = new Object[v.size()][10];
                    for (int i = 0; i < v.size(); i++) {
                        Alumno alumno = (Alumno) v.elementAt(i);
                        Persona persona = alumno.getPersona();
                        trabajo[i][0] = persona.getNombre();
                        trabajo[i][1] = persona.getApellido();
                        trabajo[i][2] = new Long(persona.getDni());
                        trabajo[i][3] = new Boolean(persona.isMasculino());
                        trabajo[i][4] = persona.getDomicilio();
                        trabajo[i][5] = persona.getLocalidad();
                        trabajo[i][6] = persona.getCodigoPostal();
                        trabajo[i][7] = persona.getTelefono();
                        SimpleDateFormat dateFormatInicio = new
                                SimpleDateFormat(
                                        "d-M-yyyy");
                        trabajo[i][8] = dateFormatInicio.format(persona.
                                getFechaNacimiento());
                        trabajo[i][9] = javax.jdo.JDOHelper.
                                        getObjectId(alumno).toString(); ;
                    }
                    compomenteABMCListAlumnos.setDatos(trabajo);
                    this.compomenteABMCListPeriodos.clearDatos();
                }
            }

            catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    /**
     * loadListAlumnoDeCurso
     *
     * @param curso Curso
     */
    private void loadListCalificacionesDelAlumno(Alumno alumno) {
        if (alumno != null) {
            try {

                //actualizo el curso
                alumno = (Alumno) BrokerServer.instance().getPMF().
                         getPersistenceManager().getObjectById(javax.jdo.
                        JDOHelper.getObjectId(alumno),true);

                compomenteABMCListPeriodos.clearDatos();

                if (alumno.getVectorPeriodos().size() > 0) {
                    Object[][] trabajo = new Object[alumno.getVectorPeriodos().
                                         size()][11];
                    for (int i = 0; i < alumno.getVectorPeriodos().size(); i++) {
                        Periodo periodo = (Periodo) alumno.getVectorPeriodos().
                                          elementAt(i);

                        if (i == alumno.getCurso().getCantidadPeriodos()) { //el ultimo es el Examen
                            trabajo[i][0] = "Examen";
                        } else {
                            trabajo[i][0] = new Integer(i).toString();
                        }
                        trabajo[i][1] = new Integer(periodo.
                                getInasistenciasInjustificadas());
                        trabajo[i][2] = new Integer(periodo.
                                getInasistenciasjustificadas());
                        trabajo[i][3] = new Double(periodo.getLeer());
                        trabajo[i][4] = new Double(periodo.getEscuchar());
                        trabajo[i][5] = new Double(periodo.getHablar());
                        trabajo[i][6] = new Double(periodo.getEscribir());
                        trabajo[i][7] = new Double(periodo.getGramatica());
                        trabajo[i][8] = periodo.getConducta();
                        trabajo[i][9] = periodo.getObservaciones();
                        trabajo[i][10] = javax.jdo.JDOHelper.
                                         getObjectId(periodo).toString(); ;
                    }
                    compomenteABMCListPeriodos.setDatos(trabajo);
                }
            }

            catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    /**
     * compomenteABMCListPeriodos_Insercion
     *
     * @param e InsertarEvent
     */
    public void compomenteABMCListPeriodos_Insercion(InsertarEvent e) {

        if (getUltimoAlumnoSeleccionado() != null) {
            try {

                int inasistenciasInjustificadas = ((Integer) ((Vector) e.
                        getVector()).elementAt(1)).
                                                  intValue();
                int inasistenciasjustificadas = ((Integer) ((Vector) e.
                        getVector()).
                                                 elementAt(2)).intValue();

                double leer = ((Double) ((Vector) e.getVector()).
                               elementAt(3)).doubleValue();
                double escuchar = ((Double) ((Vector) e.getVector()).
                                   elementAt(4)).doubleValue();
                double hablar = ((Double) ((Vector) e.getVector()).
                                 elementAt(5)).doubleValue();
                double escribir = ((Double) ((Vector) e.getVector()).
                                   elementAt(6)).doubleValue();
                double gramatica = ((Double) ((Vector) e.getVector()).
                                    elementAt(7)).doubleValue();
                String conducta = ((String) ((Vector) e.getVector()).
                                   elementAt(8));
                String observaciones = ((String) ((Vector) e.getVector()).
                                        elementAt(9));

                Periodo periodo = new Periodo();

                periodo.setInasistenciasInjustificadas(
                        inasistenciasInjustificadas);
                periodo.setInasistenciasjustificadas(inasistenciasjustificadas);
                periodo.setLeer(leer);
                periodo.setEscuchar(escuchar);
                periodo.setHablar(hablar);
                periodo.setEscribir(escribir);
                periodo.setGramatica(gramatica);
                periodo.setConducta(conducta);
                periodo.setObservaciones(observaciones);

                ICommand insertarPeriodo = CommandFactory.createInsertarPeriodo(
                        getUltimoAlumnoSeleccionado(),
                        periodo);

                insertarPeriodo.execute();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
                this.loadListCalificacionesDelAlumno(
                        getUltimoAlumnoSeleccionado());
                return;

            }
            this.loadListCalificacionesDelAlumno(getUltimoAlumnoSeleccionado());
        }

    }

    public void compomenteABMCListAlumnos_ClickTable(ClickTableEvent e) {
        if (compomenteABMCListAlumnos.getSelectedRow() != -1) {
            this.loadListCalificacionesDelAlumno(getUltimoAlumnoSeleccionado());
        }
    }

    private Alumno getUltimoAlumnoSeleccionado() {
        if (compomenteABMCListAlumnos.getSelectedRow() != -1) {
            String oidStr = ((String) compomenteABMCListAlumnos.
                             getSelectedRowData().
                             getValueAt(9));
            kodo.util.Id oid = new kodo.util.Id(oidStr);
            Alumno alumno = (Alumno) org.salamanca.broker.BrokerServer.instance().
                            getPMF().getPersistenceManager().getObjectById(oid,true);
            return alumno;

        }
        return null;
    }

    /**
     * compomenteABMCListPeriodos_Modificacion
     *
     * @param e ModificarEvent
     */
    public void compomenteABMCListPeriodos_Modificacion(ModificarEvent e) {
        if (compomenteABMCListPeriodos.getSelectedRow() != -1) {
            try {
                String oidStr = ((String) compomenteABMCListPeriodos.
                                 getSelectedRowData().
                                 getValueAt(10));
                kodo.util.Id oid = new kodo.util.Id(oidStr);
                Periodo periodo = (Periodo) org.salamanca.broker.BrokerServer.
                                  instance().getPMF().getPersistenceManager().
                                  getObjectById(oid,true);
                int inasistenciasInjustificadas = ((Integer) ((Vector) e.
                        getVector()).elementAt(1)).
                                                  intValue();
                int inasistenciasjustificadas = ((Integer) ((Vector) e.
                        getVector()).
                                                 elementAt(2)).intValue();

                double leer = ((Double) ((Vector) e.getVector()).
                               elementAt(3)).doubleValue();
                double escuchar = ((Double) ((Vector) e.getVector()).
                                   elementAt(4)).doubleValue();
                double hablar = ((Double) ((Vector) e.getVector()).
                                 elementAt(5)).doubleValue();
                double escribir = ((Double) ((Vector) e.getVector()).
                                   elementAt(6)).doubleValue();
                double gramatica = ((Double) ((Vector) e.getVector()).
                                    elementAt(7)).doubleValue();
                String conducta = ((String) ((Vector) e.getVector()).
                                   elementAt(8));
                String observaciones = ((String) ((Vector) e.getVector()).
                                        elementAt(9));

                ICommand modificarPeriodo = CommandFactory.createModificarPeriodo(
                        periodo, inasistenciasInjustificadas,
                        inasistenciasjustificadas,
                        leer, escuchar, hablar,
                        escribir, gramatica, conducta, observaciones);

                modificarPeriodo.execute();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
                this.loadListCalificacionesDelAlumno(
                        getUltimoAlumnoSeleccionado());

            }
            this.loadListCalificacionesDelAlumno(getUltimoAlumnoSeleccionado());
        }
    }

    /**
     * compomenteABMCListPeriodos_Eliminacion
     *
     * @param e EliminarEvent
     */
    public void compomenteABMCListPeriodos_Eliminacion(EliminarEvent e) {
        String oidStr = ((String) ((Vector) e.getVector()).elementAt(10));

        kodo.util.Id oid = new kodo.util.Id(oidStr);
        Periodo periodo = (Periodo) org.salamanca.broker.BrokerServer.
                          instance().getPMF().getPersistenceManager().
                          getObjectById(oid,true);

        ICommand eliminarPeriodo =CommandFactory.createEliminarPeriodo(
                periodo);
        try {
            eliminarPeriodo.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
            this.loadListCalificacionesDelAlumno(getUltimoAlumnoSeleccionado());

        }
        this.loadListCalificacionesDelAlumno(getUltimoAlumnoSeleccionado());
    }
}


class CalificacionesFrame_compomenteABMCListPeriodos_eliminarAdapter implements
        EliminarListener {
    private CalificacionesFrame adaptee;
    CalificacionesFrame_compomenteABMCListPeriodos_eliminarAdapter(
            CalificacionesFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Eliminacion(EliminarEvent e) {
        adaptee.compomenteABMCListPeriodos_Eliminacion(e);
    }
}


class CalificacionesFrame_compomenteABMCListPeriodos_modificarAdapter implements
        ModificarListener {
    private CalificacionesFrame adaptee;
    CalificacionesFrame_compomenteABMCListPeriodos_modificarAdapter(
            CalificacionesFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Modificacion(ModificarEvent e) {
        adaptee.compomenteABMCListPeriodos_Modificacion(e);
    }
}


class CalificacionesFrame_compomenteABMCListAlumnos_clickTableAdapter implements
        ClickTableListener {
    private CalificacionesFrame adaptee;
    CalificacionesFrame_compomenteABMCListAlumnos_clickTableAdapter(
            CalificacionesFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void ClickTable(ClickTableEvent e) {
        adaptee.compomenteABMCListAlumnos_ClickTable(e);
    }
}


class CalificacionesFrame_compomenteABMCListPeriodos_insertarAdapter implements
        InsertarListener {
    private CalificacionesFrame adaptee;
    CalificacionesFrame_compomenteABMCListPeriodos_insertarAdapter(
            CalificacionesFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Insercion(InsertarEvent e) {
        adaptee.compomenteABMCListPeriodos_Insercion(e);
    }
}
TOP

Related Classes of org.salamanca.ui.CalificacionesFrame_compomenteABMCListPeriodos_eliminarAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.