Package org.salamanca.ui

Source Code of org.salamanca.ui.SelectCursoFrame_jButtonCalificaciones_actionAdapter

package org.salamanca.ui;

import java.awt.BorderLayout;

import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JList;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.*;
import java.util.Vector;
import org.salamanca.domain.Curso;
import java.util.*;
import javax.swing.DefaultListModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.salamanca.commands.curso.*;
import javax.swing.text.*;
import java.text.SimpleDateFormat;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import org.salamanca.broker.BrokerServer;
import org.salamanca.domain.User;
import org.salamanca.commands.MessageException;
import componenteTabla.compomenteABMCList;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
import java.text.ParseException;
import java.text.NumberFormat;
import componenteTabla.InsertarEvent;
import componenteTabla.InsertarListener;
import componenteTabla.EliminarEvent;
import componenteTabla.EliminarListener;
import org.jdoinstruments.runtime.discfilemodel.util.DirectOID;
import componenteTabla.ModificarEvent;
import componenteTabla.ModificarListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentAdapter;
import java.util.prefs.Preferences;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class SelectCursoFrame extends JInternalFrame {
    int year;
    DefaultListModel model = new DefaultListModel();
    compomenteABMCList compomenteABMCListCursos = new
                                                  compomenteABMCList();

    NumberFormat numberFormat = NumberFormat.getIntegerInstance();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    SimpleDateFormat dateFormatInicio = new SimpleDateFormat("d-M-yyyy");
    SimpleDateFormat dateFormatFin = new SimpleDateFormat("d-M-yyyy");
    JLabel jLabel5 = new JLabel();
    JFormattedTextField jFormattedTextFieldYear = new JFormattedTextField();
    JLabel jLabel6 = new JLabel();
    BorderLayout borderLayout1 = new BorderLayout();
    JButton jButtonCalificaciones = new JButton();
    CursoSelectableI selectable;
    public SelectCursoFrame(CursoSelectableI selectable) {
        this.selectable = selectable;
        try {
            jbInit();


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

            try {
                jbInit();


            } catch (Exception exception) {
                exception.printStackTrace();
            }
    }
    private void loadTextFieldYear() {

       String yearStr =  BrokerServer.instance().getYearPreference();

        this.jFormattedTextFieldYear.setText(yearStr);

        try {
            year = numberFormat.parse(this.jFormattedTextFieldYear.
                                      getText()).intValue();
            this.loadListCursos(year);
        } catch (ParseException ex) {
            JOptionPane.showMessageDialog(this, "Fecha erronea");
        }

    }

    /**
     * loadList
     */
    private void loadListCursos(int year) {
        try {

            GregorianCalendar calMin = new GregorianCalendar(year, 0, 1);
            GregorianCalendar calMax = new GregorianCalendar(year, 11, 31);

            Date dateMin = calMin.getTime();
            Date dateMax = calMax.getTime();

            compomenteABMCListCursos.clearDatos();

            Vector v = org.salamanca.broker.BrokerServer.instance().
                       queryParameter(
                               Curso.class, "import java.util.Date",
                               "java.util.Date dateMin, java.util.Date dateMax",
                               "fechaInicio>=dateMin && fechaInicio<=dateMax",
                               dateMin, dateMax);
            if ((v != null) && (v.size() > 0)) {
                Object[][] trabajo = new Object[v.size()][6];
                for (int i = 0; i < v.size(); i++) {
                    Curso curso = (Curso) v.elementAt(i);
                    trabajo[i][0] = curso.getNombre();
                    trabajo[i][1] = curso.getObservaciones();
                    SimpleDateFormat dateFormatInicio = new SimpleDateFormat(
                            "d-M-yyyy");
                    trabajo[i][2] = Integer.valueOf(curso.getCantidadPeriodos());
                    trabajo[i][3] = dateFormatInicio.format(curso.
                            getFechaInicio());
                    trabajo[i][4] = dateFormatInicio.format(curso.
                            getFechaFinalizacion());
                    trabajo[i][5] = javax.jdo.JDOHelper.
                                    getObjectId(curso).toString();
                }
                compomenteABMCListCursos.setDatos(trabajo);
            }
        }

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

    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jPanel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 11));
        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        jPanel1.setBounds(new Rectangle(6, 49, 500, 326));

        jPanel1.setLayout(borderLayout1);
        jPanel2.setLayout(null);
        jLabel5.setFont(new java.awt.Font("Arial", Font.PLAIN, 22));
        jLabel5.setText("Cursos");
        jLabel5.setBounds(new Rectangle(93, 11, 165, 30));
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        this.setTitle("Cursos");
        this.addComponentListener(new SelectCursoFrame_this_componentAdapter(this));
        jFormattedTextFieldYear.setFont(new java.awt.Font("Arial", Font.PLAIN,
                14));
        jFormattedTextFieldYear.setBounds(new Rectangle(366, 12, 98, 26));
        jFormattedTextFieldYear.addKeyListener(new
                                               SelectCursoFrame_jFormattedTextFieldYear_keyAdapter(this));
        jLabel6.setFont(new java.awt.Font("Arial", Font.PLAIN, 11));
        jLabel6.setText("A�o");
        jLabel6.setBounds(new Rectangle(313, 16, 45, 18));

        jButtonCalificaciones.setBounds(new Rectangle(211, 12, 117, 22));
        jButtonCalificaciones.setFont(new java.awt.Font("Arial", Font.PLAIN, 11));
        jButtonCalificaciones.setText("Seleccionar");
        jButtonCalificaciones.addActionListener(new
                                                SelectCursoFrame_jButtonCalificaciones_actionAdapter(this));
        this.getContentPane().add(jPanel2);
        jPanel2.add(jButtonCalificaciones);
        this.getContentPane().add(jPanel1);
        jPanel2.setBorder(BorderFactory.createEtchedBorder());
        jPanel2.setBounds(new Rectangle(6, 382, 501, 44));
        this.getContentPane().add(jLabel5);
        this.getContentPane().add(jFormattedTextFieldYear);
        this.getContentPane().add(jLabel6);
        jPanel1.add(compomenteABMCListCursos, java.awt.BorderLayout.CENTER);
        //------------------------ Curso
        compomenteABMCListCursos.setVisibleCantidadRegistros(true);
        compomenteABMCListCursos.setVisibleBuscar(true);
        compomenteABMCListCursos.setInfoColumna(new String[][] { {"nombre",
                                                "tipo", "editable", "editor",
                                                "val.Combo", "Ancho Columna"}
                                                , {"Nombre", "String", "true",
                                                "comun", "", "240"}
                                                , {"Observaciones", "String",
                                                "true", "comun", "", "240"}
                                                , {"Cantidad de Periodos",
                                                "Integer", "true", "comun", "2",
                                                "110"}
                                                , {"Fecha de Inicio", "String",
                                                "true", "comun", "", "100"}
                                                , {"Fecha de Finalizacion",
                                                "String", "true", "comun", "",
                                                "110"}, {"oid", "String",
                                                "false", "comun", "", "1"}
        });

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

        compomenteABMCListCursos.setTituloImprimir("Alumnos del Curso ");

    }

    public void jFormattedTextFieldYear_keyPressed(KeyEvent e) {
        if (e.getKeyCode() == e.VK_ENTER) {

            try {
                year = numberFormat.parse(this.jFormattedTextFieldYear.
                                          getText()).
                       intValue();
                this.loadListCursos(year);

                //grabo en las preferencias
                 BrokerServer.instance().setYearPreference(year);

            } catch (ParseException ex) {
                JOptionPane.showMessageDialog(this, "Fecha erronea");
            }

        }
    }

    public void jButtonCalificaciones_actionPerformed(ActionEvent e) {
        if (compomenteABMCListCursos.getSelectedRow() != -1) {
            String oidStr = ((String) compomenteABMCListCursos.
                             getSelectedRowData().
                             getValueAt(5));

           kodo.util.Id oid = new kodo.util.Id(oidStr);
            try {

                Curso curso = (Curso) org.salamanca.broker.BrokerServer.
                              instance().
                              getPMF().getPersistenceManager().getObjectById(
                                      oid,true);
                this.setVisible(false);
                selectable.setCurso(curso);
                selectable.show();

            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }

        }
    }

    public void this_componentShown(ComponentEvent e) {
        loadTextFieldYear();
    }

    public void setSelectable(CursoSelectableI selectable) {
        this.selectable = selectable;
    }


}


class SelectCursoFrame_this_componentAdapter extends ComponentAdapter {
    private SelectCursoFrame adaptee;
    SelectCursoFrame_this_componentAdapter(SelectCursoFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void componentShown(ComponentEvent e) {
        adaptee.this_componentShown(e);
    }
}


class SelectCursoFrame_jButtonCalificaciones_actionAdapter implements
        ActionListener {
    private SelectCursoFrame adaptee;
    SelectCursoFrame_jButtonCalificaciones_actionAdapter(SelectCursoFrame
            adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButtonCalificaciones_actionPerformed(e);
    }
}


class SelectCursoFrame_jFormattedTextFieldYear_keyAdapter extends KeyAdapter {
    private SelectCursoFrame adaptee;
    SelectCursoFrame_jFormattedTextFieldYear_keyAdapter(SelectCursoFrame
            adaptee) {
        this.adaptee = adaptee;
    }

    public void keyPressed(KeyEvent e) {
        adaptee.jFormattedTextFieldYear_keyPressed(e);
    }
}
TOP

Related Classes of org.salamanca.ui.SelectCursoFrame_jButtonCalificaciones_actionAdapter

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.